Create your free BvLogic ID to continue this course and save your progress.
Design Patterns 5 lessons
  1. 1 What a pattern is for
  2. 2 The ones you will actually use sign in to open
  3. 3 Principles behind the patterns sign in to open
  4. 4 Recognising when you need one sign in to open
  5. 5 Patterns in the code you meet sign in to open
Course overview
Data: video · change

This lesson: 122KB

Design Patterns · Lesson 1 of 5

What a pattern is for

Understand them as vocabulary, not as rules.

A design pattern is a named solution to a problem that recurs. The value is mostly that it is named: saying "this is a factory" communicates in three words what would otherwise take a paragraph, and that shared vocabulary is what patterns actually buy you.

They are descriptions, not prescriptions. Patterns were catalogued by observing what experienced developers kept doing, not invented as rules to follow. Somebody who reads the catalogue and then looks for places to apply patterns has the relationship backwards, and the result is code with more structure than the problem required.

The right sequence. Write the simple thing. When it becomes awkward in a specific way, recognise that the awkwardness has a name, and apply the pattern that addresses it.

The common failure. A junior developer discovers patterns and produces a system with six abstractions where two functions would have done. This is worse than the naive version, because now the reader has to understand both the problem and the machinery built around it.

The second failure, less discussed, is not recognising a pattern you are reinventing badly. A great deal of confusing code is a half implemented observer or strategy that nobody named.

Know them well enough to recognise them in other people's code and in library documentation, which is where you will meet them most.

And accept that some are language specific. Several classic patterns exist to work around limitations that modern languages do not have, and using them anyway adds ceremony for nothing.

Lab — try it yourself

Look at a framework you use and identify two patterns in its design. You meet patterns in libraries far more often than you write them.

Check what you learned

Create your free BvLogic ID to take the quiz and record your score.

Create your BvLogic ID
Continue to lesson 2 Up next 2. The ones you will actually use