When writing programs, at a small scale, one cannot yet feel the importance of design patterns. Once the scale grows and requirements iterate, a project that applies appropriate design patterns can always iterate the fastest at the lowest cost.
But a strange point is that I can never remember the names of the specific implementations corresponding to the design patterns, yet I never forget the design ideas behind them — depend on abstractions rather than concretions; open for extension, closed for modification;
First, abstract a complex logic into a set of construction processes (with sequential constraints, i.e., timing constraints) or a set of meta-operations (facilitating combination to achieve complex logic), and encapsulate them with an interface.
Then, different logical entity classes inherit this interface and perform different concrete implementations.
Finally, depend on the interface, combine construction processes or meta-operations, and implement specific business code. If you want to change an implementation later, you only need to swap in a different concrete implementation class somewhere.