SlideShare a Scribd company logo
1 of 37
SolCal
                 CodeCamp


Clean Code III
      Software
   Craftsmanship
    San Diego, June 24rd 2012
Theo Jungeblut
• Senior Software Developer at
  AppDynamics in San Francisco
• architects decoupled solutions
  tailored to business needs and crafts
  maintainable code to last
• worked in healthcare and factory
  automation, building mission critical
  applications, framework &
  platforms for 8+ years
• degree in Software Engineering
  and Network Communications              theo@designitright.net
• enjoys cycling, running and eating      www.designitright.net
                                          www.speakerrate.com/theoj
Overview
•   Why Clean Code?
•   The Power of Simplicity
•   Tools - Your Best Friend
•   From Names to Classes
•   The "Must Read"-Books
•   Summary
•   Q&A
Does writing Clean Code
make us more efficient?
What is Clean Code?
Clean Code is maintainable

     Source code must be:
     • readable & well structured
     • extensible
     • testable
Software
 Engineering
      vs.
Craftsmanship
Software
 Engineering
     AND
Craftsmanship
The “Must Read”-Book(s)
 by Robert C Martin


A Handbook of Agile
Software
Craftsmanship

“Even bad code can
function. But if code
isn’t clean, it can bring a
development
organization to its
knees.”
Code Maintainability *
    Principles                   Patterns                   Containers


       Why?                        How?                        What?


  Extensibility                Clean Code                   Tool reuse

* from: Mark Seemann’s “Dependency Injection in .NET” presentation Bay.NET 05/2011
Keep it simple, stupid
        (KISS)
KISS-Principle – “Keep It Simple Stupid”
   by Kelly Johnson




                      http://blogs.smarter.com/blogs/Lego%20Brick.jpg
The Power of Simplicity




                                                       Graphic by Nathan Sawaya courtesy of brickartist.com




Graphic by Nathan Sawaya courtesy of brickartist.com

                                                                                http://www.geekalerts.com/lego-iphone/
Graphic by Nathan Sawaya courtesy of brickartist.com
Source Code Conventions
.NET Tools and their Impact
Tool name        Positive Impact           Negative Impact
Resharper        compiling ++++            VS responsiveness --
FxCop            code quality ++           compiling time -
StyleCop         code consistency +++      compiling time -
StyleCop plugin compiling time +++         VS responsiveness --
for Resharper
Ghost Doc        automated docs            potentially worse doc
Spell Checker    fewer spelling errors ++ performance --
Code Contracts   testability, quality ++   compiling time --
Pex & Moles      automated test ++         compiling time --
Resharper
“The single most impacting development
        addition to Visual Studio”
     Features:
       –   Code Analysis
       –   Quick Fixes
       –   Code Templates
       –   Code Generation
       –   Code Cleanup
       –   Many, many more…
                              http://www.jetbrains.com/resharper/
FxCop / Static Code Analysis
  Code Analysis:
    – Correctness
    – Library design
    – Internationalization and localization
    – Naming conventions
    – Performance
    – Security


              http://msdn.microsoft.com/en-us/library/3z0aeatx.aspx
Style Cop with R# Integration
   Code Consistency & Readability:
     – Automated check of C# coding
       standard
     – Enforceable at check-in with TFS
       check-in Policy

     – Full Integration in Resharper with
       Style Cop plugin:
     – Code Analysis
     – Quick Fixes
     – Code Cleanup
Ghost Doc

• Save keystrokes and time
• Simplify documenting your code
• Benefit of the base class documentation




          http://submain.com/products/ghostdoc.aspx
Spell Checker

  • Spelll chicking for literals and comments in VS




http://visualstudiogallery.msdn.microsoft.com/7c8341f1-ebac-40c8-92c2-476db8d523ce/
•   Design-by-Contract programming
•   Improved testability
•   Static verification
•   API documentation integration with
    Sandcastle
    http://msdn.microsoft.com/en-us/devlabs/dd491992
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/
Names Matter
    •   Meaningful Names
    •   Intention Revealing Names
    •   Use Pronounceable Names
    •   Use Searchable Names
    •   Avoid Encoding (Hungarian)
    •   Don’t be cute
    •   Pick One Word per Concept
    •   Use Problem Domain Names
