how agile design uses ocp to eliminate design smells
TRANSCRIPT
Agiledesign
evolutionarydesign
codeandfixdesign
ExtremeProgrammingDesignMantra:
“YouAin’tGonnaNeedIt”
TaketheFirstBullet
Foolme
Once…
initsproperform
sumsup
initsmostcommonform
“Whenasinglechangetoaprogramresultsina cascade ofchangestodependentmodules,thedesignsmells ofrigidity.OCP advisesusto refactorthesystemsothatfurtherchangesofthatkindwillnotcausemoremodifications.IfOCP isappliedwell,furtherchangesofthatkindareachievedbyaddingnewcode, notbychangingoldcodethatalreadyworks”
YAGNI
Design moreresilientdesign
thesimplestthingthatcouldpossiblywork
patchingdegradeddesign
designsmells
coderot NeedlessComplexity
over-conformance OpenClosedPrinciple
requirementchange
resultsina
by
resultsin
reactstoreactsto
applying
by
firstbullet
has
suffersfrom
oneofthe
leadsto
worsethan
toexpensive
the
needstoevolvetosurvive threatensthe
survivalof
morecomplexthan
evolvesinto
closedagainstchangeslikethis
“notaperfume tobeliberallyscatteredalloverthesystem”
degrades/compromises
thransformsthis
intothis
helpsavoiding/eliminating
nottobeappliedwhenthereareno
strategiesuses
secondbullet
RobertMartin
MartinFowler
https://www.martinfowler.com/articles/designDead.html
ASD:PPP
HowAgiledesignusestheOpen-ClosedPrincipletoeliminatedesignsmells
startsbydoing
“Fool me once, shame on you. Fool me twice,shame on me.”
This is a powerful attitude in software design.
To keep from loading our software with needlesscomplexity, we may permit ourselves to befooled once.
This means that we initially write our codeexpecting it not to change.
When a change occurs, we implement theabstractions that protect us from future changes ofthat kind.
In short, we take the first bullet and then make surethat we are protected from any more bullets comingfrom that particular gun.
Conforming to OCP is expensive.
It takes development time and effort to create theappropriate abstractions. Those abstractions alsoincrease the complexity of the software design.There is a limit to the amount of abstraction that thedevelopers can afford.
Clearly, we want to limit the application of OCP tochanges that are likely.
How do we know which changes are likely? We dothe appropriate research, we ask the appropriatequestions, and we use our experience and commonsense.
And after all that, we wait until the changeshappen!
Agile teams apply principles only to solve smells;they don’t apply principles when there are nosmells.
It would be a mistake to unconditionally conform toa principle just because it is a principle. Theprinciples are there to help us eliminate badsmells. They are not a perfume to be liberallyscattered all over the system.
Over-conformance to the principles leads to thedesign smell of needless complexity.