Value Objects For Flexible Systems

Rafael A. George Duval
1 min readFeb 6, 2024

--

Value Objects are immutable data structures that cannot be changed.

Although Ruby’s core library does not enforce immutability, it is essential to represent the use cases of an application. Value Objects are global and language-agnostic, and each language has its way of implementing them. Value objects are objects whose property values determine their equality. They reduce duplication in the system by consolidating attributes.

Immutability promotes stability by preventing side effects.

Value objects are immutable, and instantiating invalid objects can cause unexpected issues. Validations can reduce the risk of system crashes due to invalid states, but they are not foolproof.

Value objects consolidate attributes to remove duplication and enable rich behavior. Values in your system afford to shift process boundaries.

Using value objects to represent valid cases can eliminate ambiguity caused by Test-Doubles. Test-Doubles represent expected valid cases in the system, while Stubs represent good cases in the application.

In general, values in your system afford shifting boundaries between components.

[¹]: Domain-Driven Design: Tackling Complexity in the Heart of Software

--

--

Rafael A. George Duval
Rafael A. George Duval

Written by Rafael A. George Duval

✍🏼 Building a Solo Digital Media Company 🧪 Snippets of Text [https://snippetsoftext.substack.com/subscribe]

No responses yet