Seeking advice on model design (composition vs inheritance)

Hello there,

First up will mention that I have a lot to learn :). Hence, I am working on an application in the gambling domain.

I am contemplating the scenario where I have to store portfolio’s and their associated staking plans. For example; A trading/gambling portfolio might have a staking plan attached to it. A staking plan might be one of the following options;

Martingale, RetirementPlan, Labouche, FibonacciSequence, PercentageOfBank, KellyCritereon, Etc

Depending on the portfolio, each of these staking plans might have different parameters/options attached to them. For example. Portfolio with a Martingale staking plan might need to store a house limit or a portfolio with a PercentageOfBank staking plan might need to store how much percentage to use.

My difficulty is, I am confused as to the best way to architecture my database model. (I am using entityframework code first). I am also unsure whether the case for inheritance or composition is the way to go for this.

Presuming I choose to go with composition. Would it be appropriate to have a model (or database table) for each of these staking plans? or would it be best to just jam it all into one table (e.g. like same as TPH inheritance)? I would for example have an interface called IStakingPlan then a bunch of classes that implement that interface.

Do I first need to decide on inheritance vs composition? and then plan my database?

I am confused! Thank you kindly for any advice, discussion or suggested solution

submitted by /u/BeingFriendlyIsNice
[link] [comments]

Leave a Reply