This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Can anyone suggest a design pattern for a simple problem.
I have two business object classes ( With setters and getters). I want to create a third class ( With setters and getters ) to be used for display. The third class will contain data extracted from the first two.
I have usually implemented this by having a static utility method that reads of the two objects and creates the third.
Would there be a pattern that could be put in use here.
Not very clear about what you are going to do with the data in the two classes (a,b). Is the third class(c) going to copy the data into itself, or can it just use getter methods of a and b to do its thing?
Possibly, you could do a facade pattern using a and b to provide the functionality of c?
Joined: Dec 14, 2004
C has some kind of aggregation of A and B ,but is a standalone class with getters and setters. Assume that the viewer can only deal with C and cannot deal with A and B.
So the functionality is to extract data from A and B to create C.
Joined: Dec 16, 2007
To me, facade sounds about right.
C contains objects of A and B. Users invoke methods of C, which in turn invoke methods of A and B to do whatever it is that they have to do.