Design patterns in software engineering and Drupal
At this week's internal tech talk we discussed design patterns in software engineering. As Larry Garfield elegantly states in his Drupal Watchdog article on the subject, design patterns are the definitions of concepts. I like to think of them as good practice definitions as well.
Often, when faced with an architectural design problem to solve, using the usual technologies of Drupal and PHP, there are multiple paths that an engineer can take. To the junior engineer this can seem daunting since he will lack the knowledge and experience to know which possible route will produce the best result and fewest future headaches.
In such situations, a good working knowledge of the basic design patterns can be invaluable, since understanding them means that the engineer knows a good solution and the reason he is going to do it that way, thus avoiding the poor outcome the design pattern was described to avoid (also known as the anti-pattern).
Design patterns have analogies with standards-based approaches in other forms of engineering. Structural engineers have access to a huge wealth of experience locked into engineering standards that have been built up by their profession over the centuries. Software engineering is still a relatively new discipline and so good practice like this is less well described, but equally as important.
For those looking for more information on the subject, an early book is Design Patterns: Elements of Reusable Object-Oriented Software written by four software engineers in the early nineties who are known as 'The Gang of Four'. This is still considered one of the seminal works on the subject. We found the book a little heavy going however, and recommend Head first design patterns for an introduction to the subject. For more information and specific PHP code examples of design patterns, check out the IBM Developer works design patterns in PHP