SlideShare une entreprise Scribd logo
1  sur  28
Télécharger pour lire hors ligne
Object
Calisthenics
#tac2018 @AgileTorinoConf
Ferdinando Santacroce
@jesuswasrasta
“
2
The word calisthenics comes from
the ancient Greek words kalòs
(καλός), beauty, and sthénos
(σθένος), strength.
@jesuswasrasta #tac2018
“
3
So, here’s an exercise that can help you to
internalize principles of good object-oriented
design and actually use them in real life.
Jeff Bay
@jesuswasrasta #tac2018
4
1. Only one level of indentation per method
@jesuswasrasta #tac2018
5
2. Don’t use ELSE keyword
@jesuswasrasta #tac2018
6
3. Wrap all primitives and strings
@jesuswasrasta #tac2018
7
4. First class collections (1)
@jesuswasrasta #tac2018
8
4. First class collections (2)
@jesuswasrasta #tac2018
9
5. One dot per line
@jesuswasrasta #tac2018
10
6. Don’t abbreviate
@jesuswasrasta #tac2018
11
7. Keep all entities small
@jesuswasrasta #tac2018
12
8. No classes with more than two instance variables
@jesuswasrasta #tac2018
13
9. No getters/setters/properties
@jesuswasrasta #tac2018
14
@jesuswasrasta #tac2018
Time to get stronger!
Setup
TicTacToe Kata
2 pomodoros
Pair programming
TDD
Debriefing, Q&A
15
@jesuswasrasta #tac2018
Board, Row, Circle, Cross?
Too many objects?
Did rules conflicted, sometimes?
Does it felt weird or uncomfortable, maybe?
Debriefing
16
E
n
c
a
p
s
u
l
a
t
i
o
n
17
P
o
l
i
m
o
r
p
h
i
s
m
18
N
a
m
i
n
g
19
1. Only one level of indentation per method
@jesuswasrasta #tac2018
Single Responsibility Principle (S.O.L.I.D.)
Extract method
Extract objects (collaborators)
20
2. Don’t use ELSE keyword
@jesuswasrasta #tac2018
Polymorphism
Behavioral Patterns
Strategy Pattern (set algorithm at runtime)
State Pattern (state machines)
21
3. Wrap all primitives and strings
@jesuswasrasta #tac2018
Primitive Obsession Anti-Pattern:
using primitives to represent domain ideas
22
4. First class collections
@jesuswasrasta #tac2018
Encapsulation:
Any class that contains a collection
should contain no other member variables
Give behaviors related to the collection a home
23
5. One dot per line
@jesuswasrasta #tac2018
Law of Demeter
Only talk with your immediate friends,
don’t talk to strangers
Fluent interfaces allowed
24
6. Don’t abbreviate
@jesuswasrasta #tac2018
Naming
“Clean Code” book, Robert C. Martin, Ch. 2
Meaningful, intention-revealing,
pronounceable, searchable names
Methos name too long?
Maybe it does too many things...
25
7. Keep all entities small
@jesuswasrasta #tac2018
Single Responsibility Principle (again...)
Class with 50 l.o.c, methods with 5
The “class that fits in the monitor” rule
There’s no black & white, it’s all about trade-offs
26
8. No classes with more than two instance variables
@jesuswasrasta #tac2018
High cohesion, low coupling
27
9. No getters/setters/properties
@jesuswasrasta #tac2018
Tell, don’t ask
Feature envy code-smell
(extensive use of another class)
They violates Open/Closed Principle (S.O.L.I.D.)
Anemic Domain anti-pattern
28
Thanks!
Any questions?
You can find me at:
▫ @jesuswasrasta
▫ http://about.me/ferdinando.santacroce

Contenu connexe

Tendances

Keeping Your Data Close and Your Caches Hotter (Ricardo Ferreira, Confluent) ...
Keeping Your Data Close and Your Caches Hotter (Ricardo Ferreira, Confluent) ...Keeping Your Data Close and Your Caches Hotter (Ricardo Ferreira, Confluent) ...
Keeping Your Data Close and Your Caches Hotter (Ricardo Ferreira, Confluent) ...
confluent
 

Tendances (20)

Conhecendo Apache Kafka
Conhecendo Apache KafkaConhecendo Apache Kafka
Conhecendo Apache Kafka
 
What you have to know about Certified Kubernetes Administrator (CKA)
What you have to know about Certified Kubernetes Administrator (CKA)What you have to know about Certified Kubernetes Administrator (CKA)
What you have to know about Certified Kubernetes Administrator (CKA)
 
