CodyIT to [email protected]English • 4 months agoOOP is not that badosa1.netmessage-square57fedilinkarrow-up161arrow-down110starcopymore-verticalflagCreate ReportslashBlock usercross-posted to: [email protected]
arrow-up151arrow-down1external-linkOOP is not that badosa1.netCodyIT to [email protected]English • 4 months agomessage-square57fedilinkstarcopymore-verticalflagCreate ReportslashBlock usercross-posted to: [email protected]
minus-square@[email protected]linkfedilink1•edit-24 months 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. arrow-up11arrow-down10file-textreply1starmore-verticalmailMessageflagCreate ReportslashBlock user
minus-square@[email protected]linkfedilink2•4 months 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. arrow-up12arrow-down10file-textreply1starmore-verticalmailMessageflagCreate ReportslashBlock user
minus-square@[email protected]linkfedilink-1•edit-24 months agoThat’s changing the goal posts to “not static” arrow-up11arrow-down12file-textreply1starmore-verticalmailMessageflagCreate ReportslashBlock user
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”