SlideShare una empresa de Scribd logo
1 de 81
© XPSurgery.com 2016 @kevinrutherford
Love and Death
“To love is to suffer. To avoid suffering
one must not love. But then one
suffers from not loving. Therefore,
to love is to suffer; not to love is to
suffer; to suffer is to suffer. To be
happy is to love. To be happy,
then, is to suffer, but suffering
makes one unhappy. Therefore,
to be unhappy, one must love or
love to suffer or suffer from too
much happiness.
I hope you're getting this down.”
Love and Death, Woody Allen, 1975
© XPSurgery.com 2016 @kevinrutherford
@kevinrutherford @xpsurgery
http://silkandspinach.net http://xpsurgery.com
© XPSurgery.com 2016 @kevinrutherford
© XPSurgery.com 2016 @kevinrutherford
© XPSurgery.com 2016 @kevinrutherford
?
© XPSurgery.com 2016 @kevinrutherford
© XPSurgery.com 2016 @kevinrutherford
© XPSurgery.com 2016 @kevinrutherford
Extreme Normal Form:
1. Passes all tests
2. Expresses intent
3. No duplication
4. No extra stuff
© XPSurgery.com 2016 @kevinrutherford
Primitive Obsession
Feature Envy
Sim
ulated
Polym
orphism
Lazy Class
Temporary Field
Inappropriate
Intim
acy
ShotgunSurgery
Data Clump
Long
M
ethod
Large Class
???
??? ???
???
???
???
???
RefusedBequest
© XPSurgery.com 2016 @kevinrutherford
S ingle responsibility principle
O pen-closed principle
L iskov substitution principle
I nterface segregation principle
D ependency inversion principle
© XPSurgery.com 2016 @kevinrutherford
Principles of package cohesion
Reuse-release equivalence principle (REP)
Common-reuse principle (CRP)
Common-closure principle (CCP)
Principles of package coupling
Acyclic dependencies principle (ADP)
Stable-dependencies principle (SDP)
Stable-abstractions principle (SAP)
© XPSurgery.com 2016 @kevinrutherford
© XPSurgery.com 2016 @kevinrutherford
© XPSurgery.com 2016 @kevinrutherford
“This is Mrs Bencours,
one of my patients.
She thinks she's a sheep.”
Everything you always wanted to know about sex
but were afraid to ask, Woody Allen, 1975
coupling
© XPSurgery.com 2016 @kevinrutherford
Comparing Techniques by Means of Encapsulation
and Connascence,
Communications of the ACM Vol. 35, No. 9, Sept. 1992
pp. 147-151
Meilir
Page-Jones
© XPSurgery.com 2016 @kevinrutherford
1996
Meilir
Page-Jones
© XPSurgery.com 2016 @kevinrutherford
1999
Meilir
Page-Jones
© XPSurgery.com 2016 @kevinrutherford
Connascence between two software elements
A and B means either:
1) some change to A would require B to be changed, or
2) some change would require both A and B to be changed together
in order to preserve overall correctness.
© XPSurgery.com 2016 @kevinrutherford
Connascence between two software elements
A and B means either:
1) some change to A would require B to be changed,
(or at least carefully checked), or
2) some change would require both A and B to be changed together
in order to preserve overall correctness.
© XPSurgery.com 2016 @kevinrutherford
Meilir
Page-Jones
“I'll go so far as to say
that connascence [is]
at the heart of modern
software-engineering
constructs.”
© XPSurgery.com 2016 @kevinrutherford
2005-9
Grand Unified Theory
of Software Design
Jim
Weirich
© XPSurgery.com 2016 @kevinrutherford
© XPSurgery.com 2016 @kevinrutherford
© XPSurgery.com 2016 @kevinrutherford
Degree
Reach
Type
© XPSurgery.com 2016 @kevinrutherford
Degree
Type
Reach
© XPSurgery.com 2016 @kevinrutherford
Connascence of Name
int i = 9;
int j = Math.sqrt(i);
[static]
© XPSurgery.com 2016 @kevinrutherford
Connascence of Name
int i = 9;
int j = Math.sqrt(i);
[static]
© XPSurgery.com 2016 @kevinrutherford
Connascence of Name
int i = 9;
int j = Math.sqrt(i);
[static]
© XPSurgery.com 2016 @kevinrutherford
Connascence of Name
int i = 9;
int j = Math.sqrt(i);
[static]
© XPSurgery.com 2016 @kevinrutherford
Connascence of Name
int i = 9;
int j = Math.sqrt(i);
N
N N
N
[static]
© XPSurgery.com 2016 @kevinrutherford
Connascence of Algorithm
get(...) put(...)
[static]
© XPSurgery.com 2016 @kevinrutherford
Connascence of Algorithm
get(...) put(...)
A
[static]
© XPSurgery.com 2016 @kevinrutherford
Connascence of Algorithm
get(...) put(...)
hash(...)
[static]
© XPSurgery.com 2016 @kevinrutherford
Connascence of Algorithm
get(...) put(...)
hash(...)
A
[static]
© XPSurgery.com 2016 @kevinrutherford
Connascence of Position
printf(“%d %sn”, time.now(), request.path);
[static]
© XPSurgery.com 2016 @kevinrutherford
Connascence of Position
printf(“%d %sn”, time.now(), request.path);
P
[static]
© XPSurgery.com 2016 @kevinrutherford
Connascence of Convention
int basePrice = priceFor(sku); //  999 pence (== £9.99)
decimal salesTax = calcTax(basePrice);
return basePrice + salesTax;
[static]
© XPSurgery.com 2016 @kevinrutherford
Connascence of Convention
int basePrice = priceFor(sku); //  999 pence (== £9.99)
decimal salesTax = calcTax(basePrice);
return basePrice + salesTax;
C
[static]
© XPSurgery.com 2016 @kevinrutherford
Connascence of Type
int basePrice = priceFor(sku); //  999 pence (== £9.99)
decimal salesTax = calcTax(basePrice);
return basePrice + salesTax;
[static]
© XPSurgery.com 2016 @kevinrutherford
Connascence of Type
int basePrice = priceFor(sku); //  999 pence (== £9.99)
decimal salesTax = calcTax(basePrice);
return basePrice + salesTax;
T
[static]
© XPSurgery.com 2016 @kevinrutherford
Static connascence:
Name Convention
Algorithm Type
Position (Difference)
© XPSurgery.com 2016 @kevinrutherford
string[] board = new string[12];
     :
     :
