Value object definition

“A small simple object, like money or a data range, whose equality isn’t based on identity”1

Use case

Let’s assume for example that you want to represent addresses in your application domain. What is really important to represent addresses is the value they hold and not the exact instance they could become. Indeed there is no reason to have two distinct objects representing the same “5th Avenue” address. In practice their notion of equality isn’t based on identity. Instead two value objects are equal if all their fields are equal.

Doctrine embeddable

Let’s create our value object. What we want is to represent a user with some basic informations:

class User {
private $name;

private $street;

private $postalCode;

private $city;

private $country;
}

But hey! there are immutable fields in this class. So let’s try another way:

/**
* @Entity
*/

class User {

/**
* @Column(type="string")
*/

private $name;

/**
* @Embedded(class="Address")
*/

private $address;
}

/**
* @Embeddable
*/

class Address {

/**
* @Column(type="string")
*/

private $street;

/**
* @Column(type="string")
*/

private $postalCode;

/**
* @Column(type="string")
*/

private $city;

/**
* @Column(type="string")
*/

private $country;
}

In practice you are defining an Address value object.
Doctrine will inline all the columns from the Address class into the table of the User class:

|-----------------------+-----------------------|
| name | street | postalCode | city | country |
|--------|--------|------------|------|---------|
| Andrea | Via Po | 00100 | Rome | Italy |
|--------|--------|------------|------|---------|

And you can ask for the street in a simple way:

SELECT u FROM USER u WHERE u.address.city = :myCity
rolex replica watches  |
omega replica watches  |
longines replica watches  |
rolex replica watches  |
breitling replica watches  |
rolex replica wathces  |
omega replica watches  |
Windows 7 key  |
Windows 7 key  |
windows 7 professional key  |
windows 7 ultimate key  |
windows 7 home premium key  |
windows 7 Activation Key  |
windows 8 key  |
Windows 8 Enterprise key  |
Windows 8 Professional key  |
windows 8.1 professional key  |
Windows 10 key  |
windows 10 product key  |
Windows 10 serial key  |
windows 10 pro key  |
windows 10 home key  |
Office 2010 key  |
Office Professional Plus 2010 key  |
Office 2013 key  |
office professional plus 2013 key  |
Office 2016 key  |
Office Professional 2016 key  |
office professional plus 2016 key  |
Office 2016 for Mac Key  |
Windows 7 key  |
Windows 7 key  |
windows 7 professional key  |
windows 7 ultimate key  |
windows 7 home premium key  |
windows 7 Activation Key  |
windows 8 key  |
Windows 8 Enterprise key  |
Windows 8 Professional key  |
windows 8.1 professional key  |
Windows 10 key  |
windows 10 product key  |
Windows 10 serial key  |
windows 10 pro key  |
windows 10 home key  |
Office 2010 key  |
Office Professional Plus 2010 key  |
Office 2013 key  |
office professional plus 2013 key  |
Office 2016 key  |
Office Professional 2016 key  |
office professional plus 2016 key  |
Office 2016 for Mac Key  |
Windows 7 ultimate key  |
Windows 7 key  |
windows 7 professional key  |
windows 7 ultimate key  |
windows 7 home premium key  |
windows 7 Activation Key  |
windows 8 key  |
Windows 8 Enterprise key  |
Windows 8 Professional key  |
windows 8.1 professional key  |
Windows 10 key  |
windows 10 product key  |
Windows 10 serial key  |
windows 10 pro key  |
windows 10 home key  |
Office 2010 key  |
Office Professional Plus 2010 key  |
Office 2013 key  |
office professional plus 2013 key  |
Office 2016 key  |
Office Professional 2016 key  |
office professional plus 2016 key  |
Office 2016 for Mac Key  |
Office 2013 key  |
Windows 7 key  |
windows 7 professional key  |
windows 7 ultimate key  |
windows 7 home premium key  |
windows 7 Activation Key  |
windows 8 key  |
Windows 8 Enterprise key  |
Windows 8 Professional key  |
windows 8.1 professional key  |
Windows 10 key  |
windows 10 product key  |
Windows 10 serial key  |
windows 10 pro key  |
windows 10 home key  |
Office 2010 key  |
Office Professional Plus 2010 key  |
Office 2013 key  |
office professional plus 2013 key  |
Office 2016 key  |
Office Professional 2016 key  |
office professional plus 2016 key  |
Office 2016 for Mac Key  |
Office 2016 key  |
Windows 7 key  |
windows 7 professional key  |
windows 7 ultimate key  |
windows 7 home premium key  |
windows 7 Activation Key  |
windows 8 key  |
Windows 8 Enterprise key  |
Windows 8 Professional key  |
windows 8.1 professional key  |
Windows 10 key  |
windows 10 product key  |
Windows 10 serial key  |
windows 10 pro key  |
windows 10 home key  |
Office 2010 key  |
Office Professional Plus 2010 key  |
Office 2013 key  |
office professional plus 2013 key  |
Office 2016 key  |
Office Professional 2016 key  |
office professional plus 2016 key  |
Office 2016 for Mac Key  |
windows 7 Activation Key  |
Windows 7 key  |
windows 7 professional key  |
windows 7 ultimate key  |
windows 7 home premium key  |
windows 7 Activation Key  |
windows 8 key  |
Windows 8 Enterprise key  |
Windows 8 Professional key  |
windows 8.1 professional key  |
Windows 10 key  |
windows 10 product key  |
Windows 10 serial key  |
windows 10 pro key  |
windows 10 home key  |
Office 2010 key  |
Office Professional Plus 2010 key  |
Office 2013 key  |
office professional plus 2013 key  |
Office 2016 key  |
Office Professional 2016 key  |
office professional plus 2016 key  |
Office 2016 for Mac Key  |
windows 7 Activation Key  |
Windows 7 key  |
windows 7 professional key  |
windows 7 ultimate key  |
windows 7 home premium key  |
windows 7 Activation Key  |
windows 8 key  |
Windows 8 Enterprise key  |
Windows 8 Professional key  |
windows 8.1 professional key  |
Windows 10 key  |
windows 10 product key  |
Windows 10 serial key  |
windows 10 pro key  |
windows 10 home key  |
Office 2010 key  |
Office Professional Plus 2010 key  |
Office 2013 key  |
office professional plus 2013 key  |
Office 2016 key  |
Office Professional 2016 key  |
office professional plus 2016 key  |
Office 2016 for Mac Key  |
windows 7 home premium key  |
Windows 7 key  |
windows 7 professional key  |
windows 7 ultimate key  |
windows 7 home premium key  |
windows 7 Activation Key  |
windows 8 key  |
Windows 8 Enterprise key  |
Windows 8 Professional key  |
windows 8.1 professional key  |
Windows 10 key  |
windows 10 product key  |
Windows 10 serial key  |
windows 10 pro key  |
windows 10 home key  |
Office 2010 key  |
Office Professional Plus 2010 key  |
Office 2013 key  |
office professional plus 2013 key  |
Office 2016 key  |
Office Professional 2016 key  |
office professional plus 2016 key  |
Office 2016 for Mac Key  |
Office 2016 key  |
Windows 7 key  |
windows 7 professional key  |
windows 7 ultimate key  |
windows 7 home premium key  |
windows 7 Activation Key  |
windows 8 key  |
Windows 8 Enterprise key  |
Windows 8 Professional key  |
windows 8.1 professional key  |
Windows 10 key  |
windows 10 product key  |
Windows 10 serial key  |
windows 10 pro key  |
windows 10 home key  |
Office 2010 key  |
Office Professional Plus 2010 key  |
Office 2013 key  |
office professional plus 2013 key  |
Office 2016 key  |
Office Professional 2016 key  |
office professional plus 2016 key  |
Office 2016 for Mac Key  |
Windows 7 key  |
Windows 7 key  |
windows 7 professional key  |
windows 7 ultimate key  |
windows 7 home premium key  |
windows 7 Activation Key  |
windows 8 key  |
Windows 8 Enterprise key  |
Windows 8 Professional key  |
windows 8.1 professional key  |
Windows 10 key  |
windows 10 product key  |
Windows 10 serial key  |
windows 10 pro key  |
windows 10 home key  |
Office 2010 key  |
Office Professional Plus 2010 key  |
Office 2013 key  |
office professional plus 2013 key  |
Office 2016 key  |
Office Professional 2016 key  |
office professional plus 2016 key  |
Office 2016 for Mac Key  |