Code Smell 321 - Getter Piggybacking

https://hackernoon.imgix.net/images/RIiBoPtpMiRsMKX3dnzl5gb1Urj1-ca839g4.jpeg

One broken window invites another

TL;DR: Don't reuse an existing getter to bolt on new business logic from outside the object.

Problems 😔

Solutions 😃

  1. Add real behavior methods
  2. Keep comparisons inside object
  3. Pass collaborators, not primitives
  4. Reserve getters for rendering
  5. Follow tell, don't ask

Refactorings ⚙️

Context 💬

An object exposes a getter for one legitimate reason: some other part of the system needs to read that value, usually to display it.

Getters are a code smell, but this one gets a pass, for now.

Later on, you discover that you need new business logic that depends on the same value.

You already have the getter, so you write a function outside the object that calls it and does the comparison itself, breaking the encapsulation principle.

Someone else needs slightly different logic...

Copyright of this story solely belongs to hackernoon.com. To see the full text click HERE

Read more

https://cdn.mos.cms.futurecdn.net/bG32Adb8R44ZcKDLi7JzHG-2000-80.jpg

Hitman World of Assassination devs say Elusive Targets are captured from studying talent over many hours and 'bespoke craftsmanship' rather than scans — 'You can have the 3d mesh completely right and still not feel like it looks like the person'

* IO Interactive shares how it creates accurate Hitman World of Assassination Elusive Targets * Senior level designer Marin Ansdal says there is no scanning involved and everything is "bespoke craftsmanship" * Junior concept and character artist Lovisa Österman says it takes "hours" of studying before beginning the design