On Software Design Patterns
Software Design Patterns are widespread in nowadays development process. Design patterns are in any application, people ask about them on technical interviews, and many books describe them as a silver bullet. However, there are different opinions on this topic — let us see what developers think about design patterns.
The Good
The advantages of software design patterns are straightforward to see and to use in the development process.
The very first advantage is clear architecture. Every developer who knows standard design patterns can understand the architecture build with design patterns. Each pattern has its purpose, and books describe well-mastered pattern combinations and data structures. A developer needs to read them and understand the expected workflow. The adequately built architecture ensures that the application is easy to extend and scale.
Another plus is the ability to share knowledge efficiently. When all developers know all the standard patterns, it is trivial to explain the vision of the implementation to other developers. So, technical communication between the developers is significantly simplified too.
Finally, there are lots of already written libraries and components that implement some patterns. Knowing what patterns application uses, every developer can integrate this library into the project. This approach also simplifies integration between the existing components and even applications.
Because of all that, people describe software design patterns as best practices for a long time. However, developers note that life with design patterns is not that simple.
The Bad
All the advantages described above are real but applicable as is only in small applications. The architecture of medium and big applications is significantly harder to support, so developers should take additional effort and spend extra time to do it. As a consequence, the maintenance of such applications can be more expensive.
The next problem of big applications is complexity. The higher the number of supported features, the higher the number of used design patterns. Developers need more time to understand how some features built to work on them.
Some developers love design patterns to such an extent that they are applying design patterns everywhere it is possible. Unfortunately, this approach only increases complexity without giving anything in return. Maintaining such applications is a real nightmare.
All these issues lead to inconsistency in application architecture and code. Different developers may use different patterns for the same purpose that makes application even harder to understand. Uncontrolled usage of design patterns is one of the worst things that may happen to an application. As a consequence, it may be virtually impossible to understand how the application built and how to extend it.
How to solve these issues then?
The Ugly
The reality that every developer faces is in balancing between advantages and drawbacks of software design patterns. The application may have excellent architecture but takes time to understand it, it is scalable but complicated, extendable but expensive to support. A developer team should decide which patterns to use and whether it worth it.
The first advice for developers who are working on the complicated application is to apply KISS and YAGNI principles before considering the usage of any design pattern. A new abstraction layer may be not needed at all.
Another trivial but handy recommendation is to keep all architectural changes documented. It simplifies further changes in the application, decreases the time needed for newcomers to adapt, and gives an overall picture of the application structure.
To summarize, software design patterns are just tools that developers have to use appropriately under certain circumstances. Developers who are using them should have excellent architectural skills and enough experience to tell when design patterns become an issue. And finally, all changes in the application have to improve it and make it better for end-users.