Everything as Code with Terraform
Everything as Code with TerraformEverything as Code with Terraform
Everything as Code with Terraform
 
DevOps with Kubernetes
DevOps with KubernetesDevOps with Kubernetes
DevOps with Kubernetes
 
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
Developing event-driven microservices with event sourcing and CQRS  (svcc, sv...Developing event-driven microservices with event sourcing and CQRS  (svcc, sv...
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
 
Introduction to Testcontainers
Introduction to TestcontainersIntroduction to Testcontainers
Introduction to Testcontainers
 
Akka.net versus microsoft orleans
Akka.net versus microsoft orleansAkka.net versus microsoft orleans
Akka.net versus microsoft orleans
 
Crossplane @ Mastering GitOps.pdf
Crossplane @ Mastering GitOps.pdfCrossplane @ Mastering GitOps.pdf
Crossplane @ Mastering GitOps.pdf
 
Reactive programming with examples
Reactive programming with examplesReactive programming with examples
Reactive programming with examples
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Microservices Architecture - Bangkok 2018
Microservices Architecture - Bangkok 2018Microservices Architecture - Bangkok 2018
Microservices Architecture - Bangkok 2018
 
Keeping Your Data Close and Your Caches Hotter (Ricardo Ferreira, Confluent) ...
Keeping Your Data Close and Your Caches Hotter (Ricardo Ferreira, Confluent) ...Keeping Your Data Close and Your Caches Hotter (Ricardo Ferreira, Confluent) ...
Keeping Your Data Close and Your Caches Hotter (Ricardo Ferreira, Confluent) ...
 
Toi uu hoa he thong 30 trieu nguoi dung
Toi uu hoa he thong 30 trieu nguoi dungToi uu hoa he thong 30 trieu nguoi dung
Toi uu hoa he thong 30 trieu nguoi dung
 
Domain Driven Design (Ultra) Distilled
Domain Driven Design (Ultra) DistilledDomain Driven Design (Ultra) Distilled
Domain Driven Design (Ultra) Distilled
 
Building a Pyramid: Symfony Testing Strategies
Building a Pyramid: Symfony Testing StrategiesBuilding a Pyramid: Symfony Testing Strategies
Building a Pyramid: Symfony Testing Strategies
 
Effective terraform
Effective terraformEffective terraform
Effective terraform
 
Introduction to Apache Camel
Introduction to Apache CamelIntroduction to Apache Camel
Introduction to Apache Camel
 
Introduction to Kafka Cruise Control
Introduction to Kafka Cruise ControlIntroduction to Kafka Cruise Control
Introduction to Kafka Cruise Control
 
Hexagonal architecture with Spring Boot
Hexagonal architecture with Spring BootHexagonal architecture with Spring Boot
Hexagonal architecture with Spring Boot
 
Domain Driven Design 101
Domain Driven Design 101Domain Driven Design 101
Domain Driven Design 101
 

Plus de Ferdinando Santacroce

Plus de Ferdinando Santacroce (10)

Continuous Delivery
Continuous DeliveryContinuous Delivery
Continuous Delivery
 
Growing Teams - Agile Venture Milano - #avmi2020
Growing Teams - Agile Venture Milano - #avmi2020Growing Teams - Agile Venture Milano - #avmi2020
Growing Teams - Agile Venture Milano - #avmi2020
 
Testare l'intestabile - Italian Agile Days 2019 #IAD19
Testare l'intestabile - Italian Agile Days 2019 #IAD19Testare l'intestabile - Italian Agile Days 2019 #IAD19
Testare l'intestabile - Italian Agile Days 2019 #IAD19
 
I'm a mediocre developer
I'm a mediocre developerI'm a mediocre developer
I'm a mediocre developer
 
Working software
Working softwareWorking software
Working software
 
I'm a mediocre developer
I'm a mediocre developerI'm a mediocre developer
I'm a mediocre developer
 
Object Calisthenics - Agile Venture Prato 2018
Object Calisthenics - Agile Venture Prato 2018Object Calisthenics - Agile Venture Prato 2018
Object Calisthenics - Agile Venture Prato 2018
 
Object Calisthenics - TDD Milano
Object Calisthenics - TDD MilanoObject Calisthenics - TDD Milano
Object Calisthenics - TDD Milano
 
TDD a piccoli passi
TDD a piccoli passiTDD a piccoli passi
TDD a piccoli passi
 
Agile versioning with Git
Agile versioning with GitAgile versioning with Git
Agile versioning with Git
 

Dernier

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 

Dernier (20)

Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 

Object calisthenics