Mutation is good. Things change
TL;DR: Don't change essential attributes or behavior
Protect essential attributes from change.
“No man ever steps in the same river twice. For it’s not the same river and he’s not the same man.”
The man stays the same in essence. But his body evolves.
const date = new Date(); date.setMonth(4);
const date = new Date("2022-03-25");
This is a semantic smell. We need to model which attributes/behaviors are essential and which are accidental.
We need to favor immutable objects.
Objects can mutate in accidental ways, not in essential ones.
Code Smells are just my opinion.
Changes in software design will eventually mean "one step forward, two steps back". It is inevitable.
This article is part of the CodeSmell Series.