#3 The Principle of Immutability

#3 The Principle of Immutability

<< Previous Edition: Are the best days of open-source movement behind?

This blog hails from the BC era — Before ChatGPT — and stands as a testament to enduring principles that transcend time.

The Principle of Immutability

As covered in previous blogs, my favorite software design and architecture principles are:

  1. The Git Principle
  2. The Maven Principle
  3. The Principle of Immutability

In this blog, I am going to cover the principle of immutability. This is the only principle that is not a side-effect of technology or framework among my core principles.

Immutability & Object-Oriented Design

The immutability principle is so universal that it can be appreciated at the most basic level and at the most advanced level. We can also look at it from an Object-Oriented programming perspective. Every object has a state and behavior. The internal state is its own business, and the only way an object should be modified is via behavior. The internal state of an object being hidden is called encapsulation.

Immutability takes this one step ahead with not even allowing the internal state of an object to be changed. In other words, if the internal state is changed, it’s no longer the same object. This new mutated object needs to be identified with a new identifier. If we use the language of security, it’s equivalent to an object having a different checksum. If we use the language of gitOps, it’s equivalent to an object having a new version.

In n-tier object-oriented design, the principle of immutability is most visible in the creation of data transfer objects or value objects.

Immutability & Gang of 4 Design Patterns

The principle of immutability intersects multiple Gang of 4 design patterns. The immutable artifact creation can be related to the factory method. Artifact cloning can be related to the prototype and memento pattern. Updating artifacts can be related to the state pattern.

Immutable Infrastructure & Environments

When designing the?Roost.ai?Test environments platform (our avatar in BC), one of the key considerations was how best we could provide immutable infrastructure for pre-production workloads. Following the pattern in the previous section, roost platform:

  1. Instantly creates versioned environments (using blueprint created from repository inference).
  2. Creates as many copies of the environment as needed.
  3. Update environments as the source repository changes.


>> Next Edition: An Ephemeral Life: The Story of a Software Artifact








Mário de Sá Vera

DD&IT Data Products | Assoc Director at Novartis

3 年

Go4... still rocking... ;) Nice article.

Immutability really drives Domain Driven Principles and aggregates.

要查看或添加评论,请登录

Rishi Yadav的更多文章

社区洞察

其他会员也浏览了