Code Smell 13 - Empty Constructors

Code Smell 13 - Empty Constructors

No-Parameterized constructors are a code smell of an invalid object that will dangerously mutate. Incomplete objects cause lots of issues.

TL;DR: Pass the essence to all your objects so they will not need to mutate.


  • Mutability

  • Incomplete objects

  • Concurrency inconsistencies between creation and essence setting.

  • Setters


  1. Pass the object's essence on creation

  2. Create objects with their immutable essence.


  • Some persistence frameworks in static typed languages require an empty constructor.


  • Stateless objects. Always better solution than static class methods.

Sample Code


class AirTicket {
   constructor() {     
class AirTicket {
   constructor(origin, destination, arline, departureTime, passenger) {     



Any linter can warn this (possible) situation.

More info


  • Essence

  • Incomplete

  • Mutable


Always create complete objects. Make their essence immutable to endure through time.

Every object needs its essence to be a valid one since inception.

We should read Plato's ideas about immutability and create entities in a complete and immutable way.

These immutable objects favor bijection and survive the passing of time.


Photo by Brett Jordan in Pexels

In a purely functional program, the value of a [constant] never changes, and yet, it changes all the time! A paradox!

Joel Spolski

This article is part of the CodeSmell Series.

Last update: 2021/06/18