How to load design patterns in to your brain

(How to remember design patterns)

Daneesha Bartholomeusz

--

Edited: September 2021

A few days ago I embarked on a personal project in view of career progress to study design patterns more thoroughly. The thing with design patterns is that although you may understand them while you’re looking at them it’s not easy to remember the principle and all the implementation details of all of them (say of 23 of them)when you’re looking at a problem which needs applying them.

The secret of using design patters is being able to do just that. So there has to be a way of cramming all of it in to your brain.

With my understanding of psychology and educational psychology and study theories I came up with a few tricks to do that.

Here’s how I did it in hope that it might help somebody else.

For example we’ll take the GOF (Gang Of Four) design patterns as they’re given in the https://www.dofactory.com/net/design-patterns where I go to refer C# design patterns.

There’re 23 GOF patterns and we’ll take them one by one to study them.

Go through the page and read the pattern well. (Tip 1: Studying something helps memory to recall it rather than just reading).

Take a notebook and draw down the class diagram for the pattern. (Tip 2: Drawing things helps the brain to remember things).

Prepare your computer to do the project in .NET (let’s say in Visual Studio). (Tip 3: Actively doing something helps to remember). Start a new project and start typing in the code of the real world example. You can look at the code to type it. It’s not necessary to do it from memory. I personally find that copying and pasting each block of code underneath my file helps me to type. I look at it and type and then delete it. It’s important to type in everything rather than copying and pasting. It improves muscle memory (Tip 4). Resist the urge to use the IntelliSense.

After typing in, draw down a class diagram for the real world scenario. This is not given in the website. (Tip 5: here you’re applying the knowledge that you already have to create something similar to another artifact).

After that create a real world example on your own. For example for the Abstract Factory pattern I created an example of Flower Gardens where girls pick flowers. For Builder pattern I created a scenario of contractors building different buildings. For Factory Method pattern I created a Manufacturing Factory of Biscuits.

For this first example create the scenario very close to the one in the real world example mentioned in the website. It’ll help you to use the brain hooks you already have (Tip 6). For example in the Abstract Factory scenario I created I took the flower gardens to be created by Africa Factory and AmericaFactory as given on the example on the website. Africa Factory and AmericaFactory was something that stuck in my mind well when I studied the example on the website. So here I’m using my already existing memory hook.

After you create your own example with the use of pen and paper type it into the computer. Here also you can refer the code given on the website.

Then draw down the class diagram for the scenario you created. By looking at the class diagram you drew before for the real world example on the website and doing the necessary changes.

If you still can’t remember well do another real world example. This example, make it deviate a little from the example on the website, it’s not necessary to get it exactly like that. For the Abstract Factory pattern I created a scenario where there is a business world and there’re Managers and Accountants. And I used the names of people I know as the concrete managers and concrete accountants. (Tip 7: personalize things. This helps to remember).

Afterwards you can draw the class diagram for this example also.

Another thing that helps to remember is coming up with strange examples. Make things Bizarre (Tip8). It helps to stick things in memory. For the Prototype pattern I came up with an example for a human cloning factory.

After this you should be able to remember the pattern well. For quick reference in future use keep the class diagrams you drew.

If you study one pattern each day you’ll be able to cover them in 23 days. (And then you can think about what to do next, maybe study another set of patterns).

After I studied the patterns this way I can easily remember the principles and the implementation details of all the examples very clearly!

Hope this helps.

-Daneesha

--

--

No responses yet