0
South Bay  Clean CodeWhy Clean Code matters   Mountain View, March 2nd 2011
Theo Jungeblut• Senior Software Developer at  Omnicell Inc. in Mountain View• Has been designing and  implementing .NET ba...
Overview• Why Clean Code• Tools       •   Resharper       •   FxCop, StyleCop & StyleCop plugin for Resharper       •   Gh...
Does writing Clean Codemake us more efficient?
What is Clean Code?
http://www.technicopedia.com/8865.html
http://www.technicopedia.com/8865.html
http://technicbricks.blogspot.com/2009/06/tbs-techpoll-12-results-2009-1st.html
.NET Tools and their ImpactTool name        Positive Impact            Negative ImpactResharper        compiling -- -- -- ...
Resharper“The single most impacting development        addition to Visual Studio”     Features:       –   Code Analysis   ...
FxCop / Code AnalysisStatic Code Analysis:  – Correctness  – Library design  – Internationalization and localization  – Na...
•   Design-by-Contract programming•   Improved testability•   Static verification•   API documentation    http://msdn.micr...
Method OverviewCode Contracts User Manual, 5.3 Contract Ordering, page 22
Runtime Checking LevelsCode Contracts User Manual, 6.2.1 Runtime Checking Level, page 24
Argument ValidationCode Contracts User Manual,5.1 Argument Validation andContracts, page 18
Microsoft Pex & Moles• Pex automatically generates test suites with  high code coverage.• Moles allows to replace any .NET...
Ghost Doc• Save keystrokes and time• Simplify documenting your code• Benefit of the base class documentation          http...
Spell Checker  • Spelll chicking for texts and comments in VShttp://visualstudiogallery.msdn.microsoft.com/7c8341f1-ebac-4...
Graphic by Michael Hönnig http://michael.hoennig.de/2009/08/08/clean-code-developer-ccd/
Keep it simple, stupid        (KISS)
Graphic by Nathan Sawaya courtesy of brickartist.com
Don’t repeat yourself        (DRY)
Separation of Concerns (SoC)Single Responsibility Principle (SRP)
Component-Oriented   Programming       (CoP)
Dependency Inversion Principle           (DIP)
S               Single Responsibility Principle   O               Open/Closed Principle   L               Liskov Substitut...
Source Code Conventions
Let’s switch to the code
Summary Clean CodeBeing more efficient through:• Simplification and Specialization   (KISS, SoC, SRP)• Decoupling   (Contr...
Q&AGraphic by Nathan Sawaya courtesy of brickartist.com
ReferencesResharperhttp://www.jetbrains.com/resharper/FxCop / Code Analysishttp://msdn.microsoft.com/en-us/library/bb42947...
gotowww.csharp-lighthouse.com           for  slides & code examples
Clean Code for Bay.NET User Group (2011-03-02)
Clean Code for Bay.NET User Group (2011-03-02)
Clean Code for Bay.NET User Group (2011-03-02)
Clean Code for Bay.NET User Group (2011-03-02)
Upcoming SlideShare
Loading in...5
×

Clean Code for Bay.NET User Group (2011-03-02)

2,403

Published on

Bay.NET User Group South Bay Chapter presentation on Clean Code principles and best practices from March 3rd 2010.

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,403
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
25
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Transcript of "Clean Code for Bay.NET User Group (2011-03-02)"

  1. 1. South Bay Clean CodeWhy Clean Code matters Mountain View, March 2nd 2011
  2. 2. Theo Jungeblut• Senior Software Developer at Omnicell Inc. in Mountain View• Has been designing and implementing .NET based applications , components and frameworks for 8 years• Previously worked in factory automation with focus on component based software and framework development for 3 ½ years theo@csharp-lighthouse.com• Degree in Software Engineering and Network Communications www.csharp-lightouse.com
  3. 3. Overview• Why Clean Code• Tools • Resharper • FxCop, StyleCop & StyleCop plugin for Resharper • GhostDoc & Spell Checker • Code Contracts, Pex & Moles• Clean Code Developer Initiative• Principles and Practices• Code Comparison• Q&A
  4. 4. Does writing Clean Codemake us more efficient?
  5. 5. What is Clean Code?
  6. 6. http://www.technicopedia.com/8865.html
  7. 7. http://www.technicopedia.com/8865.html
  8. 8. http://technicbricks.blogspot.com/2009/06/tbs-techpoll-12-results-2009-1st.html
  9. 9. .NET Tools and their ImpactTool name Positive Impact Negative ImpactResharper compiling -- -- -- VS responsiveness --FxCop code quality +++ compiling +StyleCop code quality compiling +StyleCop plugin compiling --- VS responsiveness --for ResharperGhost Doc automated docs potentially worse docSpell Checker fewer spelling errors performance --Code Contracts testability, quality +++ compiling ++Pex & Moles automated test limited
  10. 10. Resharper“The single most impacting development addition to Visual Studio” Features: – Code Analysis – Code Templates – Code Generation – Code Cleanup – Many, many more… http://www.jetbrains.com/resharper/
  11. 11. FxCop / Code AnalysisStatic Code Analysis: – Correctness – Library design – Internationalization and localization – Naming conventions – Performance – Security
  12. 12. • Design-by-Contract programming• Improved testability• Static verification• API documentation http://msdn.microsoft.com/en-us/devlabs/dd491992
  13. 13. Method OverviewCode Contracts User Manual, 5.3 Contract Ordering, page 22
  14. 14. Runtime Checking LevelsCode Contracts User Manual, 6.2.1 Runtime Checking Level, page 24
  15. 15. Argument ValidationCode Contracts User Manual,5.1 Argument Validation andContracts, page 18
  16. 16. Microsoft Pex & Moles• Pex automatically generates test suites with high code coverage.• Moles allows to replace any .NET method with a delegate. http://research.microsoft.com/en-us/projects/pex/
  17. 17. Ghost Doc• Save keystrokes and time• Simplify documenting your code• Benefit of the base class documentation http://submain.com/products/ghostdoc.aspx
  18. 18. Spell Checker • Spelll chicking for texts and comments in VShttp://visualstudiogallery.msdn.microsoft.com/7c8341f1-ebac-40c8-92c2-476db8d523ce/
  19. 19. Graphic by Michael Hönnig http://michael.hoennig.de/2009/08/08/clean-code-developer-ccd/
  20. 20. Keep it simple, stupid (KISS)
  21. 21. Graphic by Nathan Sawaya courtesy of brickartist.com
  22. 22. Don’t repeat yourself (DRY)
  23. 23. Separation of Concerns (SoC)Single Responsibility Principle (SRP)
  24. 24. Component-Oriented Programming (CoP)
  25. 25. Dependency Inversion Principle (DIP)
  26. 26. S Single Responsibility Principle O Open/Closed Principle L Liskov Substitution Principle I Interface Segregation Principle D Dependency Inversion PrincipleRobert C Martin: http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod
  27. 27. Source Code Conventions
  28. 28. Let’s switch to the code
  29. 29. Summary Clean CodeBeing more efficient through:• Simplification and Specialization (KISS, SoC, SRP)• Decoupling (Contracts, CoP, IoC or SOA)• Avoiding Code Blow (DRY, YAGNI)• Quality through Testability (all of them!)
  30. 30. Q&AGraphic by Nathan Sawaya courtesy of brickartist.com
  31. 31. ReferencesResharperhttp://www.jetbrains.com/resharper/FxCop / Code Analysishttp://msdn.microsoft.com/en-us/library/bb429476(VS.80).aspxhttp://blogs.msdn.com/b/codeanalysis/http://www.binarycoder.net/fxcop/index.htmlCode Contractshttp://msdn.microsoft.com/en-us/devlabs/dd491992http://research.microsoft.com/en-us/projects/contracts/Pex & Molehttp://research.microsoft.com/en-us/projects/pex/StyleCophttp://stylecop.codeplex.com/StyleCop Plugin for Resharperhttp://stylecopforresharper.codeplex.com/Ghostdochttp://submain.com/products/ghostdoc.aspx Lego (trademarked in capitals as LEGO)
  32. 32. gotowww.csharp-lighthouse.com for slides & code examples
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×