Membership
Main Menu
Forum Boards
Stats
- 23 tutorials
- 83,588 members
- 882,142 forum posts
- 33 blog posts
Tutorials
Design Patterns - Value Object
Views: 12819
Introduction
The Value Object pattern has, just like the Singleton, to do with referencing and instances. In a way, the Value Object is the opposite of the Singleton: its goal is to ensure NOT to use the same instance, under certain conditions.
Problem
How to prevent that objects serving as containers to certain values are unintentionally reused instead of re-instantiated.
If you have read OO PHP Part 1, you probably remember Snoopy and Lassie being attached at the mouth. It is because PHP 5 uses handles instead of copying every object like PHP 4 does that the Teeth property of Lassie wasn’t duplicated, causing both dogs’ Teeth property to refer to the same Teeth object.
This is essentially what you are trying to avoid when implementing the Value Object Pattern.
