And the code display application contains three modules, or subprograms. The copy module calls the other two modules. Copy gets characters from the read keyboard and passes the characters to the write printer module.
.... Demand is changing:
We hope that copy can read information from the tape reader: If the variable value is false, it reads information from the keyboard as before. However, many other programs are currently using the copy program. You cannot change the interface of the Copy Program. Changing the interface will result in a long time of re-compilation and re-testing.
Patch:
Of course, you will think of the method of using a global variable. The result is as follows:
If you want to set the ptflag to true for the copy from the tape, and then call copy, it will correctly read the information from the tape. Once the copy call returns, the caller must reset the ptflag.
....
Need to change again:
The customer hopes that the copy program can be output to the paper belt void machine.
If such patching continues, the software will become difficult to maintain.
This design change is similar to the previous one. But another global variable and? Operator.
-----------------------------------------------------------------------------
The above example does not mean that the customer needs to be changed. In reality, the customer's needs must be changed.
The above example shows how fast the design degradation speed of the program is in the face of changes. The original design of the Copy Program is simple and elegant. However, after only two changes, it has shown symptoms of rigidity, vulnerability, unnecessary complexity, and unnecessary repetition.
Remember, the most unstable in most software projects is the requirement. It must be in a continuously changing state. This is a fact we must accept as developers!
A good solution:
In this example, when we encounter the first requirement change, we need to modify the design and make the modified design flexible for the changes in that category of requirements.
To meet new requirements, the team seize this opportunity to change the design so that the design will be flexible for future similar changes, rather than trying to patch the design.
Agile Software Development-an example: Copy Program