DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Low-Code Development: Leverage low and no code to streamline your workflow so that you can focus on higher priorities.

DZone Security Research: Tell us your top security strategies in 2024, influence our research, and enter for a chance to win $!

Launch your software development career: Dive head first into the SDLC and learn how to build high-quality software and teams.

Open Source Migration Practices and Patterns: Explore key traits of migrating open-source software and its impact on software development.

Related

  • Decision-Making Model: SOLVED
  • The Power of Refactoring: Extracting Interfaces for Flexible Code
  • Designing for Security
  • Rate Limiting Strategies for Efficient Traffic Management

Trending

  • Getting Started With Microsoft Tool Playwright for Automated Testing
  • Enhance IaC Security With Mend Scans
  • Tackling Records in Spring Boot
  • Mastering System Design: A Comprehensive Guide to System Scaling for Millions, Part 2

Design Patterns Are Blueprints

Should we abandon the notion that design patterns are blueprints, or is there more to it than that?

By 
Grzegorz Ziemoński user avatar
Grzegorz Ziemoński
·
May. 23, 16 · Opinion
Like (6)
Save
Tweet
Share
8.7K Views

Join the DZone community and get the full member experience.

Join For Free

Recently I was checking DZone for some interesting programming articles. One of the front page articles stated: Design Patterns Are Not Blueprints. If you haven't read it already, do it now.

So, of course, I got interested and read the text. It fell under the category of I wrote some nice code and I'm proud of it. But I would also argue that it falls under attacking well known, battle tested programming practices (one of many TDD is bad, Design Patterns are bad, OO is bad, etc.).

Immediately I sense some objections. The author didn't outright say "Design Patterns are bad!"; he just mentioned that you don't have to apply them left and right. Attacking articles tend to use words such as bad, sucks, or anti-pattern!

That's all well and good, but it brings me to the title of this article: "Design Patterns Are Blueprints," which the author of the opposing article contested. A pattern is a well-tested, working way of solving a design problem. It should only be used in that kind of a problem—not everywhere possible. Also, to say that anything related to the pattern is its implementation is as silly as doing anything else without thinking.

In his case, it would be stupid to define a WiringStrategy interface with a wire() method because we would have to add a lot of classes for nothing. The top-level logic would be cluttered by a list of WiringStrategy instances and overly generic algorithms.  We would misuse a pattern to get some artificial advantage over the original solution.

Why wouldn't the pattern help? Because the author's case wasn't one we need a strategy for; he didn't need algorithm interchangeability or algorithm-caller separation. We'd be messing with a list of strategies instead of some simple code. (Worst case, he could have really messed himself up with softcoding and externalized the list of strategies to a configuration file. Good for him that he didn't do that!) So you should use the pattern only if it fits your case, not in every similar case.

When do we give up on using a pattern? When someone looking at and maintaining the code would see simple method calls with obvious purposes and understand the priority between them without any patterns. Shifting to separate classes and some fixed structure in the name of flexibility would cause the poor maintainer to go multiple places to understand what the code is doing when it just doesn't seem worth it.

That article may seem like a separated example, but I've personally witnessed a lot of cases that are this bad. Sometimes it's the person who is convinced that design patterns are not blueprints, but misusing a term and propagating misunderstandings on a popular site for programmers is somehow OK. Design patterns have their place and should not be overused, but we should not be redefining well-known and settled terms just because we feel like it. Other times, it's the person who feels the need to object some well-known truth and prove that he's smarter; but I don't think it was the case this time.

At the end of the day, all of our design patterns and best practices are designed to train our minds so that we write good code. They are not supposed to be a substitute for thought, but we should not redefine them unless we have a very strong reason to do so. Also, the best users of design patterns often label their classes AbcFactory  or  XyzStrategy  or  AbstractProxyVisitorImpl because they want to express intentional use of a design pattern (even if it's clearly visible).

Like the wise programmer says Not only simplest thing that works. Simplest good design that works!

PS. This text is not meant to attack anyone personally. I just don't like when people are writing things based on false premises.

Design

Opinions expressed by DZone contributors are their own.

Related

  • Decision-Making Model: SOLVED
  • The Power of Refactoring: Extracting Interfaces for Flexible Code
  • Designing for Security
  • Rate Limiting Strategies for Efficient Traffic Management

Partner Resources


Comments

ABOUT US

  • About DZone
  • Send feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: