lundi 20 janvier 2020

How can I design a computational engine with a set of formulas that use predefined values as part of formulas, where values depend on product model? [closed]

I have a product line called ABC, which has several models, like ABC-40, ABC-50, ABC-60. There are also more models.

Each model uses same computations, but different values for the variables used for the computations.

For example, for ABC-40:

C = [value read from input]
C2 = If C >= 6.25 THEN C2 = C, ELSE C2 = 6.25
I = C2 + [value read from db for that model]

For ABC-50

C = [value read from input]
C2 = if F = 1 or 2, then If C >= 8 THEN C2 = C, ELSE C2 = 8
C2 = if F = 0, then If C >= 7 THEN C2 = C, ELSE C2 = 7
I = C2 + [value read from db for that model]

And so on. At the end I want to know the values of C, C2, I (for all models these variables stay the same).

I am not sure how to start. I am thinking in the object-oriented PHP realm. I can create one product object for each model, ABC-50, ABC-60, etc, and hardcode the values into that object, including any computations.

OR I can create a single product object and somehow populate it with different values, either hardcoded or from a database. I am guessing the object that will be populating the Product class will be a factory with some kind of an if/then/else statement for each model.

It does not seem possible to me to just cleanly load things from a database without the if/then/else, because some computations for the values to be loaded are different for different product models (as in the example above).

Yet another alternative is to abandon OOP style and use procedural, aka for each model, do a single script of formulas. The bonus perk of that is every formula will be in a single place(file) for each model.

What I am looking to get out of this question is to get direction for proper design technique for this specific problem.

Aucun commentaire:

Enregistrer un commentaire