?
Solved

OOP Question - How To implement certain methods in my object model

Posted on 2007-07-24
3
Medium Priority
?
178 Views
Last Modified: 2010-04-23
I have a rather theoritical question concerning OOP.
I have my object model containing every single business object.
Every business object alsohas its own DAO object (Data Access Object) that controls the data manipulation.

Now I've come to the point that i need to create certain methods that use one of my business objects, but don't really fit anywhere in the existing objects I created.

For example:

Let's say I have an Business Object 'Order', which contains  all properties and calls to the DAO object for data manipulation (Load, Save, Delete).
Now I create a method 'createProductionOrder'. In the business logic of my case, a production order is divided in two; a transfer order and a production order. So I need to create two 'Orders' in this one method.

And this is why i'm confused: I cannot put this method in my 'Order' class because it creates two different types of Orders.

Should i implement a new pattern, or maybe a helper class of some sort? Please, any help is strongly appreciated!

Greetz, po$$e
0
Comment
Question by:posseke
3 Comments
 
LVL 18

Accepted Solution

by:
DarrenD earned 500 total points
ID: 19554553
Hi,

Can you use inheritence?

If you have an order class 'Order' which creates, updates and deletes orders can you create a new class 'ProductionOrder' which inherits from 'Order' and overwrite the create, update and delete methods?

This is one of those 'it depends' questions...

On the pattern bit you might want to look at the factory pattern.

Just a thought.

Darren
0
 
LVL 2

Assisted Solution

by:kralikX
kralikX earned 500 total points
ID: 19554712
Hi,
it depends on how you work with these two orders after you create them. If you work with them separately and only need to create them together (perhaps linked in some way), I'd create static method createProductionOrder in Order class. It would return two new instances of Order and you would work with them separately. See also "factory method" design pattern (http://www.dofactory.com/Patterns/PatternFactory.aspx).

If you need to work with the two order together, create new class (e.g. ProductionOrder) that would contain these two orders as fields and would manipulate with them together.

Regards,
Kralik.
0
 
LVL 2

Author Comment

by:posseke
ID: 19554795
Thx for the replies both of you,

Both Factory Pattern and the extra class (derived or non-derived) are possible, I'll look further into the Factory , this will do fine!

Greetz, po$$e
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Simple Linear Regression

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question