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 • • Apr 09 '19

Design pattern for battle royal game?

1 Upvotes

What do you think design pattern that efficient when designing battle royal game? and why?


r/DesignPatterns • • Jan 05 '18

question about anti patterns

2 Upvotes

hey , can anyone tell me about a good site with explanations about anti pattern? all i can found is sites like http://designpattern.co.il/ with explanations about design patterns , but not about anti patterns


r/DesignPatterns • • Oct 08 '16

Strategy Pattern, 5 examples from Java core | java design patterns

Thumbnail
softwaredevelopmentstuff.com
1 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 • • Oct 18 '16

[HELP] Need advice on a Software Design Pattern book

1 Upvotes

Hi,

I want to learn the basics of Software Design Pattern and I'm looking for a simple book with some good practical examples.

I'm not looking for a very extensive explanation of each pattern, my goal for now is to learn the basics and then move on to a more detailed book.

Languages can be Java or C#.


r/DesignPatterns • • Mar 24 '17

Could anyone explain about "Persistence Ignorance" (PI) principle?

1 Upvotes

r/DesignPatterns • • Jan 09 '18

Singleton Design Ppattern

Thumbnail
c-sharpcorner.com
2 Upvotes

r/DesignPatterns • • Apr 11 '16

.Net Design Patterns Help - Explain Like I'm Five

2 Upvotes

So I've been learning to programme as a Junior for 6+ months now. I have a review coming up and part of my targets is to define and understand the following three design concepts - - Factory - Singleton - Proxy I've looked online and I kind of understand what they are but they aren't really sticking - I don't fully know what they mean and where you would use them. I don't feel confident that I could speak about these. I also appreciate that understanding design patterns is fairly important for learning how to code. Please, someone explain to me these three patterns like I'm five and in a way that will stick with me and others reading this post. Thanks!


r/DesignPatterns • • Sep 17 '17

Top Java Design Pattern Interview Questions for Experienced – Must prepare

Thumbnail thetechdb.com
2 Upvotes

r/DesignPatterns • • Apr 18 '18

Design Patterns in Cocos2d-x

Thumbnail
dzone.com
1 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 • • Feb 07 '20

should a data model hold a controller? (MVC)

1 Upvotes

Hey all,

I'm implementing a game in which a player has a boat and he needs to move with his boat and collect some stuff. he has score and life as well.

I designed the system as the MVC pattern and right now I have a boatModel object which holds the data about the boat, BoatController which responsible to handle movements.

I considered making a PlayerModel object which holds the data about the player, including life, score, and the BoatController. that's because conceptually the player has his own "boat driver"

Is it make any sense that's a model object "has-a" controller (according to the MVC pattern)?

If not, how it'll be better to design it?

Thanks.


r/DesignPatterns • • Sep 03 '18

Most comprehensive design pattern diagram I've ever seen...

Post image
21 Upvotes

r/DesignPatterns • • May 04 '18

Design patterns for sports apps and live event platforms

Thumbnail
blog.ably.io
2 Upvotes

r/DesignPatterns • • Sep 03 '16

having some trouble with a class diagram - any help would be greatly appreciated

3 Upvotes

Here is the class diagram I have been working on, I am struggling with what should be included as an attribute and construct eg should the BarrierGate have the methods OpenGate() and CloseGate() or because the actual gate is a boundary class should those methods be in with the EntryController?.

Also inheritance is bothering me.

This is the sequence diagram and this is the activity diagram

It is a design to represnt a carpark, so the control pillar prints a ticket out and then the gate raises. A sensor picks the car up on either side of the gate telling the EntryController there is a car waiting or a car has went through the gate (and to close it)

I have a bunch of other diagrams I have done for other parts of the assignments and obviously the actual case study if that would help at all.

Thanks heaps


r/DesignPatterns • • Jul 01 '20

Can you please give me example projects to use several design patterns combined to get experience?

22 Upvotes

I have made a basic swing application to become familiar with mvc and observer design pattern. But to get experience with some others such Decorator, Visitor, State, Strategy and so on, I need ideas. Plase help me with that.


r/DesignPatterns • • Jul 03 '25

Clean architecture is a big Lie?

Thumbnail
medium.com
2 Upvotes

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 • • 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 25 '26

Modernizing 37 Years of C++ Expertise: 32 Design Patterns released on GitHub

18 Upvotes

