M
M
muhasa2020-04-24 23:16:08
PHP
muhasa, 2020-04-24 23:16:08

A question for OOP people - how to organize the architecture for the pipeline of formulas?

Hello.
I am writing in php some application that makes some calculation for the company.
What entities does a company have, it has a lot of parameters ( param1, param2, ..., paramN ), there are several methods for calculating a certain level of confidence, each method includes coefficients calculated by formulas and a correspondence table for each formula.

For example:
Horns and hooves
1. On the market: 5 years
2. Sphere: Industry
3. Bukh. par. report 1: 150,000 (conditional parameters)
4. Bukh. par. report 2 2: 300 000

Methodology 1. Basic
1. Coefficient - Buch. par. report 2 / Buch. par. report 1 = 2
2. Correspondence table for coefficients. 1:

If the sphere is industry , then at the
coefficient. 1 > 1 = 5 points,
coefficient 1 = 1 = 3 points,
coefficient 2 < 1 = 1 point.

For others, the sphere has its own coefficients, but we do not consider them in the example.

One of the important aspects is that there can be any number of methods for calculating the level of trust in a company , each has its own coefficients and calculation methods, but at the end we always have some total score that we need.

Now to the point - for some reason it seems to me that it would be reasonable to apply the OO model with approximately the following organization logic:

Method 1 - a class that has an array of coefficients.
The coefficients themselves- also classes, inside of which there is a handler method that starts calculation by formulas.
Formulas - also in separate classes.
Correspondence tables are also separate classes

And put one into the other like a nesting doll.
Thus, a set of methods will be obtained, within which there are a number of coefficients calculated through formulas and tables of correspondence of these formulas to a set of values.

There are 2 key questions and 1 general.

1) If you do as I said, how to load, for example, formulas into the coefficient class? What to come up with a bootloader in such a situation?
2) How to transfer data to formulas? Not everyone will climb into the database, there will be darkness of requests. There was an idea about the formation of some data source object, how do you look at it?
3) Not too confused? I just would like to have a clear, harmonious structure, and not a bunch of algorithms stuck on top of each other.

Or can you suggest another scheme?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question