News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Nicolas Bérard-Nault's Blog:
The unknown value of Value Objects
March 31, 2011 @ 12:12:46

Nicolas Bérard-Nault has put together a new post looking at the role that Value Objects play in application development and, more specifically, how they fit in with domain driven design (DDD). He looks to explain the unknown value of Value Objects to developers that might not know how helpful they really can be.

One of the main rules of DDD is that value objects are immutable. This is often not as self-evident as it seems, as many programmers are not even aware of the state they leak and create. Sadly, state is often positively correlated with entropy. Hence, taking steps to contain and to limit state is one of the keys to taming complexity in an application.

He notes that even outside of DDD Value Objects can be quite useful. He gives an example of a "RationalNumber" class with methods for basic things like addition and subtraction. He shows the more traditional mutable version that most developers would start with and uses it in several examples to show its flaws. He finishes up the post with a look at the "more correct" immutable version of the class and a sample call that would result in the correct output of a simple matematical operation.

1 comment voice your opinion now!
valueobject domaindrivendesign mutable immutable


blog comments powered by Disqus

Similar Posts

Federico Cargnelutti's Blog: Domain-Driven Design with Zend Framework

Nicolas Bérard-Nault's Blog: The unknown value of Value Objects

DZone.com: Practical PHP Refactoring: Encapsulate Downcast (and Wrapping)

Wojciech Sznapka: Immutable value objects in PHP

Ross Tuck: Persisting Value Objects in Doctrine


Community Events





Don't see your event here?
Let us know!


series wordpress release application podcast developer configure code bugfix language introduction framework list api interview community threedevsandamaybe laravel library project

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework