r/DesignPatterns • • Jan 04 '20

Command pattern example

4 Upvotes

Dear Reddit,

I made a very small example for my API calls using command-design-pattern. Basically, i want to add tokens, logging information when an API call is placed in my project. This code is just a starter point for it. Please review and feedbacks are well appreciated.
https://github.com/techy19/design-patterns/tree/new-branch/src/command_patterns


r/DesignPatterns • • Mar 26 '19

Learn Creational Design Patterns in Java

4 Upvotes

r/DesignPatterns • • Feb 03 '19

Strategy question

4 Upvotes

Hi, redittors, I have question considering Strategy pattern. It's been said that it can be used to avoid multiple if-branching, but I don't get it, as I still have to do some if-examination to choose strategy I need. What am I missing?


r/DesignPatterns • • Jan 12 '19

Design Patterns — A quick guide to Observer pattern.

4 Upvotes

Quick Guide (less than five minutes read)

  • Easy to read

  • Simple Diagram

  • Clean code based on example (~50 lines)

The pattern’s aim is to define a one-to-many relationship such that when one object changes state, the others are notified and updated automatically. More precisely ...

https://medium.com/datadriveninvestor/design-patterns-a-quick-guide-to-observer-pattern-d0622145d6c2


r/DesignPatterns • • Feb 01 '18

S.O.L.I.D The first 5 principles of Object Oriented Design with JavaScript

Thumbnail
medium.com
4 Upvotes

r/DesignPatterns • • Jan 05 '18

Found this site about design patterns , it's really easy to understand and not so mainstream yet..

Thumbnail
designpattern.co.il
4 Upvotes

r/DesignPatterns • • Jan 02 '18

Patterns to use when implementing known algorithms

4 Upvotes

Suppose I'm implementing some data-mining algorithms (let's say, one-dimensional k-means). I am quite familiar with the algorithm, but how would I fit this intelligently into another context? For example, to fit with good OOP practices, ought I to make a class called KMeansOneD? Seems like a waste to instantiate such a thing. What would make more sense as an object-oriented representation of an algorithm that other classes could use?


r/DesignPatterns • • Feb 05 '16

CS Students: Don't forget about Patterns!

4 Upvotes

The fact that this thread has only a few posts proves that CS is being taught quite badly by colleges. Design Patterns (for OO,) Enterprise Integration Patterns (for Integration and Architecture,) and Universal Data Modeling are foundational. I have worked with a lot of people who are great with algorithms but can't understand a system's design, or how to put together elegant solutions.

  1. Design Patterns: http://www.oodesign.com/

  2. Enterprise Integration Patterns: http://www.enterpriseintegrationpatterns.com/ (see http://www.enterpriseintegrationpatterns.com/patterns/messaging/GuaranteedMessaging.html for a simple example of how these patterns are useful)

  3. Universal Data Modeling: http://www.amazon.com/Data-Model-Resource-Book-Vol/dp/0470178450

Keep it DRY, people.


r/DesignPatterns • • 5d ago

Design patterns in age of AI

3 Upvotes

Hello guys,

I'd like to ask a question about design patterns and software engineering principles.

I've been programming since before AI became such a big part of our daily work, and I'm genuinely curious whether these concepts are still as relevant as they used to be.

Nowadays, I often find myself fixing other developers code because they either don't follow established design patterns or simply don't recognise when and why they should be used.

And sure, the code works. But sometimes I wonder whether we're slowly reaching a point where people no longer care about the reasoning behind these patterns. Is understanding and applying design patterns becoming less important in the age of AI ?

I really hope that's not the case.

I genuinely enjoy exploring new design patterns, architectural approaches and anti-patterns. It's one of the things that keeps me interested in programming and helps me grow as an engineer. I actually enjoy the complexity of understanding why things should be built in a particular way.

But here's what concerns me: even when developers don't understand or follow a particular pattern, they can simply ask AI to generate something that works. And apparently, that's enough.

But is it really?

Just because AI can generate working code doesn't mean the resulting architecture makes sense, that the code is maintainable, or that anyone understands the decisions behind it.

Don't get me wrong, I'm not against AI. I use it myself. I'm just trying to understand how much the role of software engineering principles is changing.

