Question on inheritance & association, pls help..

K

krislioe

Hi all,

I have two classes SalesOrder dan Invoice. The business rule is :
SalesOrder is processed/approved to produced an invoice.

So there is association between SalesOrder and Invoice.

On the other hand, Invoice has all the attributes that the SalesOrder
has EXCEPT for one attribute. (on example below : priority)

SalesOrder : docid, docno, docdate, customer, salesman,warehouse,
priority
Invoice : docid, docno, docdate, customer, salesman,warehouse,
DeliveryDate, LoadingDate, ReceiveDate, Amount

1) Should I create Invoice as subclass of SalesOrder ?

2) If the answer is yes, can we have both Extend and Association on the
relation of two entities like SalesOrder and Invoice ?

Thank you for your help,
xtanto
 
C

Chris Brat

Sounds like homework but anyway...

I'd rather have an abstract SalesDocument class that is extended by the
other two.

Have all the common fields and business logic in the SalesDocument
class and then have the Invoice and SalesOrder specific stuff in its
appropriate class.

You might only have one field that currently differs between SalesOrder
and Invoice but that can easily change - and you can add 'document'
specific methods where needed.

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top