A large number of flags at application initialization?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
11 views
Is there a web app that assembles itself, piece by piece, and depending on the transmitted at the start of the config. This can happen anywhere, so in order to ensure stability around the scattered pieces of code with a type code if (configLoadedFlag == true && frameworkLoadedFlag == true) {} else {} and naturally decline with logging in critical cases. It would be desirable to reduce the number of branches / order flags. I remember something from patternof had.
by | 11 views

5 Answers

0 like 0 dislike
Hide all flags that are "smeared" by the code inside a separate class, which depending on their condition generates (Factory and Strategy patterns) the object that performs the desired function. This will reduce the number of branches and reduce the connectivity code.
by
0 like 0 dislike
As far as I know, there is a pattern strategy to avoid the heap if-s. But I'm not sure it will fit you, because the idea is it should work with a configuration (combination of flags in this case). And the fact that you have " IFS " scattered throughout the code increases its connectivity. If you say that you have a lot of "pieces" that depend on each other, maybe you should use Dependency Injection?
by
0 like 0 dislike
And data validation flags are somehow connected?
For example can configLoadedFlag && frameworkLoadedFlag to mean something coherent? In this case it will just encapsulate the validation logic in one class, it is possible to check the value of a Flagged enum. If different combinations about the number of combinatorial (and they are not related in the manner described) is not suitable.
by
0 like 0 dislike
If cocked for each flag runs its more or less independent set of operations is described above — it is better to allocate the interface to work with this "configuration", and using the registration mapping action-flag to implement the required logic.
Here and the IoC just can be use.
by
0 like 0 dislike
Inside an already implemented set of commands. All of them are executed sequentially if all goes well, however, we are not in a perfect world and something is constantly falling. Perhaps the server didn't give the config may config found to be invalid, maybe the server code and external libraries has fallen off. In the end we 3 times perezapisyvat or config depending on the error trying to tell a library from a different place, etc. etc. If we consider configLoadedFlag && frameworkLoadedFlag then Yes it is holistic. This means that we have uploaded all the necessary and mono to start the app itself. If any of the 2 still in process, need to wait. Accordingly, here may be added some kind of check box type socketConnectionReadyFlag.
by

Related questions

0 like 0 dislike
5 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
27,959 users