* Chapter extract: Robert C. Martin –” Clean Code”, Parson Education, Inc. 2008
Functions
     • Small – Do One Thing
     • One Level of Abstraction
     • No or only few Arguments
     • Have No Side Effects
     • Prefer Exceptions to
       Returning Error Codes
     • Don’t Repeat Yourself

* Chapter extract: Robert C. Martin –” Clean Code”, Parson Education, Inc. 2008
Comments
     •   Comments o not Make Up for Bad Code
     •   Explain Yourself in Code
     •   Clarification
     •   Warning of Consequences
     •   ToDo Comments
     •   Javadocs in Public APIs



* Chapter extract: Robert C. Martin –” Clean Code”, Parson Education, Inc. 2008
Bad Comments
     • Mumblings
     • Redundant Comments
     • Misleading Comments
     • Journal Comments
     • Noise Comments
     • Don’t use a Comment When you Use a
       Method or a Variable
     • Commented-Out Code

* Chapter extract: Robert C. Martin –” Clean Code”, Parson Education, Inc. 2008
The Purpose of Formatting
        •   Team Rules – Consistency is King
        •   Vertical Openness Between Concepts
        •   Vertical Distance
        •   Horizontal Alignment
        •   Indentation
        •   Write Journey Style Code

         Resharper & StyleCop – “Code Cleanup”
* Kind of Chapter extract: Robert C. Martin –” Clean Code”, Parson Education, Inc. 2008
Classes
        •   Class Organization
        •   Encapsulation
        •   Classes Should be Small
        •   The Single Responsibility Principle
        •   Cohesion
        •   Organize for Change
        •   Insolating from Change


* Kind of Chapter extract: Robert C. Martin –” Clean Code”, Parson Education, Inc. 2008
The “Must Read”-Book(s)
 by Robert C Martin


A Handbook of Agile
Software
Craftsmanship

“Even bad code can
function. But if code
isn’t clean, it can bring a
development
organization to its
knees.”
TheKrzysztof Cwalina,Read”-Book(s)
  by
     “Must Brad Abrams
Framework Design
Guidelines

“teaches
developers the
best practices for
designing reusable
libraries for the
Microsoft .NET
Framework.”
Summary Clean Code
Maintainability is achieved through:
• Readability (Coding Guidelines)
• Simplification and Specialization
  (KISS, SoC, SRP, OCP, )
• Decoupling (LSP, DIP, IHP, Contracts,
  LoD, CoP, IoC or SOA)
• Avoiding Code Bloat (DRY, YAGNI)
• Quality through Testability
  (all of them!)
Q&A
                                         Downloads,
                                         Feedback & Comments:
                                                   theo@designitright.net
                                                   www.designitright.net
                                                   www.speakerrate.com/theoj
Graphic by Nathan Sawaya courtesy of brickartist.com
http://clean-code-developer.com
                                          References…
http://michael.hoennig.de/2009/08/08/clean-code-developer-ccd/
http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod
http://www.manning.com/seemann/
http://en.wikipedia.org/wiki/Keep_it_simple_stupid
http://picocontainer.org/patterns.html
http://en.wikipedia.org/wiki/Separation_of_concerns
http://en.wikipedia.org/wiki/Single_responsibility_principle
http://en.wikipedia.org/wiki/Information_hiding
http://en.wikipedia.org/wiki/Liskov_substitution_principle
http://en.wikipedia.org/wiki/Dependency_inversion_principle
http://en.wikipedia.org/wiki/Open/closed_principle
http://en.wikipedia.org/wiki/Law_Of_Demeter
http://en.wikipedia.org/wiki/Don't_repeat_yourself
http://en.wikipedia.org/wiki/You_ain't_gonna_need_it
http://en.wikipedia.org/wiki/Component-oriented_programming
http://en.wikipedia.org/wiki/Service-oriented_architecture
http://www.martinfowler.com/articles/injection.html
http://www.codeproject.com/KB/aspnet/IOCDI.aspx
http://msdn.microsoft.com/en-us/magazine/cc163739.aspx
http://msdn.microsoft.com/en-us/library/ff650320.aspx
http://msdn.microsoft.com/en-us/library/aa973811.aspx
http://msdn.microsoft.com/en-us/library/ff647976.aspx
http://msdn.microsoft.com/en-us/library/cc707845.aspx
http://msdn.microsoft.com/en-us/library/bb833022.aspx
http://unity.codeplex.com/
http://www.idesign.net/idesign/DesktopDefault.aspx?tabindex=5&tabid=11
… more References
Resharper
http://www.jetbrains.com/resharper/