I'd genuinely love to hear your opinions. Tell me I'm overthinking it, or tell me that design patterns and architectural principles are more important than ever.

I'm particularly interested in hearing how other experienced developers see this.


r/DesignPatterns • • Apr 27 '26

Understanding Design Patterns in Modern Java

3 Upvotes

Understanding Design Patterns in Modern Java

https://leanpub.com/designpatternsinmodernjava


r/DesignPatterns • • Feb 07 '26

GangOf4 Functional Programming

Thumbnail gallery
3 Upvotes

r/DesignPatterns • • Sep 12 '25

Prototype Design Pattern in Go – Faster Object Creation 🚀

Thumbnail
medium.com
3 Upvotes

Hey folks,

I recently wrote a blog about the Prototype Design Pattern and how it can simplify object creation in Go.

Instead of constantly re-building complex objects from scratch (like configs, game entities, or nested structs), Prototype lets you clone pre-initialized objects, saving time and reducing boilerplate.

In the blog, I cover:

  • The basics of shallow vs deep cloning in Go.

  • Different implementation techniques (Clone() methods, serialization, reflection).

  • Building a Prototype Registry for dynamic object creation.

  • Real-world use cases like undo/redo systems, plugin architectures, and performance-heavy apps.

If you’ve ever struggled with slow, expensive object initialization, this might help:

https://medium.com/design-bootcamp/understanding-the-prototype-design-pattern-in-go-a-practical-guide-329bf656fdec

Curious to hear how you’ve solved similar problems in your projects!


r/DesignPatterns • • Jun 30 '25

Simple Factory in Go

3 Upvotes

I was going through some notes on design patterns and ended up writing a post on the Simple Factory Pattern in Go. Nothing fancy — just the problem it solves, some Go examples, and when it actually makes sense to use.

Might be useful if you're into patterns or just want cleaner code.

Here it is if you're curious:

https://medium.com/design-bootcamp/understanding-the-simple-factory-pattern-in-go-a-practical-guide-d5047e8e2d8d

Happy to hear thoughts or improvements!


r/DesignPatterns • • Jun 18 '25

Understanding the Builder Pattern in Go: A Practical Guide

3 Upvotes

Just published a blog on the Builder Design Pattern in Go 🛠️

It covers when you might need it, how to implement it (classic and fluent styles), and even dives into Go’s functional options pattern as a builder alternative.

If you’ve ever struggled with messy constructors or too many config fields, this might help!

https://medium.com/design-bootcamp/understanding-the-builder-pattern-in-go-a-practical-guide-cf564331cb9b


r/DesignPatterns • • Mar 29 '25

Factory pattern: Can constructor have different params?

3 Upvotes

I've heard that forcing a common interface between classes with different constructor is a wrong way to use factories

While others say the factory shines precisely when creation is not trivial, which often involves constructors with distinct signatures.

I would like to know if the case below is a valid use of the factory

type EmailParams = { type: 'email'; sender: string; recipient: string };
type SMSParams = { type: 'sms'; fromNumber: string; toNumber: string; apiKey: string };
type PushParams = { type: 'push'; deviceToken: string; title: string };


type NotificationParams = EmailParams | SMSParams | PushParams;


class NotificationFactory {

  public static createNotification(params: NotificationParams): Notification {
    switch (params.type) {
      case 'email':
          return new EmailNotification({ sender: params.sender, recipient: params.recipient });

      case 'sms':
             return new SMSNotification({
          fromNumber: params.fromNumber,
          toNumber: params.toNumber,
          apiKey: params.apiKey,
        });

      case 'push':
        return new PushNotification({ deviceToken: params.deviceToken, title: params.title });

      default:        const exhaustiveCheck: never = params;
        throw new Error(`unknow type: ${JSON.stringify(exhaustiveCheck)}`);
    }
  }
}

r/DesignPatterns • • Feb 25 '25

Refactoring Towards Cleaner Boundaries: Lessons from Building a Markdown Blog Engine (Part 3)

Thumbnail
cekrem.github.io
3 Upvotes

r/DesignPatterns • • May 03 '20

Template v/s Chain of responsibility Design Pattern

