connascence hunting
TRANSCRIPT
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
@kevinrutherford
@xpsurgery
http://silkandspinach.net
http://xpsurgery.com
1. Maths / group theory PhD2. Encryption mortgage transfers and Unix3. Software house4. Agile / XP5. Coaching / training in s/w craftsmanship
?
SOLID
Primitive Obsession
Feature Envy
Simulated Polymorphism
Lazy Class
Temporary Field
Inappropriate Intimacy
Shotgun Surgery
Data Clump
Long Method
Large Class
???
???
???
???
???
???
???
Refused Bequest
Code smells are confusing. Sometimes FeatureEnvy is a good thing...
SOLID is impractical
All these things are a proxy for COUPLING and COHESION
Refactoring algorithm:
1. Remove some coupling
2. Repeat
https://github.com/ xpsurgery / corner-shop
A
B
C
WarehouseActions
CatalogueActions
BasketActions
UserInterface
Warehouse
Catalogue
Basket
Filestore
Main
Connascence between two software elements
A and B means either:
some change to A would require B to be changed,
(or at least carefully checked), or
some change would require both A and B
to be changed together
in order to preserve overall correctness.
WarehouseActions
CatalogueActions
BasketActions
UserInterface
Warehouse
Catalogue
Basket
Filestore
Main
WarehouseActions
Warehouse
Connascence of Name
Connascence of Type
Degree
Reach
Type
expression expression0
function function 1
object object2
module module 3
process process 4
Reach
Name
Type
Convention
Algorithm
Position
Execution Order
Timing
Value
Identity
123456789
Type
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]
?
@kevinrutherford
@xpsurgery
http://silkandspinach.net/tag/connascence
http://xpsurgery.com