FxCop / Code Analysis
http://msdn.microsoft.com/en-us/library/bb429476(VS.80).aspx
http://blogs.msdn.com/b/codeanalysis/
http://www.binarycoder.net/fxcop/index.html

Code Contracts
http://msdn.microsoft.com/en-us/devlabs/dd491992
http://research.microsoft.com/en-us/projects/contracts/

Pex & Mole
http://research.microsoft.com/en-us/projects/pex/

StyleCop
http://stylecop.codeplex.com/

Ghostdoc
http://submain.com/products/ghostdoc.aspx

Spellchecker
http://visualstudiogallery.msdn.microsoft.com/
7c8341f1-ebac-40c8-92c2-476db8d523ce//
                                                               Lego (trademarked in capitals as LEGO)
Please fill out the
feedback, and…
                          www.speakerrate.com/theoj




… thanks for you attention!
            And visit and support the

                      www.sandiegodotnet.com

More Related Content

What's hot

Clean Code - Design Patterns and Best Practices at Silicon Valley Code Camp
Clean Code - Design Patterns and Best Practices at Silicon Valley Code CampClean Code - Design Patterns and Best Practices at Silicon Valley Code Camp
Clean Code - Design Patterns and Best Practices at Silicon Valley Code CampTheo Jungeblut
 
Clean Code I - Best Practices
Clean Code I - Best PracticesClean Code I - Best Practices
Clean Code I - Best PracticesTheo Jungeblut
 
Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...
Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...
Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...Theo Jungeblut
 
Contract First Development with Microsoft Code Contracts and Microsoft Pex at...
Contract First Development with Microsoft Code Contracts and Microsoft Pex at...Contract First Development with Microsoft Code Contracts and Microsoft Pex at...
Contract First Development with Microsoft Code Contracts and Microsoft Pex at...Theo Jungeblut
 
Cut your Dependencies with - Dependency Injection for South Bay.NET User Grou...
Cut your Dependencies with - Dependency Injection for South Bay.NET User Grou...Cut your Dependencies with - Dependency Injection for South Bay.NET User Grou...
Cut your Dependencies with - Dependency Injection for South Bay.NET User Grou...Theo Jungeblut
 
Lego For Engineers - Dependency Injection for LIDNUG (2011-06-03)
Lego For Engineers - Dependency Injection for LIDNUG (2011-06-03)Lego For Engineers - Dependency Injection for LIDNUG (2011-06-03)
Lego For Engineers - Dependency Injection for LIDNUG (2011-06-03)Theo Jungeblut
 
Mental models, complexity and software
Mental models, complexity and softwareMental models, complexity and software
Mental models, complexity and softwareArturo Herrero
 
Clean Code III - Software Craftsmanship
Clean Code III - Software CraftsmanshipClean Code III - Software Craftsmanship
Clean Code III - Software CraftsmanshipTheo Jungeblut
 
Lego for Software Engineers at Silicon Valley Code Camp 2011 (2010-10-10)
Lego for Software Engineers at Silicon Valley Code Camp 2011 (2010-10-10)Lego for Software Engineers at Silicon Valley Code Camp 2011 (2010-10-10)
Lego for Software Engineers at Silicon Valley Code Camp 2011 (2010-10-10)Theo Jungeblut
 
Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Gianluca Padovani
 
Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Gianluca Padovani
 