if (position[currentPlayer] > 11)
  index = 0;
Connascence of Value
[dynamic]
© XPSurgery.com 2016 @kevinrutherford
string[] board = new string[12];
     :
     :
if (position[currentPlayer] > 11)
  index = 0;
Connascence of Value
[dynamic]
V
© XPSurgery.com 2016 @kevinrutherford
email = Email.new()
email.setRecipient("foo@example.com")
email.setSender("me@mydomain.com")
email.setSubject("Hello World")
email.send()
Connascence of Execution
[dynamic]
© XPSurgery.com 2016 @kevinrutherford
email = Email.new()
email.setRecipient("foo@example.com")
email.setSender("me@mydomain.com")
email.setSubject("Hello World")
email.send()
Connascence of Execution
[dynamic]
E
© XPSurgery.com 2016 @kevinrutherford
email = Email.new()
email.setRecipient("foo@example.com")
email.setSender("me@mydomain.com")
email.setSubject("Hello World")
email.send()
Connascence of Execution
[dynamic]
E
E
© XPSurgery.com 2016 @kevinrutherford
Connascence of Identity
[dynamic]
fetch(`http://localhost:17174/salesmen/${salesmanId}`, {
  method: 'put',
  body: JSON.stringify({
    salesmanId: salesmanId,
    orderId: orderId,
    commission: commission
  })
})
© XPSurgery.com 2016 @kevinrutherford
Connascence of Identity
[dynamic]
fetch(`http://localhost:17174/salesmen/${salesmanId}`, {
  method: 'put',
  body: JSON.stringify({
    salesmanId: salesmanId,
    orderId: orderId,
    commission: commission
  })
}) I
© XPSurgery.com 2016 @kevinrutherford
Connascence of Timing
[dynamic]
xrayMachine.on()
Thread.sleep(20)
xrayMachine.off()
© XPSurgery.com 2016 @kevinrutherford
Connascence of Timing
[dynamic]
xrayMachine.on()
Thread.sleep(20)
xrayMachine.off()
T
© XPSurgery.com 2016 @kevinrutherford
Dynamic connascence:
Value Timing
Execution (Difference)
Identity
© XPSurgery.com 2016 @kevinrutherford
Degree
Type
Reach
© XPSurgery.com 2016 @kevinrutherford
50
50
V = 2
E = 1
© XPSurgery.com 2016 @kevinrutherford
50
50
50
V = 3
E = 3
© XPSurgery.com 2016 @kevinrutherford
50
50
50
50
V = 4
E = 6
© XPSurgery.com 2016 @kevinrutherford
V = 5
E = 10
50
50
50
50
50
© XPSurgery.com 2016 @kevinrutherford
Type
Degree
Reach
© XPSurgery.com 2016 @kevinrutherford
expression ↔ expression 0
function ↔ function 1
object ↔ object 2
aggregate ↔ aggregate 3
process ↔ process 4
© XPSurgery.com 2016 @kevinrutherford
Degree
Reach
Type
© XPSurgery.com 2016 @kevinrutherford
© XPSurgery.com 2016 @kevinrutherford
© XPSurgery.com 2016 @kevinrutherford
1. Minimize overall connascence
2. Minimize connascence crossing
encapsulation boundaries
By breaking the system into
encapsulated elements
By maximising the connascence
within encapsulation boundaries
© XPSurgery.com 2016 @kevinrutherford
1. Minimize overall connascence
2. Minimize connascence crossing
encapsulation boundaries
By breaking the system into
encapsulated elements
By maximising the connascence
within encapsulation boundaries
© XPSurgery.com 2016 @kevinrutherford
1. Minimize overall connascence
By breaking the system into
encapsulated elements
© XPSurgery.com 2016 @kevinrutherford
© XPSurgery.com 2016 @kevinrutherford
© XPSurgery.com 2016 @kevinrutherford
© XPSurgery.com 2016 @kevinrutherford
© XPSurgery.com 2016 @kevinrutherford
Ca,b
= f(type, level, degree)
?
© XPSurgery.com 2016 @kevinrutherford
© XPSurgery.com 2016 @kevinrutherford
© XPSurgery.com 2016 @kevinrutherford
?
© XPSurgery.com 2016 @kevinrutherford
Primitive Obsession
Feature Envy
Sim
ulated
Polym
orphism
Lazy Class
Temporary Field
Inappropriate
Intim
acy
ShotgunSurgery
Data Clump
Long
M
ethod
Large Class
???
??? ???
???
???
???
???
RefusedBequest
© XPSurgery.com 2016 @kevinrutherford
“I'll go so far as to say
that connascence [is]
at the heart of modern
software-engineering
constructs.”
© XPSurgery.com 2016 @kevinrutherford
Degree
Reach
Type
© XPSurgery.com 2016 @kevinrutherford
1. Minimize overall connascence
2. Minimize connascence crossing
encapsulation boundaries
By breaking the system into
encapsulated elements
By maximising the connascence
within encapsulation boundaries
© XPSurgery.com 2016 @kevinrutherford
© XPSurgery.com 2016 @kevinrutherford
Ca,b
= f(type, level, degree)
© XPSurgery.com 2016 @kevinrutherford
1. Break the monolith you have into
meaningful encapsulation units
2. Remove the “worst” connascence among
the encapsulation units
3. Find which encapsulation units have
the “most” internal connascence
4. Recurse into each, returning to the
top level after each one
© XPSurgery.com 2016 @kevinrutherford
© XPSurgery.com 2016 @kevinrutherford
?
@kevinrutherford
@xpsurgery
http://silkandspinach.net/tag/connascence
http://xpsurgery.com

