I have a need for both light and heavy versions of the object in my application.
- A lightweight object will contain only ID fields, but there will be no instances of related classes.
- An object with a heavy weight will contain identifiers and instances of these classes.
Here is an example class (for discussion only):
public class OrderItem {
Is there a good design pattern to accomplish this?
I see how it can be encoded into one class (as my example above), but it is unclear how the instance is used. I would need to check for NULL in all my code.
Edit: This object model is used on the client side of the client-server application. In the case when I use light objects, I do not need a lazy load, because it will be a waste of time and memory (I will already have objects in memory on the client side elsewhere)
source share