Clean code & design patterns
Clean code & design patternsClean code & design patterns
Clean code & design patternsPascal Larocque
 
WordCamp US: Clean Code
WordCamp US: Clean CodeWordCamp US: Clean Code
WordCamp US: Clean Codemtoppa
 
Cut your Dependencies with Dependency Injection - .NET User Group Osnabrueck
Cut your Dependencies with Dependency Injection - .NET User Group OsnabrueckCut your Dependencies with Dependency Injection - .NET User Group Osnabrueck
Cut your Dependencies with Dependency Injection - .NET User Group OsnabrueckTheo Jungeblut
 
Functional Dependency Injection in C#
Functional Dependency Injection in C#Functional Dependency Injection in C#
Functional Dependency Injection in C#Thomas Jaskula
 
Cut your Dependencies - Dependency Injection at Silicon Valley Code Camp
Cut your Dependencies - Dependency Injection at Silicon Valley Code CampCut your Dependencies - Dependency Injection at Silicon Valley Code Camp
Cut your Dependencies - Dependency Injection at Silicon Valley Code CampTheo Jungeblut
 

What's hot (20)

Clean Code - Design Patterns and Best Practices at Silicon Valley Code Camp
Clean Code - Design Patterns and Best Practices at Silicon Valley Code CampClean Code - Design Patterns and Best Practices at Silicon Valley Code Camp
Clean Code - Design Patterns and Best Practices at Silicon Valley Code Camp
 
Clean Code I - Best Practices
Clean Code I - Best PracticesClean Code I - Best Practices
Clean Code I - Best Practices
 
Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...
Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...
Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...
 
Contract First Development with Microsoft Code Contracts and Microsoft Pex at...
Contract First Development with Microsoft Code Contracts and Microsoft Pex at...Contract First Development with Microsoft Code Contracts and Microsoft Pex at...
Contract First Development with Microsoft Code Contracts and Microsoft Pex at...
 
Cut your Dependencies with - Dependency Injection for South Bay.NET User Grou...
Cut your Dependencies with - Dependency Injection for South Bay.NET User Grou...Cut your Dependencies with - Dependency Injection for South Bay.NET User Grou...
Cut your Dependencies with - Dependency Injection for South Bay.NET User Grou...
 
Clean code
Clean codeClean code
Clean code
 
Lego For Engineers - Dependency Injection for LIDNUG (2011-06-03)
Lego For Engineers - Dependency Injection for LIDNUG (2011-06-03)Lego For Engineers - Dependency Injection for LIDNUG (2011-06-03)
Lego For Engineers - Dependency Injection for LIDNUG (2011-06-03)
 
Clean Code 2
Clean Code 2Clean Code 2
Clean Code 2
 
Mental models, complexity and software
Mental models, complexity and softwareMental models, complexity and software
Mental models, complexity and software
 
Clean Code III - Software Craftsmanship
Clean Code III - Software CraftsmanshipClean Code III - Software Craftsmanship
Clean Code III - Software Craftsmanship
 
Lego for Software Engineers at Silicon Valley Code Camp 2011 (2010-10-10)
Lego for Software Engineers at Silicon Valley Code Camp 2011 (2010-10-10)Lego for Software Engineers at Silicon Valley Code Camp 2011 (2010-10-10)
Lego for Software Engineers at Silicon Valley Code Camp 2011 (2010-10-10)
 
Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)
 
Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Tdd is not about testing (OOP)
Tdd is not about testing (OOP)
 
Clean code & design patterns
Clean code & design patternsClean code & design patterns
Clean code & design patterns
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
WordCamp US: Clean Code
WordCamp US: Clean CodeWordCamp US: Clean Code
WordCamp US: Clean Code
 
Cut your Dependencies with Dependency Injection - .NET User Group Osnabrueck
Cut your Dependencies with Dependency Injection - .NET User Group OsnabrueckCut your Dependencies with Dependency Injection - .NET User Group Osnabrueck
Cut your Dependencies with Dependency Injection - .NET User Group Osnabrueck
 
