I'm currently working on a pricing tool which has several level of calculations.
For instance, I have an object Quote which itself has one or several QuoteItem attached.
I think there should be class inheritance but I don't want to initialize my Quote every time I create a QuoteItem since all QuoteItems share exactly the same Quote with the same characteristics.
Is that class inheritance with super class ? Or should it be 2 independent class ? I can't find any documentation nor resource dealing about my scenario which I think to be very common.
I have a list of quoteitems which are attached to one quote, I would like first to create the quote and then the quoteitems. If I start from the quoteitems I feel that it will create everytime a quote which isn't at all the expected behaviour since there should be only 1 quote for all my quoteitems.
Is that a correct approach ?
class Quote():
def __init__():
# this will set parameter global to the quote
print('Quote created')
class QuoteItem(Quote):
def __init__():
# this will set specific details for all quote items attached to one specific quote
print ('QuoteItem created')
Or should those 2 classes be totally independent ?
Any use case or documentation about such scenario is welcome. The parent/subclass document I found deals only with object which are very similar. In my example they are not the same, they are children, i.e quoteitems can't exist without quote.
Thanks