You will learn why naming is really difficult if done right, why coding and style guidelines are crucial, code structuring, exception handling and why other elements of coding often define the tipping point between success and failure of projects. Following the principles of software craftsmanship will allow you to end up with better maintainability and extensibility of your software and the success of the project in the end. All 3 Clean Code presentations provide great value by themselves, but taken together are designed to offer a holistic approach to successful software creation.
Why writing Clean Code makes us more efficient Over the lifetime of a product, maintaining the product is actually one - if not the most - expensive area(s) of the overall product costs. Writing clean code can significantly lower these costs. However, writing clean code also makes you more efficient during the initial development time and results in more stable code. You will be presented design patterns and best practices which will make you write better and more easily maintainable code, seeing code in a holistic way. You will learn how to apply them by using an existing implementation as the starting point of the presentation. Finally, patterns & practices benefits are explained.
This presentation is based on C# and Visual Studio 2012. However, the demonstrated patterns and practice can be applied to every other programming language too.
2. Theo Jungeblut
• Engineering manager & lead by day
at AppDynamics in San Francisco
• Coder & software craftsman by night
• Architects decoupled solutions
tailored to business needs & crafts
maintainable code to last
• Worked in healthcare and factory
automation, building mission critical
applications, framework & platforms
• Degree in Software Engineering
and Network Communications
• Enjoys cycling, running and eating
theo@designitright.net
www.designitright.net
3. Overview
• Why Clean Code?
• The Power of Simplicity
• Tools - Your Best Friend
• From Names to Classes
• The "Must Read"-Books
• Summary
• Q&A
9. 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.”
12. KISS-Principle – “Keep It Simple Stupid”
http://blogs.smarter.com/blogs/Lego%20Brick.jpg
by Kelly Johnson
13. The Power of Simplicity
http://www.geekalerts.com/lego-iphone/
Graphic by Nathan Sawaya courtesy of brickartist.com
Graphic by Nathan Sawaya courtesy of brickartist.com
23. • Pex automatically generates test suites with
high code coverage.
• Moles allows to replace any .NET method with
a delegate.
Microsoft Pex & Moles
http://research.microsoft.com/en-us/projects/pex/
24. 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
25. 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
26. Comments
• Comments do 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
27. 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
28. 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
29. 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
30. 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.”
31. The “Must Read”-Book(s)by Krzysztof Cwalina, Brad Abrams
Framework Design
Guidelines
“teaches
developers the
best practices for
designing reusable
libraries for the
Microsoft .NET
Framework.”
32. 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!)
33. Downloads,
Feedback & Comments:
Q & A
Graphic by Nathan Sawaya courtesy of brickartist.com
theo@designitright.net
www.designitright.net
www.speakerrate.com/theoj