Creative Coding

Design Patterns in WordPress: We're Just Getting Started


Throughout this series, we've been taking a look at a few design patterns and how they are applicable to software development - specifically WordPress development.

The thing about design patterns is that there is a wide variety of them and it would be near impossible to do justice to each of the patterns in a series here on the blog. Nonetheless, hopefully taking a look at these three have helped kickstart your interest in using design patterns in your work.

To wrap up this series, I wanted to provide a list of other patterns, resources, and guides that you may find useful if you've found this particular series useful in your development endeavors.

A List of Design Patterns

Here's the thing: The list of design patterns isn't fixed. There are some that have been established for quite some time.

The truth is, the patterns even have various permutations based on the environment in which they're implemented - this is why I think it's so important to understand the core pattern so that you can adapt it to your needs, or so you can recognize it in the wild so that - should the need arise - you can continue to implement your work in a way that plays nicely with the existing implementation.

With that said, I can't possibly list out all of the design patterns here. I can list out many of the popular patterns along with some links to their corresponding Wikipedia articles so you have a few to review.

For those that are listed above, I recommend at least reading through each of the articles. Many of the them will likely be applicable to your day-to-day work especially if you're working on larger applications. Even if you're working on a smaller project, they're still applicable and beneficial.

After that, we'll take a look at two books that I highly recommend for developers to have on their desk at any given time.


Whenever others ask me for resources on design patterns, there are really only two books that I recommend. Both of them are listed below along with links, a short description of each, why I recommend them, and the target audience for each of them.

Head First Design Patterns

Head First Design Patterns

Head First Design Patterns is a relatively new book in comparison to a lot of the material that's available today. It uses a different teaching style than many classical books or text books in that it uses a lot of humor, lots of pictures, diagrams, humor, and so on.

Personally, I'm a fan of its style but I know that some may reject it.

Nonetheless, the book covers the following patterns:

  • The Strategy Pattern
  • The Observer Pattern
  • The Decorator Pattern
  • The Simple Factory Pattern
  • The Factory Pattern
  • The Singleton Pattern
  • The Command Pattern
  • The Adapter Pattern
  • The Facade Pattern
  • The Template Method Pattern
  • The Iterator Pattern
  • The Composite Pattern
  • The State Pattern
  • The Proxy Pattern
  • The Compound Pattern
  • And a list of other common patterns that we've listed in the first part of this article.

If you're looking for a book to get started in design patterns, then this is the book with which I'd start.

Design Patterns: Elements of Reusable Object-Oriented Software

Gang of Four

This book is also known as The Gang of Four Book because it was written by four accomplished software engineers. It's a more technical read than Head First Design Patterns, but I still recommend it as the description of the patterns and the provided diagrams and implementations are easy to follow.

I will say that if you're just now venturing into the world of design patterns, I'd start with Head First and then read this book; otherwise, this one may seem a bit more dry or less interesting.

Nonetheless, here's the list of patterns the Gang of Four provide in their book:

  • The Abstract Pattern
  • The Builder Pattern
  • The Factory Pattern
  • The Prototype Pattern
  • The Singleton Pattern
  • The Chain of Responsibility
  • The Command Pattern
  • The Interpreter Pattern
  • The Iterator Pattern
  • The Mediator Pattern
  • The Memento Pattern
  • The Observer Pattern
  • The State Pattern
  • The Strategy Pattern
  • The Template Method Pattern
  • The Adapter Pattern
  • The Bridge Pattern
  • The Composite Pattern
  • The Decorator Pattern
  • The Facade Pattern
  • The Flyweight Pattern
  • The Proxy Pattern

In addition to covering the patterns, the book also uses case studies to show actual implementations of the pattern in real world examples which I think can be incredibly useful when referring to them in your work.


One of the dangers for people who first discover design patterns is the propensity to try to apply them everywhere, but don't do that: design patterns offer a lot of advantages in software development, but they have their place and things should not be forced into a pattern.

They should fit naturally.

In short, don't try to use patterns for the sake of using a pattern, use them when their design fits the problem that you're trying to solve.

With that said, we've wrapped up the Design Patterns in WordPress series.

To summarize:

  • We've covered the Observer Pattern and how we can setup our code to fire events and to publish them to other objects that are interested.
  • We've reviewed how to setup our plugins so that a single instance of the plugin is always accessible throughout the lifetime of the plugin, theme, or application
  • We also took a detailed look at the Simple Factory pattern that included a demo application, diagram, and sample code

All in all, it feels as if we've covered a lot of ground. The truth is, there's still much to review. If you've found this particular series interesting, or want to take a deeper dive into the topics at hand, be sure to review the design patterns listed earlier in this article, or read the two books that are linked above.

Related Posts
  • Code
    SOLID: Part 4 - The Dependency Inversion Principle4 dip retina
    The Single Responsibility (SRP), Open/Closed (OCP), Liskov Substitution, Interface Segregation, and Dependency Inversion. Five agile principles that should guide you every time you write code.Read More…
  • Code
    The Repository Design PatternRepository pattern retina preview
    The Repository Design Pattern, defined by Eric Evens in his Domain Driven Design book, is one of the most useful and most widely applicable design patterns ever invented. Any application has to work with persistence and with some kind of list of items. These can be users, products, networks, disks, or whatever your application is about. If you have a blog for example, you have to deal with lists of blog posts and lists of comments. The problem that all of these list management logics have in common is how to connect business logic, factories and persistence.Read More…
  • Code
    Creative Coding
    Design Patterns in WordPress: The Simple Factory PatternDesign patterns in wordpress
    In this series, we're taking a look at design patterns and how we can leverage them to our advantage when building products on top of WordPress. The nice thing about design patterns is that they aren't explicitly limited to themes or plugins - they are handy in a variety of different scenarios. It's simply a matter of being able to identify which patterns are applicable to certain scenarios.Read More…
  • Code
    Creative Coding
    Design Patterns in WordPress: The Singleton PatternDesign patterns in wordpress
    Throughout this series, we're taking a look at the significance of design patterns and the roles that they play in WordPress development. In the first post in the series, we took a high-level survey and even reviewed the Observer Pattern to see how it's possible to register various functions or objects with certain events that occur within the lifecycle of an application. In this post, where's going to take a look at the Singleton Pattern.Read More…
  • Code
    Creative Coding
    Design Patterns in WordPress: An IntroductionDesign patterns in wordpress
    For those who have an extensive background in software engineering, design patterns should be familiar territory; however, there's an entire group of developers - especially in the web development community - who aren't necessarily familiar with design patterns (even though they've likely used them!). In this series, we're going to take a look at design patterns, specifically in the context of WordPress, how they're useful, and some practical examples that we can use in our themes and plugins.Read More…
  • Code
    The Whens and Whys for PHP Design PatternsPreview
    There are plenty of articles that explain what design patterns are, and how to implement them; the web doesn't need yet another one of those articles! Instead, in this article, we will more discuss the when and why, rather than the which and how. I'll present different situations and use-cases for patterns, and will also provide short definitions to help those of you who are not so familiar with these specific patterns. Let's get started.Read More…