Vans Shoes DanylkoWeb

Always Learning. ASP.NET MVC. Code Exorcist. Mobile Gadgeteer. Web Architect.

Using JetBrain's ReSharper 9 to implement (and learn) Design Patterns

One of ReSharper's best kept secrets are Smart Templates. Today, I show you how to master your design patterns using a free download.

May 1st, 2015 • MVC •
0 (0 votes)
ReSharper 9 Smart Templates Title

If you've been a Visual Studio developer for a long time, you no doubt know that you cannot live without ReSharper and it's productivity tools when it comes to code enhancements.

After doing my 5 ways to take your ASP.NET MVC Development to "Ludicrous Speed," I always try to figure out a way to make it faster.

Usually code automation is key when generating fast and solid code. It's tried and tested code and that it's always worked for you and you can create your own boilerplate templates to generate code at the blink of an eye.

ReSharper Smart Templates

This is where JetBrains ReSharper's Smart Templates come into focus. These templates are common code structures that you build to speed up your development.

Think of Resharper's Smart Templates as code macros on Steroids!

While Resharper already has a number of them available, I'm always creating new templates to increase my productivity.

Patterns, Patterns, and More Patterns

While going through some code one day, I wanted to implement an observable pattern. I was having a "garbage collection/memory dump" day where I had a headache and couldn't think about how to implement one.

Then it hit me.

Why not have a collection of sample design patterns as Smart Templates?

After entering in all 23 design patterns to Resharper as Smart Templates, I thought others may have a need for these.

So I'm packaging them up and sending them to you.


After you receive your .zip file, unzip the files into a directory. You will see the ASP.NET MVC Guidelines PDF and the DesignPattern.DotSettings file.

  1. Open your Resharper Templates Explorer.

    Resharper Template Explorer

  2. Click the Import button and locate your DesignPatterns.dotSettings file.

    Resharper Import Templates

  3. You should be ready to start implementing your design patterns in your code.

At this point, you can close the templates explorer and open a code window and start testing your Design Pattern Smart Templates.

How is everything structured?

It's difficult to remember how to create a design pattern unless you've actually seen a piece of code that mimics the pattern.

It's even more difficult to relate certain pieces of code to a pattern which is why I decide to make things a little easier by putting the Smart Templates into naming categories.

To start using your new Smart Templates:

  1. Enter '_dp' for Design Pattern.
  2. Then decide on the type of Design Pattern you wish to use:
    1. Enter 'b' for Behavorial Patterns
    2. Enter 's' for Structural Patterns
    3. Enter 'c' for Creational Patterns
  3. Finally, enter the type of pattern you wish to use.

The chart below describes the design patterns available and their keyword shortcut.

Shortcut Type Description
_dpbc Behavorial Command Pattern
_dpbcor Behavorial Chain of Responsibility
_dpbint Behavorial Interpreter
_dpbit Behavorial Interator (debated as to whether to include this or not)
_dpbmed Behavorial Mediator
_dpbmem Behavorial Memento
_dpbo Behavorial Observer
_dpbst Behavorial State 
_dpbstr Behavorial Strategy
_dpcaf Creational Abstract Factory 
_dpcb Creational Builder 
_dpcf Creational Factory 
_dpcp Creational Prototype 
_dpcs Creational Singleton
_dpsa Structural Adapter
_dpsb Structural Bridge 
_dpsc Structural Composite 
_dpsd Structural Decorator 
_dpsf Structural Fascade 
_dpsfly Structural Flyweight 
_dpsp Structural Proxy 

So if you wanted to see what a Decorator pattern would look like, enter:

  • Enter '_dp' for Design Pattern.
  • 's' to learn it's a Structural pattern
  • and finally enter 'd' for Decorator.

After entering '_dpsd,' press Tab and you get the entire code structure with assistance as to what you want to call your new class, fields, and/or properties.

A majority of these samples were taken from the


I hope these Smart Templates help you in your coding travels. If you want to expand these patterns, please let me know and I will modify them and update the library for everyone.

Want the Smart Templates now?

Sign up below for my ASP.NET MVC newsletter and receive these Smart Templates in your email.

Was this informative? Share it!

Looking to become a better developer?

Sign up to receive ReSharper Design Pattern Smart Templates, ASP.NET MVC Guidelines Checklist, and Newsletter Updates!

Picture of Jonathan Danylko

Jonathan Danylko is a freelance web architect and avid programmer who has been programming for over 20 years. He has developed various systems in numerous industries including e-commerce, biotechnology, real estate, health, insurance, and utility companies.

When asked what he likes to do in his spare time, he replies, "Programming."

comments powered by Disqus