Design Patterns Handbook
  • Introduction
  • Creational Patterns
    • Builder
    • Factory
    • Abstract Factory
    • Factory Method
    • Prototype
    • Singleton
    • Object Pool
    • Revealing Constructor
  • Structural Patterns
    • Adapter
    • Composite
    • Proxy
    • Flyweight
    • Facade
    • Bridge
    • Decorator
    • Private Class Data
  • Behavioral Patterns
    • Template Method
    • Mediator
    • Chain Of Responsibility
    • Observer
    • Strategy
    • Command
    • State
    • Visitor
    • Memento
    • Interpreter
    • Null Object
    • Iterator
    • Middleware
  • Clean Code Patterns
    • Extract Method
    • Clarify Responsibility
    • Remove Duplications
    • Keep Refactoring
    • Always Unit Test
    • Create Data Type
    • Comment to Better Name
    • Consistent Naming
    • If-else over ternary operator
    • Composition over Inheritance
    • Too Many Returns
    • Private to Interface
  • Anti Patterns
    • Big Ball of Mud
    • Singleton
    • Mad Scientist
    • Spaghetti Code
    • It Will Never Happen
    • Error Codes
    • Commented Code
    • Abbreviations
    • Prefixes
    • Over Patternized
    • Generic Interface over Function
Powered by GitBook
On this page

Was this helpful?

Introduction

NextCreational Patterns

Last updated 5 years ago

Was this helpful?

This handbook is full of examples to inspire usage and easier understanding of design patterns. What actually is a pattern?

Each pattern is a three-part rule, which expresses a relation between a certain context, a problem, and a solution. -- Alexander

When we start learning design patterns, we might tend to use them whenever possible. That can lead to over-engineering, which produces more code than it is necessary to implement the needed requirement. It is also called as over using of design patterns.

One way to escape over-engineering is to use Test Driver Development. TDD is made of 3 phases. First, write a simple test. Second, make the test pass, by implementing behavior that is required by the test. Third, refactor what we have coded to make the test pass. The third phase is the ideal place to think about design patterns, because when we want to refactor the code, we have a problem “how to make the code better?”. The design patterns are here to help us with problems, not to be a fancy toys to make our code better.

Always remember, when we use design patterns to solve code problem we face to, the intention is to lower complexity, never increase. That way we only produce low complexity code that is going to be readable and easily maintanable.

Interesting links and reference materials:

  • by SourceMaking

  • Refactoring to Patterns by Joshua Kerievsky

Examples of GoF Design Patterns in Java's core libraries
Design patterns deep dive