Functional Dependency Injection in C#
Functional Dependency Injection in C#Functional Dependency Injection in C#
Functional Dependency Injection in C#
 
Cut your Dependencies - Dependency Injection at Silicon Valley Code Camp
Cut your Dependencies - Dependency Injection at Silicon Valley Code CampCut your Dependencies - Dependency Injection at Silicon Valley Code Camp
Cut your Dependencies - Dependency Injection at Silicon Valley Code Camp
 
SOLID design principles applied in Java
SOLID design principles applied in JavaSOLID design principles applied in Java
SOLID design principles applied in Java
 

Similar to Clean Code Part III - Craftsmanship at SoCal Code Camp

Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...Theo Jungeblut
 
It is a sunny day
It is a sunny dayIt is a sunny day
It is a sunny daybcoder
 
Friday final test
Friday final testFriday final test
Friday final testbcoder
 
Clean Infrastructure as Code
Clean Infrastructure as Code Clean Infrastructure as Code
Clean Infrastructure as Code QAware GmbH
 
Kiss.ts - The Keep It Simple Software Stack for 2017++
Kiss.ts - The Keep It Simple Software Stack for 2017++Kiss.ts - The Keep It Simple Software Stack for 2017++
Kiss.ts - The Keep It Simple Software Stack for 2017++Ethan Ram
 
Taming Big Balls of Mud with Diligence, Agile Practices, and Hard Work
Taming Big Balls of Mud with Diligence, Agile Practices, and Hard WorkTaming Big Balls of Mud with Diligence, Agile Practices, and Hard Work
Taming Big Balls of Mud with Diligence, Agile Practices, and Hard WorkJoseph Yoder
 
Philly CocoaHeads 20160414 - Building Your App SDK With Swift
Philly CocoaHeads 20160414 - Building Your App SDK With SwiftPhilly CocoaHeads 20160414 - Building Your App SDK With Swift
Philly CocoaHeads 20160414 - Building Your App SDK With SwiftJordan Yaker
 
Enterprise Node - Code Quality
Enterprise Node - Code QualityEnterprise Node - Code Quality
Enterprise Node - Code QualityKurtis Kemple
 
Slides for Houston iPhone Developers' Meetup (April 2012)
Slides for Houston iPhone Developers' Meetup (April 2012)Slides for Houston iPhone Developers' Meetup (April 2012)
Slides for Houston iPhone Developers' Meetup (April 2012)lqi
 
Coding Standard And Code Review
Coding Standard And Code ReviewCoding Standard And Code Review
Coding Standard And Code ReviewMilan Vukoje
 
Old code doesn't stink - Detroit
Old code doesn't stink - DetroitOld code doesn't stink - Detroit
Old code doesn't stink - DetroitMartin Gutenbrunner
 
Developer Job in Practice
Developer Job in PracticeDeveloper Job in Practice
Developer Job in Practiceintive
 
Software Architecture Erosion and Modernization
Software Architecture Erosion and ModernizationSoftware Architecture Erosion and Modernization
Software Architecture Erosion and Modernizationbmerkle
 
10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware ProgrammingPostSharp Technologies
 
Enhance Your Code Quality with Code Contracts
Enhance Your Code Quality with Code ContractsEnhance Your Code Quality with Code Contracts
Enhance Your Code Quality with Code ContractsEran Stiller
 
Clean Infrastructure as Code
Clean Infrastructure as CodeClean Infrastructure as Code
Clean Infrastructure as CodeQAware GmbH
 
Letter to a Junior Developer: The Engineering Side of Programming
Letter to a Junior Developer: The Engineering Side of ProgrammingLetter to a Junior Developer: The Engineering Side of Programming
Letter to a Junior Developer: The Engineering Side of ProgrammingLazar Kovacevic
 
Writing Code for Humans, not Computers
Writing Code for Humans, not ComputersWriting Code for Humans, not Computers
Writing Code for Humans, not ComputersRené Cacheaux
 
NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET Dmytro Mindra
 

