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
Please enter at least three characters to search
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

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • How Large Tech Companies Architect Resilient Systems for Millions of Users
  • Building Security into the Feature During the Design Phase
  • Build a Scalable E-commerce Platform: System Design Overview
  • A Step-by-Step Guide to Write a System Design Document

Trending

  • AI-Based Threat Detection in Cloud Security
  • How to Practice TDD With Kotlin
  • Docker Base Images Demystified: A Practical Guide
  • Docker Model Runner: Streamlining AI Deployment for Developers

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
Likes (6)
Comment
Save
Tweet
Share
9.1K 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

  • How Large Tech Companies Architect Resilient Systems for Millions of Users
  • Building Security into the Feature During the Design Phase
  • Build a Scalable E-commerce Platform: System Design Overview
  • A Step-by-Step Guide to Write a System Design Document

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and 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:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!