The Object Reference Design Pattern
One of the most basic design patterns is the object reference design pattern.
Object Reference Pattern
This pattern essentially encapsulates details concerning persistable objects and their unique database query key. The pattern asserts that an object is a derived attribute aggregated by reference and is not persisted. The object’s unique database query key is aggregated by value, is persisted, and is write-protected against the attempt of any other package class to set its value.
In cases where database performance and storage are issues, object references persist only their object identifiers, and can be used in place of actual objects and acted upon via their identifiers. However, when the actual object is required, it can be gotten from the object reference which may or may not be currently holding the object. If the object reference does not hold the object and the object is asked for, the object is refreshed via its query key from the database.
Было ли это полезно?