Code Smell 27 — Associative Arrays
- Information Hiding
- Code Duplication
- Fail Fast
- Reify objects
- Create cohesive small objects
- Don’t leave them anemic, find their cohesive relations.
Degrees deserves reification
Many people suffer from primitive obsession and believe this is over design. Designing software is about making decisions and comparing trade-offs. The performance argument is not valid nowadays since modern virtual machines can efficiently deal with small short-lived objects.
We cannot forbid Associative Arrays since they are very good as a first approach.
They will be fine for exporting data, serialization, persistence and other accidental implementation issues.
We should avoid them on our systems.
When creating objects we must not think of them as data. This is a common misconception.
We should stay loyal to our Bijection and discover real world objects.
Most associative arrays have cohesion and represent real world entities, and we must treat them as first class objects.
Code Smell 01 — Anemic Models
Your objects are a bunch of public attributes without behavior.
Failure is fashionable. Making is much easier than thinking and failures are not stigma, let’s take this idea to our…
There’s nothing more permanent than a temporary hack.
This article is part of the CodeSmell Series.