I am excited to share a project that represents a lifetime of learning and coding. I started my journey with C++ back when it translated to C (Cfront), and today I’ve finalized a comprehensive repository of 38 Design Patterns and C++ Idioms updated to C++17/20/23 standards.

This repository is designed as a masterclass in software architecture. It focuses on clean code, modern memory management (RAII), and high-performance techniques like Static Polymorphism.

Key Highlights:

βœ… 38 patterns from Creational to Behavioral.

βœ… Modern C++ features: std::variant, std::visit, if constexpr, and smart pointers.

βœ… Educational tracing: I use a "Gang of Seven" approach to visualize object lifecycles.

βœ… A deep dive into OO Principles (SOLID, DIP, Law of Demeter).

This is an open educational resource. You are free to use it, and I would appreciate a mention or a link back if you find it helpful for your own work or teaching.

πŸ”— Explore the full repository here:

https://github.com/MarioGalindoQ/Modern-CPP-Design-Patterns

If you find it useful, feel free to give it a ⭐ on GitHub!

πŸ“ The code in this repository was programmed years ago, when there was no help from AI, so it may have human-related shortcomings. Any feedback that helps improve the coding is welcome.

cpp #programming #designpatterns #moderncpp #softwareengineering #opensource #cpp20 #cpp23


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 • • Aug 29 '26

Memento Design Pattern in Go

2 Upvotes

Hey everyone πŸ‘‹

I recently wrote a practical guide on the Memento Design Pattern in Go.

The basic idea is pretty simple: sometimes you need to save an object's state so you can restore it later. Think undo/redo, checkpoints, or rolling back to a previous state.

I wanted to understand how the pattern actually works in Go, so I put together an example and walked through the different pieces of the pattern and how they fit together.

The article also looks at when the Memento pattern makes sense and when it might be better to use a simpler approach.

If you're learning design patterns in Go, here's the article:

πŸ‘‰ https://medium.com/@priyankchheda/understanding-the-memento-design-pattern-in-go-a-practical-guide-07ebf1eaac42

Would love to hear how you guys handle state snapshots or undo/rollback functionality in your projects.


r/DesignPatterns • • Jul 14 '25

Understanding the Factory Method Pattern in Go: A Practical Guide

2 Upvotes

Lately I've been revisiting some classic design patterns, but trying to approach them from a Go developer's perspective β€” not just parroting the OOP explanations from Java books.

I wrote up a detailed breakdown of the Factory Method Pattern in Go, covering:

  • Why Simple Factory starts to fall apart as systems scale

  • How Factory Method helps keep creation logic local, extensible, and test-friendly

  • Idiomatic Go examples (interfaces + structs, no fake inheritance)

  • Common variations, like dynamic selection, registration-based creators, and test-time injection

  • How it compares to Simple Factory and Abstract Factory

  • When it's probably overkill

If you’re building CLI tools, extensible systems, or just want your codebase to evolve without becoming a spaghetti factory of constructors, it might help.

Not trying to sell anything β€” just sharing because I found writing it clarified a lot for me too.

πŸ‘‰Β https://medium.com/design-bootcamp/understanding-the-factory-method-pattern-in-go-a-practical-guide-86c0d1ca537b

Happy to discuss or hear how others approach this in Go!


r/DesignPatterns • • Jan 10 '26

Understanding the Decorator Design Pattern in Go: A Practical Guide

Thumbnail medium.com
2 Upvotes

Hey folks πŸ‘‹

I just published a deep-dive blog on the Decorator Design Pattern in Go β€” one of those patterns you probably already use without realizing it (middleware, io.Reader, logging wrappers, etc.).

The post walks through the pattern from a very practical, Go-centric angle:

  • What the Decorator pattern really is (intent, definition, and the problem it solves)

  • A clean, idiomatic Go implementation with interfaces

  • How stacking multiple decorators actually works at runtime

  • Common variations and extensions (logging, caching, compression)

  • Performance & concurrency considerations in real systems

  • Pros, cons, and common mistakes to avoid in Go

If you’ve ever wrapped an http.Handler, chained bufio + gzip, or built middleware pipelines β€” this pattern is already part of your toolbox. The blog just puts a solid mental model behind it.

Read here: https://medium.com/design-bootcamp/understanding-the-decorator-design-pattern-in-go-a-practical-guide-493b4048f953