Similar to Clean Code Part III - Craftsmanship at SoCal Code Camp (20)

Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...
 
It is a sunny day
It is a sunny dayIt is a sunny day
It is a sunny day
 
Friday final test
Friday final testFriday final test
Friday final test
 
Clean Infrastructure as Code
Clean Infrastructure as Code Clean Infrastructure as Code
Clean Infrastructure as Code
 
Kiss.ts - The Keep It Simple Software Stack for 2017++
Kiss.ts - The Keep It Simple Software Stack for 2017++Kiss.ts - The Keep It Simple Software Stack for 2017++
Kiss.ts - The Keep It Simple Software Stack for 2017++
 
Taming Big Balls of Mud with Diligence, Agile Practices, and Hard Work
Taming Big Balls of Mud with Diligence, Agile Practices, and Hard WorkTaming Big Balls of Mud with Diligence, Agile Practices, and Hard Work
Taming Big Balls of Mud with Diligence, Agile Practices, and Hard Work
 
Philly CocoaHeads 20160414 - Building Your App SDK With Swift
Philly CocoaHeads 20160414 - Building Your App SDK With SwiftPhilly CocoaHeads 20160414 - Building Your App SDK With Swift
Philly CocoaHeads 20160414 - Building Your App SDK With Swift
 
Enterprise Node - Code Quality
Enterprise Node - Code QualityEnterprise Node - Code Quality
Enterprise Node - Code Quality
 
Slides for Houston iPhone Developers' Meetup (April 2012)
Slides for Houston iPhone Developers' Meetup (April 2012)Slides for Houston iPhone Developers' Meetup (April 2012)
Slides for Houston iPhone Developers' Meetup (April 2012)
 
Coding Standard And Code Review
Coding Standard And Code ReviewCoding Standard And Code Review
Coding Standard And Code Review
 
Code Inspection
Code InspectionCode Inspection
Code Inspection
 
Old code doesn't stink - Detroit
Old code doesn't stink - DetroitOld code doesn't stink - Detroit
Old code doesn't stink - Detroit
 
Developer Job in Practice
Developer Job in PracticeDeveloper Job in Practice
Developer Job in Practice
 
Software Architecture Erosion and Modernization
Software Architecture Erosion and ModernizationSoftware Architecture Erosion and Modernization
Software Architecture Erosion and Modernization
 
10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming
 
Enhance Your Code Quality with Code Contracts
Enhance Your Code Quality with Code ContractsEnhance Your Code Quality with Code Contracts
Enhance Your Code Quality with Code Contracts
 
Clean Infrastructure as Code
Clean Infrastructure as CodeClean Infrastructure as Code
Clean Infrastructure as Code
 
Letter to a Junior Developer: The Engineering Side of Programming
Letter to a Junior Developer: The Engineering Side of ProgrammingLetter to a Junior Developer: The Engineering Side of Programming
Letter to a Junior Developer: The Engineering Side of Programming
 
Writing Code for Humans, not Computers
Writing Code for Humans, not ComputersWriting Code for Humans, not Computers
Writing Code for Humans, not Computers
 
NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET
 

Recently uploaded

Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 

Recently uploaded (20)

Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 

