Mutation is good. Things change
TL;DR: Don't change essential attributes or behavior
Problems
Bijection violation
Solutions
Protect essential attributes from change.
Refactorings

Refactoring 001 - Remove Setters
Maxi Contieri βββ γ» Nov 17 '21 γ» 2 min read
Context
Heraclitus said:
β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.
Sample Code
Wrong
const date = new Date();
date.setMonth(4);
Right
const date = new Date("2022-03-25");
Detection
[X] Manual
This is a semantic smell. We need to model which attributes/behaviors are essential and which are accidental.
Tags
Conclusion
We need to favor immutable objects.
Objects can mutate in accidental ways, not in essential ones.
Relations

Code Smell 16β-βRippleΒ Effect
Maxi Contieri βββ γ» Nov 4 '20 γ» 2 min read
More Info

The evil powers of mutants
Maxi Contieri βββ γ» Dec 19 '20 γ» 6 min read
Disclaimer
Code Smells are just my opinion.
Credits
Photo by Nick Fewings on Unsplash
Changes in software design will eventually mean "one step forward, two steps back". It is inevitable.
Salman Arshad

Software Engineering Great Quotes
Maxi Contieri βββ γ» Dec 28 '20 γ» 13 min read
This article is part of the CodeSmell Series.
Top comments (0)