itf11006 .net
DESCRIPTION
ITF11006 .NET. Industrial Programming. Industrial Programming. Guidelines Development Guidelines UX Guidelines Quality Measures Code Metrics Code Analyses Robustness Error handling (exceptions) Resource handling. Guidelines. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: ITF11006 .NET](https://reader034.vdocument.in/reader034/viewer/2022051821/56815550550346895dc31d8a/html5/thumbnails/1.jpg)
ITF11006 .NET
Industrial Programming
![Page 2: ITF11006 .NET](https://reader034.vdocument.in/reader034/viewer/2022051821/56815550550346895dc31d8a/html5/thumbnails/2.jpg)
Industrial Programming
• Guidelines– Development Guidelines– UX Guidelines
• Quality Measures– Code Metrics– Code Analyses
• Robustness– Error handling (exceptions)– Resource handling
![Page 3: ITF11006 .NET](https://reader034.vdocument.in/reader034/viewer/2022051821/56815550550346895dc31d8a/html5/thumbnails/3.jpg)
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
![Page 4: ITF11006 .NET](https://reader034.vdocument.in/reader034/viewer/2022051821/56815550550346895dc31d8a/html5/thumbnails/4.jpg)
Documentation of code
• Documentable Entities– Class / Struct– Method– …
• Cannot document Namespace through XML tag• Shows up in
– Object Browser– Intellisense– Library Documentation
![Page 5: ITF11006 .NET](https://reader034.vdocument.in/reader034/viewer/2022051821/56815550550346895dc31d8a/html5/thumbnails/5.jpg)
Documentation of code (cont.)• XML tags (http://msdn.microsoft.com/en-us/library/5ast78ax.aspx)
– summary– param– example– code– exception– returns
• GhostDoc
![Page 6: ITF11006 .NET](https://reader034.vdocument.in/reader034/viewer/2022051821/56815550550346895dc31d8a/html5/thumbnails/6.jpg)
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
![Page 7: ITF11006 .NET](https://reader034.vdocument.in/reader034/viewer/2022051821/56815550550346895dc31d8a/html5/thumbnails/7.jpg)
UX Guidelines
• Windows Size– Default– Min– Max
• Resizing must work!• Clean layout• Shortcuts• Tab-order
![Page 8: ITF11006 .NET](https://reader034.vdocument.in/reader034/viewer/2022051821/56815550550346895dc31d8a/html5/thumbnails/8.jpg)
Industrial Programming
• Guidelines– Development Guidelines– UX Guidelines
• Quality Measures– Code Metrics– Code Analyses
• Robustness– Error handling (exceptions)– Resource handling
![Page 9: ITF11006 .NET](https://reader034.vdocument.in/reader034/viewer/2022051821/56815550550346895dc31d8a/html5/thumbnails/9.jpg)
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.
![Page 10: ITF11006 .NET](https://reader034.vdocument.in/reader034/viewer/2022051821/56815550550346895dc31d8a/html5/thumbnails/10.jpg)
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.
![Page 11: ITF11006 .NET](https://reader034.vdocument.in/reader034/viewer/2022051821/56815550550346895dc31d8a/html5/thumbnails/11.jpg)
Code MetricsMetric Green Yellow Red
Maintainability Index 100-60 60-40 <40
Cyclomatic complexity <10 10-20 >20
Class Coupling <10 10-20 >20
Lines of Code <10 10-30 >30
• Use MS official sample– “Image slideshow in full screen mode”
(http://code.msdn.microsoft.com/CSImageFullScreenSlideShow-79e29568)
![Page 12: ITF11006 .NET](https://reader034.vdocument.in/reader034/viewer/2022051821/56815550550346895dc31d8a/html5/thumbnails/12.jpg)
Code Metrics – VS 2010
![Page 13: ITF11006 .NET](https://reader034.vdocument.in/reader034/viewer/2022051821/56815550550346895dc31d8a/html5/thumbnails/13.jpg)
Code Metrics – Excel
![Page 14: ITF11006 .NET](https://reader034.vdocument.in/reader034/viewer/2022051821/56815550550346895dc31d8a/html5/thumbnails/14.jpg)
Code Analyses
• Rule Set• Rule Action• Automatic / Manual execution• Use from Start
![Page 15: ITF11006 .NET](https://reader034.vdocument.in/reader034/viewer/2022051821/56815550550346895dc31d8a/html5/thumbnails/15.jpg)
Code Analyses - Settings
![Page 16: ITF11006 .NET](https://reader034.vdocument.in/reader034/viewer/2022051821/56815550550346895dc31d8a/html5/thumbnails/16.jpg)
Code Analyses – Results/Fix
![Page 17: ITF11006 .NET](https://reader034.vdocument.in/reader034/viewer/2022051821/56815550550346895dc31d8a/html5/thumbnails/17.jpg)
Code Analyses – Requirements• Microsoft Minimum Recommended Rules
+Microsoft.Naming (All)• HiOf.Net.ruleset
![Page 18: ITF11006 .NET](https://reader034.vdocument.in/reader034/viewer/2022051821/56815550550346895dc31d8a/html5/thumbnails/18.jpg)
Industrial Programming
• Guidelines– Development Guidelines– UX Guidelines
• Quality Measures– Code Metrics– Code Analyses
• Robustness– Defensive Programming– Error handling (exceptions)– Resource handling
![Page 19: ITF11006 .NET](https://reader034.vdocument.in/reader034/viewer/2022051821/56815550550346895dc31d8a/html5/thumbnails/19.jpg)
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
![Page 20: ITF11006 .NET](https://reader034.vdocument.in/reader034/viewer/2022051821/56815550550346895dc31d8a/html5/thumbnails/20.jpg)
Error handling
![Page 21: ITF11006 .NET](https://reader034.vdocument.in/reader034/viewer/2022051821/56815550550346895dc31d8a/html5/thumbnails/21.jpg)
Exceptions
• Do not throw System.Exception• Inherit from System.Exception• End with Exception
![Page 22: ITF11006 .NET](https://reader034.vdocument.in/reader034/viewer/2022051821/56815550550346895dc31d8a/html5/thumbnails/22.jpg)
Exceptions
• Exception handling• Throwing exceptions• Exception info– Message– InnerException
• Library code rethrows/do not catch• Clients shall handle exceptions
![Page 23: ITF11006 .NET](https://reader034.vdocument.in/reader034/viewer/2022051821/56815550550346895dc31d8a/html5/thumbnails/23.jpg)
Resource handling