"The goal is not to bend devs to the will of a specific pattern, but to get them to think about their work and what they're doing." They need to apply critical thought.
SOLID - Single Responsibility Principle, Open/Closed Principle, Liskov Substitution principle, Interface Segregation Principle, Dependency Inversion Principle
Have you had to maintain code that goes for more than one screen? Wow. Too many responsibilities in the code. As changes are made, and complexity introduced, then the quality degrades. Single responsibility is the rule.
How many times code breaks because you change the base class with unintended side effects. Should be able to extend classes but not modify them.
Liskov is coding to an interface. I shouldn't care where the instantiation came from.
Make fine grained interfaces to match specific needs. Create an interface that only applies to what I need.
Depend on abstractions, not concrete implementations. Use something, don't instantiate something unless using a factory.
So what are design patterns? GOF is a dry read. General reusable solutions to a common problem. Enables communication but may not be code. They are conceptual. Google SOLID and you'll find all sorts of resources.
Three types: Creational, Structural, and Behavioral
Creational
- Singleton
- Factory - simple, factory, abstract
Structural
Behavioral
Phil spent the rest of the evening walking through a number of design patterns in code.
Resources:
The classic Gang Of Four book Design Patterns
The readable patterns book Head First Design Patterns
www.dofactory.com