1 / 23

ITF11006 .NET

ITF11006 .NET. Industrial Programming. Industrial Programming. Guidelines Development Guidelines UX Guidelines Quality Measures Code Metrics Code Analyses Robustness Error handling (exceptions) Resource handling. Guidelines.

geordi
Télécharger la présentation

ITF11006 .NET

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. ITF11006 .NET Industrial Programming

  2. Industrial Programming • Guidelines • Development Guidelines • UX Guidelines • Quality Measures • Code Metrics • Code Analyses • Robustness • Error handling (exceptions) • Resource handling

  3. Guidelines • Design Guidelines for Developing Class Libraries(http://msdn.microsoft.com/en-us/library/ms229042.aspx) • Guidelines for Names • Capitalization Conventions(http://msdn.microsoft.com/en-us/library/ms229043(v=vs.100).aspx) • Member Design Guidelines • Choosing Between Properties and Methods(http://msdn.microsoft.com/en-us/library/ms229054.aspx) • Documentation of code

  4. Documentation of code • Documentable Entities • Class / Struct • Method • … • Cannot document Namespace through XML tag • Shows up in • Object Browser • Intellisense • Library Documentation

  5. Documentation of code (cont.) • XML tags(http://msdn.microsoft.com/en-us/library/5ast78ax.aspx) • summary • param • example • code • exception • returns • GhostDoc

  6. Guidelines • Design Guidelines for Developing Class Libraries(http://msdn.microsoft.com/en-us/library/ms229042.aspx) • Guidelines for Names • Capitalization Conventions(http://msdn.microsoft.com/en-us/library/ms229043(v=vs.100).aspx) • Member Design Guidelines • Choosing Between Properties and Methods(http://msdn.microsoft.com/en-us/library/ms229054.aspx) • Documentation of code • UX Guidelines

  7. UX Guidelines • Windows Size • Default • Min • Max • Resizing must work! • Clean layout • Shortcuts • Tab-order

  8. Industrial Programming • Guidelines • Development Guidelines • UX Guidelines • Quality Measures • Code Metrics • Code Analyses • Robustness • Error handling (exceptions) • Resource handling

  9. Code Metrics • Cyclomatic complexity • Structural complexity of code • Calculates number of different code paths • High values requires more unit tests to cover all paths • Class Coupling • Measures the Efferent Coupling, the number of classes this method depends on • High coupling means brittle, likely to change, probably unfocused and lack of responsibility • Lines of Code • Based on IL, so approximate, but better than source • Excludes white space, comments, braces, types etc.

  10. Code Metrics (cont.) • Maintainability Index: • A weighted number based on Halstead volume, cyclomatic complexity and lines of code • Maintainability Index = MAX(0,(171 - 5.2 * ln(Halstead Volume) - 0.23 * (Cyclomatic Complexity) - 16.2 * ln(Lines of Code))*100 / 171) • A green rating is between 20 and 100 and indicates that the code has good maintainability. A yellow rating is between 10 and 19 and indicates that the code is moderately maintainable. A red rating is a rating between 0 and 9 and indicates low maintainability.

  11. Code Metrics • Use MS official sample • “Image slideshow in full screen mode” (http://code.msdn.microsoft.com/CSImageFullScreenSlideShow-79e29568)

  12. Code Metrics – VS 2010

  13. Code Metrics – Excel

  14. Code Analyses • Rule Set • Rule Action • Automatic / Manual execution • Use from Start

  15. Code Analyses - Settings

  16. Code Analyses – Results/Fix

  17. Code Analyses – Requirements • Microsoft Minimum Recommended Rules +Microsoft.Naming (All) • HiOf.Net.ruleset

  18. Industrial Programming • Guidelines • Development Guidelines • UX Guidelines • Quality Measures • Code Metrics • Code Analyses • Robustness • Defensive Programming • Error handling (exceptions) • Resource handling

  19. Defensive Programming • Handle anticipated deviations • Missing Directory / File • Lack of database connectivity • Lost database connection • Verify input data • Do not let the user enter erroneous data • Guard against SQL injection • Use SQL procedures / bind variables

  20. Error handling

  21. Exceptions • Do not throw System.Exception • Inherit from System.Exception • End with Exception

  22. Exceptions • Exception handling • Throwing exceptions • Exception info • Message • InnerException • Library code rethrows/do not catch • Clients shall handle exceptions

  23. Resource handling

More Related