When to Use Design Patterns

Lately I've been doing a refresher course on design patterns. I've been wondering if it's worth memorizing them. It seems that once I read about a pattern, I'll want to apply it in a lot of situations while programming. Sometimes I'll work my way into an overly complex solution that has to be simplified later.

I think maybe the best way to approach design patterns is to use the quickest approach to get things working - without applying any patterns. Then, only after things are working, take a break from the code for a few days and sparingly refactor with design patterns if any make themselves apparent.

Of course, there are exceptions to this rule. Patterns like the inversion of control, abstract factory and data access object seem almost too intuitive not to use when initially designing a system.

No comments:

Post a Comment