Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
© XPSurgery.com 2016 @kevinrutherford
Love and Death
“To love is to suffer. To avoid suffering
one must not love. But then...
© XPSurgery.com 2016 @kevinrutherford
@kevinrutherford @xpsurgery
http://silkandspinach.net http://xpsurgery.com
© XPSurgery.com 2016 @kevinrutherford
?
© XPSurgery.com 2016 @kevinrutherford
SOLID
Primitive Obsession
Feature Envy
Sim
ulated
Polym
orphism
Lazy Class
Temporary...
© XPSurgery.com 2016 @kevinrutherford
Refactoring algorithm:
1. Remove some coupling
2. Repeat
© XPSurgery.com 2016 @kevinrutherford
https://github.com/ xpsurgery / corner-shop
© XPSurgery.com 2016 @kevinrutherford
A B
C
© XPSurgery.com 2016 @kevinrutherford
Warehouse
Actions
Catalogue
Actions
Basket
Actions
User
Interface
Warehouse
Catalogu...
© XPSurgery.com 2016 @kevinrutherford
Connascence between two software elements
A and B means either:
1) some change to A ...
© XPSurgery.com 2016 @kevinrutherford
Warehouse
Actions
Catalogue
Actions
Basket
Actions
User
Interface
Warehouse
Catalogu...
© XPSurgery.com 2016 @kevinrutherford
Warehouse
Actions
Warehouse
Connascence of Name
Connascence of Type
© XPSurgery.com 2016 @kevinrutherford
Degree
Reach
Type
© XPSurgery.com 2016 @kevinrutherford
expression ↔ expression 0
function ↔ function 1
object ↔ object 2
module ↔ module 3
...
© XPSurgery.com 2016 @kevinrutherford
Name
Type
Convention
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
...
© XPSurgery.com 2016 @kevinrutherford
Refactoring algorithm:
1. Organise the code into top-level
encapsulation units
2. Ma...
© XPSurgery.com 2016 @kevinrutherford
?
@kevinrutherford
@xpsurgery
http://silkandspinach.net/tag/connascence
http://xpsur...
Upcoming SlideShare
Loading in …5
×

Connascence hunting

817 views

Published on

Slides from a workshop I ran at CodeCraftConf 2016.

Published in: Software
  • Be the first to comment

  • Be the first to like this

Connascence hunting

  1. 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. 2. © XPSurgery.com 2016 @kevinrutherford @kevinrutherford @xpsurgery http://silkandspinach.net http://xpsurgery.com
  3. 3. © XPSurgery.com 2016 @kevinrutherford ?
  4. 4. © XPSurgery.com 2016 @kevinrutherford SOLID Primitive Obsession Feature Envy Sim ulated Polym orphism Lazy Class Temporary Field Inappropriate Intim acy ShotgunSurgery Data Clump Long M ethod Large Class ??? ??? ??? ??? ??? ??? ??? RefusedBequest
  5. 5. © XPSurgery.com 2016 @kevinrutherford Refactoring algorithm: 1. Remove some coupling 2. Repeat
  6. 6. © XPSurgery.com 2016 @kevinrutherford https://github.com/ xpsurgery / corner-shop
  7. 7. © XPSurgery.com 2016 @kevinrutherford A B C
  8. 8. © XPSurgery.com 2016 @kevinrutherford Warehouse Actions Catalogue Actions Basket Actions User Interface Warehouse Catalogue Basket Filestore Main
  9. 9. © 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.
  10. 10. © XPSurgery.com 2016 @kevinrutherford Warehouse Actions Catalogue Actions Basket Actions User Interface Warehouse Catalogue Basket Filestore Main
  11. 11. © XPSurgery.com 2016 @kevinrutherford Warehouse Actions Warehouse Connascence of Name Connascence of Type
  12. 12. © XPSurgery.com 2016 @kevinrutherford Degree Reach Type
  13. 13. © XPSurgery.com 2016 @kevinrutherford expression ↔ expression 0 function ↔ function 1 object ↔ object 2 module ↔ module 3 process ↔ process 4 Reach
  14. 14. © XPSurgery.com 2016 @kevinrutherford Name Type Convention Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Type
  15. 15. © XPSurgery.com 2016 @kevinrutherford Refactoring algorithm: 1. Organise the code into top-level encapsulation units 2. Map the connascence among them 3. Remove the worst 4. Recurse into each encapsulation unit [optional]
  16. 16. © XPSurgery.com 2016 @kevinrutherford ? @kevinrutherford @xpsurgery http://silkandspinach.net/tag/connascence http://xpsurgery.com

×