Más contenido relacionado

Más de Kevin Rutherford (14)

Hex arch
Hex archHex arch
Hex arch
 
Shepherding antipatterns
Shepherding antipatternsShepherding antipatterns
Shepherding antipatterns
 
Kata rules
Kata rulesKata rules
Kata rules
 
Movie app kata
Movie app kataMovie app kata
Movie app kata
 
Object discovery
Object discoveryObject discovery
Object discovery
 
Connascence
ConnascenceConnascence
Connascence
 
OCP Checkout kata
OCP Checkout kataOCP Checkout kata
OCP Checkout kata
 
OCP bowling kata
OCP bowling kataOCP bowling kata
OCP bowling kata
 
OCP String Calculator kata
OCP String Calculator kataOCP String Calculator kata
OCP String Calculator kata
 
OCP kata overview
OCP kata overviewOCP kata overview
OCP kata overview
 
Telling not-asking
Telling not-askingTelling not-asking
Telling not-asking
 
Uml
UmlUml
Uml
 
Agile principles
Agile principlesAgile principles
Agile principles
 
Flow
FlowFlow
Flow
 

Último

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 

Último (20)

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
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-...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
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...
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
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 Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
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
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 

Love and death

  • 1. © XPSurgery.com 2016 @kevinrutherford Love and Death “To love is to suffer. To avoid suffering one must not love. But then one suffers from not loving. Therefore, to love is to suffer; not to love is to suffer; to suffer is to suffer. To be happy is to love. To be happy, then, is to suffer, but suffering makes one unhappy. Therefore, to be unhappy, one must love or love to suffer or suffer from too much happiness. I hope you're getting this down.” Love and Death, Woody Allen, 1975
  • 2. © XPSurgery.com 2016 @kevinrutherford @kevinrutherford @xpsurgery http://silkandspinach.net http://xpsurgery.com
  • 3. © XPSurgery.com 2016 @kevinrutherford
  • 4. © XPSurgery.com 2016 @kevinrutherford
  • 5. © XPSurgery.com 2016 @kevinrutherford ?
  • 6. © XPSurgery.com 2016 @kevinrutherford
  • 7. © XPSurgery.com 2016 @kevinrutherford
  • 8. © XPSurgery.com 2016 @kevinrutherford Extreme Normal Form: 1. Passes all tests 2. Expresses intent 3. No duplication 4. No extra stuff
  • 9. © XPSurgery.com 2016 @kevinrutherford Primitive Obsession Feature Envy Sim ulated Polym orphism Lazy Class Temporary Field Inappropriate Intim acy ShotgunSurgery Data Clump Long M ethod Large Class ??? ??? ??? ??? ??? ??? ??? RefusedBequest
  • 10. © XPSurgery.com 2016 @kevinrutherford S ingle responsibility principle O pen-closed principle L iskov substitution principle I nterface segregation principle D ependency inversion principle
  • 11. © XPSurgery.com 2016 @kevinrutherford Principles of package cohesion Reuse-release equivalence principle (REP) Common-reuse principle (CRP) Common-closure principle (CCP) Principles of package coupling Acyclic dependencies principle (ADP) Stable-dependencies principle (SDP) Stable-abstractions principle (SAP)
  • 12. © XPSurgery.com 2016 @kevinrutherford
  • 13. © XPSurgery.com 2016 @kevinrutherford
  • 14. © XPSurgery.com 2016 @kevinrutherford “This is Mrs Bencours, one of my patients. She thinks she's a sheep.” Everything you always wanted to know about sex but were afraid to ask, Woody Allen, 1975 coupling
  • 15. © XPSurgery.com 2016 @kevinrutherford Comparing Techniques by Means of Encapsulation and Connascence, Communications of the ACM Vol. 35, No. 9, Sept. 1992 pp. 147-151 Meilir Page-Jones
  • 16. © XPSurgery.com 2016 @kevinrutherford 1996 Meilir Page-Jones
  • 17. © XPSurgery.com 2016 @kevinrutherford 1999 Meilir Page-Jones
  • 18. © XPSurgery.com 2016 @kevinrutherford Connascence between two software elements A and B means either: 1) some change to A would require B to be changed, or 2) some change would require both A and B to be changed together in order to preserve overall correctness.
  • 19. © XPSurgery.com 2016 @kevinrutherford Connascence between two software elements A and B means either: 1) some change to A would require B to be changed, (or at least carefully checked), or 2) some change would require both A and B to be changed together in order to preserve overall correctness.
  • 20. © XPSurgery.com 2016 @kevinrutherford Meilir Page-Jones “I'll go so far as to say that connascence [is] at the heart of modern software-engineering constructs.”
  • 21. © XPSurgery.com 2016 @kevinrutherford 2005-9 Grand Unified Theory of Software Design Jim Weirich
  • 22. © XPSurgery.com 2016 @kevinrutherford
  • 23. © XPSurgery.com 2016 @kevinrutherford
  • 24. © XPSurgery.com 2016 @kevinrutherford Degree Reach Type
  • 25. © XPSurgery.com 2016 @kevinrutherford Degree Type Reach
  • 26. © XPSurgery.com 2016 @kevinrutherford Connascence of Name int i = 9; int j = Math.sqrt(i); [static]
  • 27. © XPSurgery.com 2016 @kevinrutherford Connascence of Name int i = 9; int j = Math.sqrt(i); [static]
  • 28. © XPSurgery.com 2016 @kevinrutherford Connascence of Name int i = 9; int j = Math.sqrt(i); [static]
  • 29. © XPSurgery.com 2016 @kevinrutherford Connascence of Name int i = 9; int j = Math.sqrt(i); [static]
  • 30. © XPSurgery.com 2016 @kevinrutherford Connascence of Name int i = 9; int j = Math.sqrt(i); N N N N [static]
  • 31. © XPSurgery.com 2016 @kevinrutherford Connascence of Algorithm get(...) put(...) [static]
  • 32. © XPSurgery.com 2016 @kevinrutherford Connascence of Algorithm get(...) put(...) A [static]
  • 33. © XPSurgery.com 2016 @kevinrutherford Connascence of Algorithm get(...) put(...) hash(...) [static]
  • 34. © XPSurgery.com 2016 @kevinrutherford Connascence of Algorithm get(...) put(...) hash(...) A [static]
  • 35. © XPSurgery.com 2016 @kevinrutherford Connascence of Position printf(“%d %sn”, time.now(), request.path); [static]
  • 36. © XPSurgery.com 2016 @kevinrutherford Connascence of Position printf(“%d %sn”, time.now(), request.path); P [static]
  • 37. © XPSurgery.com 2016 @kevinrutherford Connascence of Convention int basePrice = priceFor(sku); //  999 pence (== £9.99) decimal salesTax = calcTax(basePrice); return basePrice + salesTax; [static]
  • 38. © XPSurgery.com 2016 @kevinrutherford Connascence of Convention int basePrice = priceFor(sku); //  999 pence (== £9.99) decimal salesTax = calcTax(basePrice); return basePrice + salesTax; C [static]
  • 39. © XPSurgery.com 2016 @kevinrutherford Connascence of Type int basePrice = priceFor(sku); //  999 pence (== £9.99) decimal salesTax = calcTax(basePrice); return basePrice + salesTax; [static]
  • 40. © XPSurgery.com 2016 @kevinrutherford Connascence of Type int basePrice = priceFor(sku); //  999 pence (== £9.99) decimal salesTax = calcTax(basePrice); return basePrice + salesTax; T [static]
  • 41. © XPSurgery.com 2016 @kevinrutherford Static connascence: Name Convention Algorithm Type Position (Difference)
  • 42. © XPSurgery.com 2016 @kevinrutherford string[] board = new string[12];      :      : if (position[currentPlayer] > 11)   index = 0; Connascence of Value [dynamic]
  • 43. © XPSurgery.com 2016 @kevinrutherford string[] board = new string[12];      :      : if (position[currentPlayer] > 11)   index = 0; Connascence of Value [dynamic] V
  • 44. © XPSurgery.com 2016 @kevinrutherford email = Email.new() email.setRecipient("foo@example.com") email.setSender("me@mydomain.com") email.setSubject("Hello World") email.send() Connascence of Execution [dynamic]
  • 45. © XPSurgery.com 2016 @kevinrutherford email = Email.new() email.setRecipient("foo@example.com") email.setSender("me@mydomain.com") email.setSubject("Hello World") email.send() Connascence of Execution [dynamic] E
  • 46. © XPSurgery.com 2016 @kevinrutherford email = Email.new() email.setRecipient("foo@example.com") email.setSender("me@mydomain.com") email.setSubject("Hello World") email.send() Connascence of Execution [dynamic] E E
  • 47. © XPSurgery.com 2016 @kevinrutherford Connascence of Identity [dynamic] fetch(`http://localhost:17174/salesmen/${salesmanId}`, {   method: 'put',   body: JSON.stringify({     salesmanId: salesmanId,     orderId: orderId,     commission: commission   }) })
  • 48. © XPSurgery.com 2016 @kevinrutherford Connascence of Identity [dynamic] fetch(`http://localhost:17174/salesmen/${salesmanId}`, {   method: 'put',   body: JSON.stringify({     salesmanId: salesmanId,     orderId: orderId,     commission: commission   }) }) I
  • 49. © XPSurgery.com 2016 @kevinrutherford Connascence of Timing [dynamic] xrayMachine.on() Thread.sleep(20) xrayMachine.off()
  • 50. © XPSurgery.com 2016 @kevinrutherford Connascence of Timing [dynamic] xrayMachine.on() Thread.sleep(20) xrayMachine.off() T
  • 51. © XPSurgery.com 2016 @kevinrutherford Dynamic connascence: Value Timing Execution (Difference) Identity
  • 52. © XPSurgery.com 2016 @kevinrutherford Degree Type Reach
  • 53. © XPSurgery.com 2016 @kevinrutherford 50 50 V = 2 E = 1
  • 54. © XPSurgery.com 2016 @kevinrutherford 50 50 50 V = 3 E = 3
  • 55. © XPSurgery.com 2016 @kevinrutherford 50 50 50 50 V = 4 E = 6
  • 56. © XPSurgery.com 2016 @kevinrutherford V = 5 E = 10 50 50 50 50 50
  • 57. © XPSurgery.com 2016 @kevinrutherford Type Degree Reach
  • 58. © XPSurgery.com 2016 @kevinrutherford expression ↔ expression 0 function ↔ function 1 object ↔ object 2 aggregate ↔ aggregate 3 process ↔ process 4
  • 59. © XPSurgery.com 2016 @kevinrutherford Degree Reach Type
  • 60. © XPSurgery.com 2016 @kevinrutherford
  • 61. © XPSurgery.com 2016 @kevinrutherford
  • 62. © XPSurgery.com 2016 @kevinrutherford 1. Minimize overall connascence 2. Minimize connascence crossing encapsulation boundaries By breaking the system into encapsulated elements By maximising the connascence within encapsulation boundaries
  • 63. © XPSurgery.com 2016 @kevinrutherford 1. Minimize overall connascence 2. Minimize connascence crossing encapsulation boundaries By breaking the system into encapsulated elements By maximising the connascence within encapsulation boundaries
  • 64. © XPSurgery.com 2016 @kevinrutherford 1. Minimize overall connascence By breaking the system into encapsulated elements
  • 65. © XPSurgery.com 2016 @kevinrutherford
  • 66. © XPSurgery.com 2016 @kevinrutherford
  • 67. © XPSurgery.com 2016 @kevinrutherford
  • 68. © XPSurgery.com 2016 @kevinrutherford
  • 69. © XPSurgery.com 2016 @kevinrutherford Ca,b = f(type, level, degree) ?
  • 70. © XPSurgery.com 2016 @kevinrutherford
  • 71. © XPSurgery.com 2016 @kevinrutherford
  • 72. © XPSurgery.com 2016 @kevinrutherford ?
  • 73. © XPSurgery.com 2016 @kevinrutherford Primitive Obsession Feature Envy Sim ulated Polym orphism Lazy Class Temporary Field Inappropriate Intim acy ShotgunSurgery Data Clump Long M ethod Large Class ??? ??? ??? ??? ??? ??? ??? RefusedBequest
  • 74. © XPSurgery.com 2016 @kevinrutherford “I'll go so far as to say that connascence [is] at the heart of modern software-engineering constructs.”
  • 75. © XPSurgery.com 2016 @kevinrutherford Degree Reach Type
  • 76. © XPSurgery.com 2016 @kevinrutherford 1. Minimize overall connascence 2. Minimize connascence crossing encapsulation boundaries By breaking the system into encapsulated elements By maximising the connascence within encapsulation boundaries
  • 77. © XPSurgery.com 2016 @kevinrutherford
  • 78. © XPSurgery.com 2016 @kevinrutherford Ca,b = f(type, level, degree)
  • 79. © XPSurgery.com 2016 @kevinrutherford 1. Break the monolith you have into meaningful encapsulation units 2. Remove the “worst” connascence among the encapsulation units 3. Find which encapsulation units have the “most” internal connascence 4. Recurse into each, returning to the top level after each one
  • 80. © XPSurgery.com 2016 @kevinrutherford
  • 81. © XPSurgery.com 2016 @kevinrutherford ? @kevinrutherford @xpsurgery http://silkandspinach.net/tag/connascence http://xpsurgery.com