Clean Code Part III - Craftsmanship at SoCal Code Camp

  • 1. SolCal CodeCamp Clean Code III Software Craftsmanship San Diego, June 24rd 2012
  • 2. Theo Jungeblut • Senior Software Developer at AppDynamics in San Francisco • architects decoupled solutions tailored to business needs and crafts maintainable code to last • worked in healthcare and factory automation, building mission critical applications, framework & platforms for 8+ years • degree in Software Engineering and Network Communications theo@designitright.net • enjoys cycling, running and eating www.designitright.net www.speakerrate.com/theoj
  • 3. Overview • Why Clean Code? • The Power of Simplicity • Tools - Your Best Friend • From Names to Classes • The "Must Read"-Books • Summary • Q&A
  • 4. Does writing Clean Code make us more efficient?
  • 5.
  • 7. Clean Code is maintainable Source code must be: • readable & well structured • extensible • testable
  • 8. Software Engineering vs. Craftsmanship
  • 9. Software Engineering AND Craftsmanship
  • 10. The “Must Read”-Book(s) by Robert C Martin A Handbook of Agile Software Craftsmanship “Even bad code can function. But if code isn’t clean, it can bring a development organization to its knees.”
  • 11. Code Maintainability * Principles Patterns Containers Why? How? What? Extensibility Clean Code Tool reuse * from: Mark Seemann’s “Dependency Injection in .NET” presentation Bay.NET 05/2011
  • 12. Keep it simple, stupid (KISS)
  • 13. KISS-Principle – “Keep It Simple Stupid” by Kelly Johnson http://blogs.smarter.com/blogs/Lego%20Brick.jpg
  • 14. The Power of Simplicity Graphic by Nathan Sawaya courtesy of brickartist.com Graphic by Nathan Sawaya courtesy of brickartist.com http://www.geekalerts.com/lego-iphone/
  • 15. Graphic by Nathan Sawaya courtesy of brickartist.com
  • 17. .NET Tools and their Impact Tool name Positive Impact Negative Impact Resharper compiling ++++ VS responsiveness -- FxCop code quality ++ compiling time - StyleCop code consistency +++ compiling time - StyleCop plugin compiling time +++ VS responsiveness -- for Resharper Ghost Doc automated docs potentially worse doc Spell Checker fewer spelling errors ++ performance -- Code Contracts testability, quality ++ compiling time -- Pex & Moles automated test ++ compiling time --
  • 18. Resharper “The single most impacting development addition to Visual Studio” Features: – Code Analysis – Quick Fixes – Code Templates – Code Generation – Code Cleanup – Many, many more… http://www.jetbrains.com/resharper/
  • 19. FxCop / Static Code Analysis Code Analysis: – Correctness – Library design – Internationalization and localization – Naming conventions – Performance – Security http://msdn.microsoft.com/en-us/library/3z0aeatx.aspx
  • 20. Style Cop with R# Integration Code Consistency & Readability: – Automated check of C# coding standard – Enforceable at check-in with TFS check-in Policy – Full Integration in Resharper with Style Cop plugin: – Code Analysis – Quick Fixes – Code Cleanup
  • 21. Ghost Doc • Save keystrokes and time • Simplify documenting your code • Benefit of the base class documentation http://submain.com/products/ghostdoc.aspx
  • 22. Spell Checker • Spelll chicking for literals and comments in VS http://visualstudiogallery.msdn.microsoft.com/7c8341f1-ebac-40c8-92c2-476db8d523ce/
  • 23. Design-by-Contract programming • Improved testability • Static verification • API documentation integration with Sandcastle http://msdn.microsoft.com/en-us/devlabs/dd491992
  • 24. 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/
  • 25. Names Matter • Meaningful Names • Intention Revealing Names • Use Pronounceable Names • Use Searchable Names • Avoid Encoding (Hungarian) • Don’t be cute • Pick One Word per Concept • Use Problem Domain Names * Chapter extract: Robert C. Martin –” Clean Code”, Parson Education, Inc. 2008
  • 26. Functions • Small – Do One Thing • One Level of Abstraction • No or only few Arguments • Have No Side Effects • Prefer Exceptions to Returning Error Codes • Don’t Repeat Yourself * Chapter extract: Robert C. Martin –” Clean Code”, Parson Education, Inc. 2008
  • 27. Comments • Comments o not Make Up for Bad Code • Explain Yourself in Code • Clarification • Warning of Consequences • ToDo Comments • Javadocs in Public APIs * Chapter extract: Robert C. Martin –” Clean Code”, Parson Education, Inc. 2008
  • 28. Bad Comments • Mumblings • Redundant Comments • Misleading Comments • Journal Comments • Noise Comments • Don’t use a Comment When you Use a Method or a Variable • Commented-Out Code * Chapter extract: Robert C. Martin –” Clean Code”, Parson Education, Inc. 2008
  • 29. The Purpose of Formatting • Team Rules – Consistency is King • Vertical Openness Between Concepts • Vertical Distance • Horizontal Alignment • Indentation • Write Journey Style Code  Resharper & StyleCop – “Code Cleanup” * Kind of Chapter extract: Robert C. Martin –” Clean Code”, Parson Education, Inc. 2008
  • 30. Classes • Class Organization • Encapsulation • Classes Should be Small • The Single Responsibility Principle • Cohesion • Organize for Change • Insolating from Change * Kind of Chapter extract: Robert C. Martin –” Clean Code”, Parson Education, Inc. 2008
  • 31. The “Must Read”-Book(s) by Robert C Martin A Handbook of Agile Software Craftsmanship “Even bad code can function. But if code isn’t clean, it can bring a development organization to its knees.”
  • 32. TheKrzysztof Cwalina,Read”-Book(s) by “Must Brad Abrams Framework Design Guidelines “teaches developers the best practices for designing reusable libraries for the Microsoft .NET Framework.”
  • 33. Summary Clean Code Maintainability is achieved through: • Readability (Coding Guidelines) • Simplification and Specialization (KISS, SoC, SRP, OCP, ) • Decoupling (LSP, DIP, IHP, Contracts, LoD, CoP, IoC or SOA) • Avoiding Code Bloat (DRY, YAGNI) • Quality through Testability (all of them!)
  • 34. Q&A Downloads, Feedback & Comments: theo@designitright.net www.designitright.net www.speakerrate.com/theoj Graphic by Nathan Sawaya courtesy of brickartist.com
  • 35. http://clean-code-developer.com References… http://michael.hoennig.de/2009/08/08/clean-code-developer-ccd/ http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod http://www.manning.com/seemann/ http://en.wikipedia.org/wiki/Keep_it_simple_stupid http://picocontainer.org/patterns.html http://en.wikipedia.org/wiki/Separation_of_concerns http://en.wikipedia.org/wiki/Single_responsibility_principle http://en.wikipedia.org/wiki/Information_hiding http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Dependency_inversion_principle http://en.wikipedia.org/wiki/Open/closed_principle http://en.wikipedia.org/wiki/Law_Of_Demeter http://en.wikipedia.org/wiki/Don't_repeat_yourself http://en.wikipedia.org/wiki/You_ain't_gonna_need_it http://en.wikipedia.org/wiki/Component-oriented_programming http://en.wikipedia.org/wiki/Service-oriented_architecture http://www.martinfowler.com/articles/injection.html http://www.codeproject.com/KB/aspnet/IOCDI.aspx http://msdn.microsoft.com/en-us/magazine/cc163739.aspx http://msdn.microsoft.com/en-us/library/ff650320.aspx http://msdn.microsoft.com/en-us/library/aa973811.aspx http://msdn.microsoft.com/en-us/library/ff647976.aspx http://msdn.microsoft.com/en-us/library/cc707845.aspx http://msdn.microsoft.com/en-us/library/bb833022.aspx http://unity.codeplex.com/ http://www.idesign.net/idesign/DesktopDefault.aspx?tabindex=5&tabid=11
  • 36. … more References Resharper http://www.jetbrains.com/resharper/ FxCop / Code Analysis http://msdn.microsoft.com/en-us/library/bb429476(VS.80).aspx http://blogs.msdn.com/b/codeanalysis/ http://www.binarycoder.net/fxcop/index.html Code Contracts http://msdn.microsoft.com/en-us/devlabs/dd491992 http://research.microsoft.com/en-us/projects/contracts/ Pex & Mole http://research.microsoft.com/en-us/projects/pex/ StyleCop http://stylecop.codeplex.com/ Ghostdoc http://submain.com/products/ghostdoc.aspx Spellchecker http://visualstudiogallery.msdn.microsoft.com/ 7c8341f1-ebac-40c8-92c2-476db8d523ce// Lego (trademarked in capitals as LEGO)
  • 37. Please fill out the feedback, and… www.speakerrate.com/theoj … thanks for you attention! And visit and support the www.sandiegodotnet.com