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

Posted on 2007-07-24
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
Question by:posseke
    LVL 18

    Accepted Solution


    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.

    LVL 2

    Assisted Solution

    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 (

    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.

    LVL 2

    Author Comment

    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    A short article about problems I had with the new location API and permissions in Marshmallow
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now