1 / 49

Improving Code Quality writing better, faster code, in less time with Visual Studio 2010

Improving Code Quality writing better, faster code, in less time with Visual Studio 2010. Code Quality best practices in day-to-day development using Visual Studio 2010.

vilmaris
Download Presentation

Improving Code Quality writing better, faster code, in less time with Visual Studio 2010

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Improving Code Quality • writing better, faster code, in less time with Visual Studio 2010 Code Quality best practices in day-to-day development using Visual Studio 2010. As building software becomes more complex, the probability of exposing end-users to application defects increases exponentially. Software quality begins as soon as you start writing code. Improving code quality is the first line of offense in quality management. Learn how to improve code quality by using Visual Studio tools like Unit Testing, Static Code Analysis, Code Profiler, Test Impact Analysis, and Intellitrace. • Randy Pagels • Sr. Developer Technical Specialist • Microsoft Corporation • Email: rpagels@microsoft.com • Website: http://www.teamsystemcafe.net • Specialist covering Heartland • (MI, OH, KY, and TN) • Team Foundation Server • Visual Studio ALM tools • Visual Studio Test Professional • Lab Management

  2. Improving Code Quality writing better, faster code, in less time!

  3. The Big Picture Release Test Cost of Bugs Development Software Phase

  4. Push Quality Upstream Release Test Cost of Bugs Development Software Phase

  5. Unit Testing with Code Coverage

  6. Unit Testing • Improve your code quality • Isolate and show that the individual parts are correct • Provides a strict, written contract that must be satisfied • Code Coverage Metrics • Bind to a Data Source • Generate tests from a binary • Execute during automated builds • Contextual Execution • Faster and more reliable

  7. Code Coverage • Verify code paths touched by test cases • A measure in the effectiveness of testing efforts • Helps identify code not covered by tests • Summary data and line level • Part of shared team reports

  8. Static Code Analysis

  9. Code Analysis Overview • Catch common programming errors • Analyze application and database code for defects and security vulnerabilities • Detect code defects early on • Use Code Analysis as part of check-in policy to prevent defects • Improve and maintain code quality using Code Metrics • Manage and triage Code Analysis warnings and errors using the Rule Set editor • Automate Code Analysis as part of your build process

  10. Catch Common Programming Errors What if the parameter ‘order’ is null? Code Analysis will warn the developer of this type of programming error and others like it.

  11. Detect Code Defects Early On Just like compiler warnings, Code Analysis errors are shown in the Error List for easy triage.

  12. Rule Set Editor The new “Rule Set” editor allows you to manage Code Analysis errors and warnings Inline Help system displays detailed information about each rule and provides code examples that will cause the error

  13. Understand Code Quality The Code Metrics window allows you to see the overall “code health” of your application

  14. Code Profiler

  15. Today developers have difficulties in identifying Performance Bottlenecks • Is my application using too much CPU? • Is my application using too much memory? • Does my application block on I/O or Database call unnecessarily? • Is my application making unnecessary Database calls?

  16. Evolution of Visual Studio Profiler Sample Profiling Instrumentation Profiling .NET Memory Profiling Reports and Analysis Enhanced Analysis Capabilities Report Comparisons 64-Bit Support Developer Productivity Platform and Technology

  17. Developer Productivity • New Summary and Function Details reports • Editor Integration • Just My Code • Rules and Guidance • Profiling In Progress Window

  18. Platform and Technology • Virtualization Support • Tier Interaction Profiling • Client Side JavaScript Profiling • Concurrency Profiling • Attach to Applications running on .NET 4.0 • Profiling Windows HPC Applications

  19. Summary and Function Details reports Developer Productivity • Actionable performance data presented on the summary page • Actionable performance chart allows the user to identify performance bottlenecks visually and zoom into the non-performing area • Visualized Call Tree and highlighted hot lines in the new Function Details Page

  20. Summary ReportsDeveloper Productivity Easily Locate Performance Spikes Identify Most Expensive Call Path Detect Functions responsible for most work

  21. Function Details ReportsDeveloper Productivity Visualize the call pattern of each method along with corresponding performance data Identify code with considerable performance impact

  22. Tier Interaction ProfilingPlatform and Technology • Analyze the performance of a multi-tier application against its Data tier and SQL Server • Analyze page request patterns and database interactions for web applications Show database queries and requests

  23. Tier Interaction Profiling Platform and Technology Timing information for servicing each page Number of page requests for each ASP.NET page Database B Connection + Number of Queries + total query time for each page Detailed Query Information for each page and each database connection

  24. Test Impact Analysis

  25. Difficulty Identifying the “right” tests • Today, there is no tool that identifies the “right” tests in need of re-verification • Developers either • Run more unit tests than needed • Run too few unit tests than needed • Testers either • Verify more tests than needed • Verify too few tests than needed • Which leads to • Lower productivity • Comprise the application’s quality

  26. Test Impact Analysis • Drives quality upstream by preventing bugs from getting into the system earlier in the life cycle. • Developers know the “right” tests impacted by their code change • Testers know the “right” tests to verify for a given build • Enhance development process by requiring verification of impacted automated tests before developers check changes into Source Control System

  27. TIA – Show Impacted Tests One Code Change resulted in 21 impacted Tests

  28. Show Code Changes View impacted tests per code change

  29. Analyze Impacted Tests During Build Enable Test Impact Analysis Build report lists impacted tests and associated code changes

  30. Static Code Analysis Code Profiler Test Impact Analysis

  31. Reduce Cost Downstream Release Test Cost of Bugs Development Software Phase

  32. IntelliTrace

  33. The world of development… • Developers have poor tools to reproduce problem scenarios and environments • Developers spend too much time sending bugs “over-the-wall” back to testers to get more information • Once a problem has occurred, it’s too late • Why can’t I simply rewind my application? • Why can’t I go back to what caused the problem?

  34. Benefits of IntelliTrace • Low overhead for collection • Enable collection in Dev, Test and Production environments • Pay-as-you-go collection model • Collect as little or much data as performance requirements allow • Diagnose a specific set of user issues • Application’s misuse of the .NET Framework • Class of failures in the application’s code • First-class debugging experience in Visual Studio

  35. What is IntelliTrace? • Application flight recorder and debugger • Similar to SysInternalsFileMon/RegMonexperience • Dynamically instruments code • Two flavors: “Low overhead” and “more in-depth” • Records program execution flow • Records program data (parameters& return values) • Allows the user to analyze and debug code in the familiar Visual Studio debugger

  36. Feature breakdown • IntelliTrace Default Experience • IntelliTraceEvents View • Configuring IntelliTrace • User controllable settings • Collecting call information • “Turning up the dial” to collect richer data • IntelliTrace Calls View • Debugger integration and the navigation gutter • Search history from code

  37. IntelliTrace Under the Hood

  38. IntelliTrace in Visual Studio 2010 * IntelliTrace is only supported on Microsoft Visual Studio 2010 Ultimate

  39. IntelliTrace™ • Codenamed “Historical Debugging” • Reduces debug “cycling” • Start Debug • Encounter defect • Drop into debugger • Move back through execution history to locate defect • Historical debug trace enables debugging off-machine test runs

  40. IntelliTrace Events The IntelliTrace window collects a list of common uses of the .NET Framework similar to SysInternalsFileMon/RegMon. Clicking the event causes the instruction pointer to highlight the line of source corresponding to the event. The navigation control allows you to step backwards, go forward, and jump back to live debugging mode quickly from any historical context.

  41. IntelliTrace Events The IntelliTrace window collects a list of common uses of the .NET Framework similar to SysInternalsFileMon/RegMon. Clicking the event causes the instruction pointer to highlight the line of source corresponding to the event.

  42. Post-mortem Analysis with IntelliTrace The thread chart gives the developer a timeline view of what took place in the application’s execution. All exceptions that occurred during the execution are summarized and offer the user a “jumping off point” to start a debugging session.

  43. Capture and Analyze bugs with Intellitrace

  44. Customizable XML start screen Improved readability Unnecessary gradients removed Reduced clutter Code editor based on WPF Search-as-you-type View Call Hierarchy Redesigned thread window for debugging Simplified one click web deployment Visual Studio IDE Enhancements

  45. Visual Studio IDE Enhancements cont. • WPF Start Page • Enhanced Docking Behavior • Zoom (Ctrl + mouse wheel) • Box Selection (Alt + select with mouse) • View Call Hierarchy (Ctrl + K, T) – design time • Navigate To – in the Edit menu or (Ctrl + Comma) • Quick Search (Ctrl-"comma")-All Spaces treated as wildcards. Camel case. • Highlighting References – select any symbol • Generate From Usage feature lets you use classes and members before you define them. • IntelliSense Suggestion Mode (vs. Completion Mode, Ctrl + Alt + Space to toggle). Use suggestion mode when classes and members are used before they are defined. What's New in the Visual Studio 2010 Editor http://msdn.microsoft.com/en-us/library/dd465268.aspx

  46. Find bugs early in the development cycle Code review by expert framework builders Tweak your use of the .NET Framework Analyze application and database code for defects Use the new “Rule Sets” feature to manage code defects Can be used at the team level with TFS Prevent Code Defects

  47. Find resource bottlenecks CPU performance issues Memory usage Multiple modes of measurement Sampling Instrumentation Memory Allocation Measure, diagnose and fix performance problems across tiers Visualize bottlenecks in concurrent code and analyze resource usage Write Faster Code

  48. Choose the Right Tests • Option to run the Test Impact Data Collector • Identifies tests impacted by code changes from multiple angles • Impacted Tests • Code Changes • Calling Tests • List of changes made since last build • Significantly reduces test time • Run only the necessary tests • Deep integration with Test Case Management

More Related