CodyIT@programming.dev to Programming@programming.devEnglish · 22 days agoOOP is not that badosa1.netexternal-linkmessage-square60fedilinkarrow-up159arrow-down110
arrow-up149arrow-down1external-linkOOP is not that badosa1.netCodyIT@programming.dev to Programming@programming.devEnglish · 22 days agomessage-square60fedilink
minus-squareKache@lemm.eelinkfedilinkarrow-up1·edit-219 days agoSounds easy to simplify: Use one of: constructor A(d), function a(d), or method d.a() to construct A’s. B and C never change, so I invoke YAGNI and hardcode them in this one and only place, abstracting them away entirely. No factories, no dependency injection frameworks.
minus-squareGissaMittJobb@lemmy.mllinkfedilinkarrow-up2·19 days agoNow B and C cannot be replaced for the purposes of testing the component in isolation, though. The hardcoded dependency just increased the testing complexity by a factor of B * C.
minus-squareKache@lemm.eelinkfedilinkarrow-up1arrow-down2·edit-219 days agoThat’s changing the goal posts to “not static”
Sounds easy to simplify:
Use one of: constructor
A(d)
, functiona(d)
, or methodd.a()
to construct A’s.B and C never change, so I invoke YAGNI and hardcode them in this one and only place, abstracting them away entirely.
No factories, no dependency injection frameworks.
Now B and C cannot be replaced for the purposes of testing the component in isolation, though. The hardcoded dependency just increased the testing complexity by a factor of B * C.
That’s changing the goal posts to “not static”