Objective
Applying of Patterm is to increase the Chance of reusing code.
Design pattern basics
open close principle
In the life cycle of one software system , there must be something that remains constant, while other part should be changed with the evolution of the system. It is very easy to find out what will remain the same during the time, like basic demands of software , fundamental functionalities , and maybe skeleton of the system . In normal cases, softwares will be changed because of requirements changing, Improvement of capacity, migrating from one system to other , Adding some components etc.
for this reason, we should consider the framework carefully when we start a new software project, we must understand the demands and potential changes well. We must construct a flexible enough solution for the problem.
so the first rule and most fundamental one is open close principle, the software should be designed to comform to this rule. Then when something changes as the time goes by , you only need to change what is changed, leave other parts be the same .
Constant parts and Variable parts
The main goal of design pattern is to change what must be changed only . The constant parts of system don't need to be changed.
so , for us, it is very important to differentiate the two parts of the system. That is the first step We can use design pattern effectively.
According to my years' experience of developing, I find the constant parts of software most likely are interfaces and the ways to use interfaces, i.e. the process of interface, while the variable parts is the concrete implementation of the interfaces.
So if the constant parts are figured out , the remainder is quite easy to accomplish.
The key is to decouple the two parts relation.
The variable may be neccessary or can be predicted , also involve some unexpected things,like fixing a bug.
How design pattern benefits Software project.
If design pattern is applied successfully, It means you can accomplish the tasts with least efforts. Because you only need to do what is really necessary. That is reusability.
Secondly, the structure and molude dividing is very meaningful and easy to understand. That is clarity.
Lastly, It can also reduce bugs significantly. You also get correctness.