M
M
Maxim Grechushnikov2018-04-02 18:25:00
Software design
Maxim Grechushnikov, 2018-04-02 18:25:00

Are there programming patterns to simplify a large number of conditions?

A little loaded with one place in the system. I want to change.
the bottleneck of the program is in this place.
the application performs some calculations based on some set of data. Some data may affect calculations given other data, and so on.
conditions were added from time to time and there is nowhere to add them. everything collapses.
this cannot be solved with a switch, the conditions affect each other, I think I’m sitting how to unwind this ball so that it doesn’t get confused anymore.
thought to use some sort of strategy. how not spit, did not find how to insert,
at least explained clearly? not very messy?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexey Nikolaev, 2018-04-02
@Heian

According to the description, a Command came to mind, or rather, a chain of commands. You do something according to one condition (execute a command), then the next command is executed, and so on down the chain until the entire macro command is executed and returns the final result. The advantage of this approach is that you can swap commands, add, delete, break conditions and actions into separate blocks. You can also return other macro commands from commands and run branch chains (this is outside the standard implementations of the pattern, but it's easy to do).

E
eRKa, 2018-04-02
@kttotto

Если условия не линейные, то это "конечный автомат".

A
awesomer, 2018-04-02
@awesomer

таблица

R
Román Mirilaczvili, 2018-04-02
@2ord

Таблица решений

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question