Avoiding extra fields from parent in inherited class (Partial inheritance?!)

Viewed 31

I am developing an API and there is a part in my API which gets some message from external source. I can receive three messages from this external source and the first message is about buying a stock and the second one and the third one is about selling the stock and if you combine the second message and the third message they have some mutual fields with the first message .

Just to be clear : 2nd + 3rd = 1st (1st have price amount side , 2nd have price and the 3rd have amount and side)

I thought that I can handle it with a base model but the problem is that if they all inherit a single base class then the 2nd and the 3rd message will have some extra fields ( 2nd message doesnt need to have a field for amount or 3rd message doesnt need to have a field for price) and if they inherit separate classes then there will be lots of classes . My question is that is there any way

0 Answers
Related