How is OOP and Design Patterns related?


Aren't Design Patterns an extension to OOP principles? Why are these two concepts treated separately? Can we believe that if someone who knows Design Patterns would definitely be an OOP expert?

Best Answer

A Design Pattern is a tried and tested solution to a common programming problem. It doesn't necessarily have to be an Object Oriented programming problem, but that is most common these days.

Learning to program is not hard for many people. It's like playing with Legos: there's a handful of different pieces you get to snap together however you want. Sometimes you make something cool, but most of the time you make crap =). Usually, the longer you play, the better you get.

Studying Design Patterns is learning good ways to build your programs. You're essentially reading advice from people that have been building things for decades. They've distilled their most common solutions into simple, digestible tidbits of knowledge with memorable names. It's like an apprenticeship for the digital-age: your elders are giving you their best advice. You can take it and be ahead of the game, or ignore it and repeat all of their mistakes.

Why are design patterns and OOP treated separately? Because they are different subjects. In general, you learn to program, then you learn how to think about programming. I wish it were the other way around, but I'm not holding my breath.

Is someone that knows Design Patterns necessarily an OOP expert? No.