Membership
Main Menu
Forum Boards
Stats
- 20 tutorials
- 74,814 members
- 734,888 forum posts
- 13 blog posts
Tutorials
Design Patterns - Value Object
Views: 5754
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.
