object calisthenics; practices for writing object-oriented c#
DESCRIPTION
According to Wikipedia, Calisthenics are a form of exercise consisting of a variety of simple, often rhythmical, movements, generally without using equipment or apparatus. Since programming without Visual Studio is going to be a bit challenging you can define Object Calisthenics as a programming exercise that uses simple rules to motivate you to take an object-oriented approach to programming. As an experienced developer practicing Test Driven Development I was a bit sceptical of whether I really needed those rules to be a better programmer. But to my surprise those little rules really reinforced my beliefs about building high-quality software using the principles of object-orientation, SOLID and Clean Code. So what are those rules? I won’t tell you…yet. Just come to my session and I’ll let you in on my secrets….TRANSCRIPT
#comdaybe
Object CalisthenicsPractices for Writing Object-Oriented
Aviva SolutionsDennis Doomen
Object…what?
Object Calisthenics
Object..\ˌka-ləs-ˈthe-niks\
Like this?
“…9 rules of thumb that will help push your code into good object-oriented shape...”Jeff Bay
So who am I?
Principal ConsultantAviva Solutions
Fluent Assertions
C# Coding Guidelines
@ddoomen
TDD, DDD, BDD
Application Lifecycle Management
Agile
XP
www.dennisdoomen.net
demo
One level of indentation per methodRule 1
demo
One dot per lineDon’t use the else keyword
Rules 2 & 5
demo
Wrap all primitives and strings…a.k.a. first-class types
Rule 3
demo
First-class collectionsRule 4
Choose names carefully…not too short
…and…not too long…contextual
Rule 6
Keep all classes small…a.k.a. Single Responsibility
Principle
Rule 7
No more than two instance variablesRule 8
demo
No propertiesRule 9
demo
…no protected properties…test data builders…more refactoring
Final result
Q&A
Resources
• Example Code (original by Johan Martinsson)
• Object Calisthenics (by Jeff Bay)• C# Coding Guidelines (by me)• www.dennisdoomen.net (by me…
again )• Agile Principles, Patterns, and Practic
es in C# (by Uncle Bob)
Thank you!Object Calisthenatics