Goke Pelemo

54%
Flag icon
If I treat a field as a value, I can change the class of the inner object to make it a Value Object [mf-vo]. Value objects are generally easier to reason about, particularly because they are immutable. In general, immutable data structures are easier to deal with. I can pass an immutable data value out to other parts of the program and not worry that it might change without the enclosing object being aware of the change. I can replicate values around my program and not worry about maintaining memory links. Value objects are especially useful in distributed and concurrent systems.
Goke Pelemo
This is why on the frontend, I generally try not to hard code HTML in variables. By making them value objects, I can also apply native JS methods to manipulate the variable then re-render it on the DOM if needed. Frameworks like React just do it for me.
Refactoring: Improving the Design of Existing Code (Addison-Wesley Signature Series (Fowler))
Rate this book
Clear rating
Open Preview