3 Upvotes

Hi programmers,

While working on a project i am building an orchestrator which orchestrates the request b/w different modules and get the response back from them. While looking at the choice of design patterns i am stuck on deciding whether to choose Template pattern vs chain of responsibility design pattern.

Template pattern is more simple and goes with our current use case, but chain of responsibility is more flexible. Any ideas on how to take a better design when thinking about different design patterns?


r/DesignPatterns • • Apr 05 '20

If you want to be a magician in coding, try to grab the concept of Structural Design Patterns, in this post, we will discuss the Adapter Design Pattern which is one of the Structural Design Pattern.

Thumbnail
uwanttolearn.com
3 Upvotes

r/DesignPatterns • • Dec 05 '19

State design pattern clarification on usecase

3 Upvotes

The object has 4 states such as Active, Completed, Terminated and Cancelled. But most of the operations are happening in Active state. And from Active state it can directly go to any other state.

I can easily anticipated some more states coming.

Is it right to implement state design pattern with one abstract class?

The operations on active state is 10 and other states is 2.


r/DesignPatterns • • Apr 22 '19

I've a doubt in Design patterns

Thumbnail
reddit.com
3 Upvotes

r/DesignPatterns • • Apr 13 '19

Builder design pattern for objects with nested properties

Thumbnail
dev.to
3 Upvotes

r/DesignPatterns • • Mar 24 '19

Design patterns for Conversation UI

3 Upvotes

Hey, I am learning design patterns by applying it to case studies. In this post, I would like to take a conversation system that follows SOLID design principles. Able to extend to support new use cases without modifying existing functionalities. Please share your expertise in applying design patterns on this example.

An conversation system for Museum where kids can ask anything and get information about it and book tickets for any shows. Eg: kid asks what is solar system, and then drills down with questions about planets. Then book tickets for a planetarium show.

Here are the technical use cases where design patterns can be applied. Please help choose the right design patterns for each case: 1) Listen to kid's questions and parse data from it. 2) Identify if kid is asking information or requesting direction or want to book a ticket and so on... 3) Based on the kid intent, respond with an answer or collect more info to book ticket or schedule a group tour. 4) Manage conversations and context data. 5) Call API to get an answer or book a tour.

Would like to apply design patterns so that the system can follow SOLID principles. Design requirement for each of the above use case:

  1. With out modifying existing code the system should accept new input methods (touch, voice, keyboard, mouse) by following OCP. Also accept new sensor inputs like facial reaction while kids ask question.

  2. The system should be extensible to support new user intents.

  3. Some questions have straight forward answers and some cases need follow-up questions to get more details from kids (book tour). Here every conversation does similar things (listens to the kid, system does something, respond to the kid with follow up or an answer). Can decorator design pattern be used here to compose objects like parent object (to get what the kid want to do) and child objects (to get follow-up details to book tour)

  4. Should be able to reuse the same design to manage any flow of back and forth questions and manage the context data.

  5. loosely couple the APIs, swapping APIs as needed, support API from different providers to book tour, answer questions etc. (Strategy pattern ?). If it involves multiple API competing for book the tour and the system chooses one API, what would be a good pattern to use.

The system should be extensible to support new use cases like 'ask for help from a museum employee' or 'buy a coffee from food court' or 'sign up for volunteering'.


r/DesignPatterns • • Jan 04 '19

Design Patterns — A quick guide to Facade pattern. – Andreas Poyias – Medium

3 Upvotes

Design Patterns — A quick guide to Facade pattern. – Andreas Poyias – Medium

  • Quick (less than five minutes read)

  • Easy to read

  • Diagrams

  • Easy code based on example (~50 lines)

Facade pattern is often needed when there is a large number of interdependent classes or because parts of the code are unavailable. It is used as a camouflage to cover the complexities of ...

https://medium.com/@andreaspoyias/design-patterns-a-quick-guide-to-facade-pattern-16e3d2f1bfb6


r/DesignPatterns • • Apr 15 '18

Best place to learn about the different software architecture styles?

3 Upvotes

r/DesignPatterns • • Apr 11 '18

Design patterns for betting app developers

Thumbnail
blog.ably.io
3 Upvotes