Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Design pattern to truncate a large object graph

Tags:

java

object

graph

Using Java, I have a very large object graph where an object is associated with many other objects each of which is associated with yet many other objects. Most of the time I just need a sub-graph to pass on to a method or send across a network.

Is there a recommended design pattern so I can truncate this large object graph at many points in the graph. One way would be provide NULL as reference at all points of truncation. I'd appreciate any other ideas.

Thanks

like image 813
Anne Forumer Avatar asked Nov 12 '22 20:11

Anne Forumer


1 Answers

If I understand you correct, you could use Lazy Factory.
This strategy is commonly used when mapping object with associations which you do not need right now, and may not need at all. (It is widely used in Hibernate ORM).
When you want to send large objects accross a network you can use Proxy Pattern.

like image 184
white Avatar answered Nov 15 '22 12:11

white