In many of the application scenarios of the design program we encounter task flows that are broadly divided into three phases.
First, entrance
One or more entrances, waiting for blocking, or unsolicited requests.
==============================
For example, the task flow needs to accept application requests from HTTP and FTP, and subsequent requests for acceptance may be added in other ways.
Second, processing
Multiple portals can correspond to one handler or multiple handlers.
==================================
For example, HTTP and FTP Multiple entry procedures need to correspond to one or more processing logic, also faced with the increase of the processing program extensibility.
Third, export
Multiple handlers or one handler for multiple exits or one exit.
==================================
such as alarm mode has mail alarm, alarm and so on, the following may increase SMS alarm and so on.
In fact, the vast majority of demand can be abstracted into the above thinking.
So the extensibility requirement for this kind of problem is to change a small amount of the original code or simply not change the original code when expanding the function. Regardless of the software refactoring level, when the new recruits take over the boss's code, I think the most headache is to increase demand, because you do not know what to change the code to bring a hidden BUG.
We always ideal can use the "plug-in" thinking to adapt to demand, write a good framework, and then classify, each of the abstract role is a large container, and then each time to the container plug into a plug-in, to a demand, do a plug-in. To two needs, do two plug-ins to plug in a pair.
More "excessive" requirements are inserted into the plug-in must have a button to control whether to enable the plug-in, the reason is to plug the plug-in too time-consuming (corresponding code in the comments N multiple lines).
In short, everything we want the effect is that each plug-in independent work, non-corresponding, increase the scalability. The disadvantage is that there may be a part of the redundant code, but this is more than the handover to work so that people every day behind the black you have to be strong.
First we use the Golang to create a demand container.
[Golang] Task flow processing thinking based on Golang interface feature derivation