October 17, 2005

OO Principles and Patterns

There are many things I like about Head First Design Patterns (HFDP), by Eric Freeman and Elisabeth Freeman, not the least of which is the teaching style that is employed. Various vehicles are used to get the message across. Cartoon style conversations between the Skeptical Developer and the Friendly Patterns Guru and crosswords, for example, both reappear as the chapters progress.

A page that I like, presented near the end of each chapter, is entitled Tools for your Design Toobox. It builds up lists of OO Principles and OO Patterns in addition to the OO Basics of Abstraction, Encapsulation, Polymorphism and Inheritance.

I thought it would be interesting to summarise the order in which these principles and patterns are presented. In brackets is the related pattern:

Encapsulate what varies. (Strategy)

Favor composition over inheritance. (Strategy)

Program to interfaces, not implementations. (Strategy)

Strive for loosely coupled designs between objects that interact. (Observer)

Classes should be open for extension but closed for modification. (Decorator)

Depend on abstractions. Do not depend on concrete classes. (Abstract Factory, Factory Method)

Only talk to your friends. (Adapter, Facade)

Don't call us, we'll call you. (Template Method)

A class should have only one reason to change. (Iterator, Composite)

I don't have anything profound to add; I just thought it would be interesting to summarise these principles as they are presented in HFDP.

Posted to Software Development by Keith Pitty
Comments

I love this kind of stuff; it makes programming so much more satisfying when you know why you are doing such-and-such. I'm really pleased to have a kindred programming spirit in the office.

Posted by: Dave Pinn at October 17, 2005 11:31 PM
Post a comment









Remember personal info?