Notas del editor

  1. 1. Maths / group theory PhD 2. Encryption – mortgage transfers and Unix 3. Software house 4. Agile / XP 5. Coaching / training in s/w craftsmanship
  2. 1. There's a problem in s/w development 2. We'll look at failed solutions 3. Introduce the concept of coupling 4. Look at the properties of coupling 5. Do some calculus 6. Reconsider the problem
  3. First, the Problem...
  4. The TDD cycle Red Green Then what? Refactoring is hard No-one does it No-one knows what to do: How much? What to pick? When to stop?
  5. Now on to the failed solutions (This section may be a bit of a rant :-)
  6. People don't always know what “duplication” here means Not all duplicated text is “duplication” And duplication between Bounded Contexts is often / usually preferable to “fixing” it eg. build problems from shared library Plus, not all “duplication” is bad
  7. Ambiguous Overlapping People remember their names, but not what they mean Not clear what to DO eg. Feature Envy isn't always a problem (eg between bounded contexts)
  8. S, O describe end results – but people think they are things to DO L can be tested for, but no-one does I, D are design rules, but no-one understands what they really mean
  9. People don't know about these (People don't think about packages / namespaces / aggregates as a design tool) CCP == SRP SDP == SAP == DIP And not all dependency is bad
  10. Connascence was introduced and first examined by Meilir Page-Jones (who has the coolest moustache in CS) Connascence first appeared in this paper (Although Yourdon and Constantine kinda mention it in Structured Design in 1979)
  11. You can see in this video still that Jim is talking about connascence ...which is a CONNECTION between different software elements
  12. Connascence has a number of attributes or properties. These are my names for them, you may see others elsewhere.
  13. Let's first talk about the TYPE of the connascence
  14. Imagine we implement an object that contains a data structure based on a hash table (and for some reason we decide not to use a standard library)
  15. The get() and put() functions must agree on the hashing algorithm to be used
  16. Even if we extract the hashing algorithm to a function...
  17. … both get() and put() still need to call it, and are therefore still coupled by CoA Now, working with the person next to you, think of other examples of CoA?
  18. Consider this old-fashioned printf call in C...
  19. … there is CoP between the format string and the arguments to the call With the person next to you, think of other examples of CoP?
  20. Consider a system in which monetary amounts are represented as numbers of pence
  21. There is CoC between everything that has to calculate with those values … and also among the types of the variables and return types of the functions Now, in pairs come up with more examples of CoC
  22. NO AUDIENCE WORK HERE
  23. NO AUDIENCE WORK HERE
  24. NO AUDIENCE WORK HERE
  25. Now have the audience suggest examples
  26. Now have the audience come up with examples
  27. Now we'll cover the DEGREE of the coupling
  28. Now we'll cover the REACH of the coupling
  29. Page-Jones defines only 3 encapsulation levels But in modern programming there are more Connascence is worsened by crossing the boundary between two encapsulation units Maybe each of these is a “scope”? Maybe therefore “block” has been missed by P-J?
  30. Those are the main properties of connascence. We could also consider whether the connascence is EXPLICIT (obvious) or IMPLICIT, but Page-Jones is quite wishy-washy about this...
  31. Page-Jones gives these as guidelines for maintainability Can we turn them into an “algorithm” for refactoring?
  32. Everything depends on what we mean by these words (...and on our “definitions” of the various kinds of connascence :)
  33. We have numbers for level and degree, so let's see if we can rank the types <group exercise> Now let's list some properties of this function <call out and flipchart>
  34. Ns