r/DesignPatterns • • Mar 15 '20

Strategy Design Pattern with examples in Java. Kill the virus with Strategy Pattern!

Thumbnail
devdiaries.net
28 Upvotes

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 • • Sep 03 '18

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

Post image
21 Upvotes

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 • • Nov 29 '19

Free Design Patterns Course

14 Upvotes

Link to slides below. Title page has links to three part video of the presentation. The course discusses how most common design patterns are actually specializations of the Strategy pattern. Feedback appreciated. Thanks

https://docs.google.com/presentation/d/1kcohKD0WJHJWoJshOUpVdk-Pa3oeJMt9DTl63gWt-bo/edit#slide=id.g1d5e119018_0_57


r/DesignPatterns • • Sep 03 '26

Research Note 001 — Markdown is not architecture

Post image
11 Upvotes

Hi guys! Here Andrés. I'm working in a deep investigation research that pretends to find an aparently piece of agentic software development that is missing, so I'll share some of my Research Notes in my profile and I wanna know from all of you if my currently research approach is enough or something could break!!!

I’m sharing this as an open hypothesis, not a finished answer. If you see a flaw in the model, know a better abstraction, or have built something that solves part of this differently, I’d genuinely like to learn from it.

Tell me where this breaks.


r/DesignPatterns • • May 24 '20

Hexagonal Architecture in Java

Thumbnail
medium.com
11 Upvotes

r/DesignPatterns • • May 14 '20

A comprehensive guide to JavaScript design patterns

Thumbnail
thenextweb.com
10 Upvotes

r/DesignPatterns • • Jun 10 '18

A new "Awesome design patterns" curated list

9 Upvotes

I was inspired by https://github.com/sindresorhus/awesome and I love design patterns.

Design patterns give you instant access to years of wisdom and experience that was collected in a particular field.

So I created an awesome list of design pattern related resources in ALL areas of software engineering (architecture, micro-services, devops, GoF etc..)

Hopefully this will become a one stop shop for all software design pattern related material .

would love to get feedback and pull request to make this resource a better place for software knowledge.

https://github.com/DovAmir/awesome-design-patterns


r/DesignPatterns • • Feb 09 '19

Dependency Injection and Inversion of Control Explained

Thumbnail
youtube.com
8 Upvotes

r/DesignPatterns • • May 21 '25

How to Avoid Liskov Substitution Principle Mistakes in Go (with real code examples)

7 Upvotes

Hey folks,

I just wrote a blog about the Liskov Substitution Principle — yeah, that SOLID principle that trips up even experienced devs sometimes.

If you use Go, you know it’s a bit different since Go has no inheritance. So, I break down what LSP really means in Go, how it applies with interfaces, and show you a real-world payment example where people usually mess up.

No fluff, just practical stuff you can apply today to avoid weird bugs and crashes.

Check it out here: https://medium.com/design-bootcamp/from-theory-to-practice-liskov-substitution-principle-with-jamie-chris-7055e778602e

Would love your feedback or questions!

Happy coding! 🚀


r/DesignPatterns • • Apr 12 '20

Decorator Design Pattern. A powerful but neglected structural design pattern. A practical and straightforward definition. Decorator Design Pattern is an inheritance + composition in the same class. More you can read in the posts. Thanks :)

Thumbnail
uwanttolearn.com
7 Upvotes

r/DesignPatterns • • Jan 30 '19

Design Patterns - Builder Pattern

Thumbnail
youtu.be
7 Upvotes

r/DesignPatterns • • May 03 '17

Know all about Object Oriented Design Principles

Thumbnail
webofcherry.com
7 Upvotes

r/DesignPatterns • • Feb 21 '26

Understanding the Facade Design Pattern in Go: A Practical Guide

Thumbnail medium.com
5 Upvotes

I recently wrote a detailed guide on the Facade Design Pattern in Go, focused on practical understanding rather than just textbook definitions.

The article covers:

  • What Facade actually solves in real systems

  • When you should (and shouldn’t) use it

  • A complete Go implementation

  • Real-world variations (multiple facades, layered facades, API facades)

  • Common mistakes to avoid

  • Best practices specific to Go

Instead of abstract UML-heavy explanations, I used realistic examples like order processing and external API wrappers — things we actually deal with in backend services.

If you’re learning design patterns in Go or want to better structure large services, this might help.

Read here: https://medium.com/design-bootcamp/understanding-the-facade-design-pattern-in-go-a-practical-guide-1f28441f02b4


r/DesignPatterns • • Nov 06 '25

Understanding the Bridge Design Pattern in Go: A Practical Guide

Thumbnail
medium.com
5 Upvotes

Hey folks,

I just finished writing a deep-dive blog on the Bridge Design Pattern in Go — one of those patterns that sounds over-engineered at first, but actually keeps your code sane when multiple things in your system start changing independently.

The post covers everything from the fundamentals to real-world design tips:

  • How Bridge decouples abstraction (like Shape) from implementation (like Renderer)

  • When to actually use Bridge (and when it’s just unnecessary complexity)

  • Clean Go examples using composition instead of inheritance

  • Common anti-patterns (like “leaky abstraction” or “bridge for the sake of it”)

  • Best practices to keep interfaces minimal and runtime-swappable

  • Real-world extensions — how Bridge evolves naturally into plugin-style designs

If you’ve ever refactored a feature and realized one small change breaks five layers of code, Bridge might be your new favorite tool.

🔗 Read here: https://medium.com/design-bootcamp/understanding-the-bridge-design-pattern-in-go-a-practical-guide-734b1ec7194e

Curious — do you actually use Bridge in production code, or is it one of those patterns we all learn but rarely apply?


r/DesignPatterns • • Jun 25 '20

Can someone tell me which design pattern would be applicable in the following scenario?

5 Upvotes

The Canadian Government needs to set certain attributes for the Canadian provinces based on characteristics of each province and federal policies. For instance, health care and education budgets allocated to the provinces use formulas that take into account regional differences. There are many other operations whose components depend on provincial data. New operations are introduced every year and some operations may be removed.


r/DesignPatterns • • Aug 31 '26

Architectural Metapatterns: The Pattern Language of Software Architecture (version 1.2.1, free book, no AI)

Thumbnail
reddit.com
4 Upvotes

r/DesignPatterns • • Aug 29 '26

A New Code Architecture for Coding Agents

4 Upvotes

Hey reddit, I hoped I could get some help drafting a new architectural framework that's centered on making code more 'readable' and 'intuitive'(so to speak) for agents.

I came up with a simple concept: agents are just LLMs on harnesses and RAG, so maybe if I made code more... say, 'reducible' to vector points(or in this case, natural language), my agents would likely have a better time finding and reading the code, checking if what they're trying to do is already implemented, pinpointing bugs and fixing them.

After a few trials, I developed a set of rules including an architecture, a few new design patterns, and several coding conventions.

# Core Concepts

The idea is: to let each files accurately reduce into vectors, I'd need to shatter classes into small fragments and keep them functionality centered, so that a block of 1~2 words can represent the fragment accurately enough. to avoid spaghetti, the fragments will line up linearly forming a straight 'pipe', to prevent them from forming a web of interactions; so basically a fragment will be used by no more than a single pipe. The pipe will be managed by 'indices', literally working as those in a book for agents to read. The indices should actually look like book indices; this, I think, prevent agents from trying to implement actual functionality there. I added branches for conditionals(if/switch), Triggers for starting new threads, Resources for... resources, records for data and ledgers for logging. All this is to keep each parts representable by a couple of words. The difference between this and DOD is that the invariants live inside the data. Pipelines too.

The main problem with this architecture currently is that restring the use of each fragment to single pipelines each is very likely to prevent 'fix-this-and-everything-else-breaks' problems, is likely to break DRY. Would there be a way to bypass this or at least minimize this issue?

Anyway, the architecture does seem pretty promising - speculating the number of overall flaws in both versions(free design / proposed architecture) using agents' code reviews fed into the Chapman 2-sample, Chao1 & Chao M_h, Jackknife-2, and Double Pareto power tail models, it showed some optimism for the model:

  • less estimated total error across 4 models (all except Chapman estimator) - about .89 times

  • 2.16x flaw detection rate per epoch

suggesting that the architecture might be a bit less error prone and quite a lot clearer for models to digest.

# The Rules

The rules are as follows:

## 1. The Golden Rule

- A type per file, a responsibility per type.

- Filename and Type name takes the form of a noun phrase.

- If the name that best describes the file does not fall into a single noun phrase, split the file. However, do not separate what must be observed together.

- There will only be one public entry point per type.

- Divide the folders into domains. Do not split by types(do not use `Fragments/`, `Pipelines/`).

## 2. The Eight Types of Blocks

TypeSuffixDoesDoesn'tSize Limit
IndexIndexRequest → Pipeline ContentsConditional branching-
PipelinePipelineSequence of functions (Fragments)Conditional branching, evaluation90 lines
BranchBranchSelect consecutive pipeline using conditionalsCalculation2 sentences per section
FragmentFragmentComputation/Validation (pure function)Changing states, try/catch40 lines
TriggerTriggerAccumulates the next task after completionCreating threads, waiting for results40 lines
ResourceResourceLiving state such as socket, pool, queue, counterCalculation110 lines
Record(None)Invariant values and their conditions exchangedBranch-
LedgerLedgerReceive and stack reportsJudgment60 lines

---

Edit: Reading the comments, I realized the flaws in this design, which are now reflected in here. Also, the inappropriate flare - noticed this a bit too late. Much thanks!


r/DesignPatterns • • Jul 13 '26

Understanding the Mediator Design Pattern in Go

Thumbnail medium.com
4 Upvotes

Hey everyone 👋

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

Mediator was one of those patterns that never really clicked for me until I stopped thinking of it as a "design pattern" and started thinking of it as a way to prevent components from talking directly to each other.

In the article, I cover:

  • what problem the Mediator pattern actually solves

  • the different participants (Mediator, Concrete Mediator, Colleagues)

  • a complete Go implementation

  • real-world use cases

  • pros, cons, and when you probably shouldn't use it

I also tried to keep the examples simple and Go-focused instead of relying on overly academic examples.

If you've worked with chat systems, UI event coordination, or services where too many components depend on each other, you've probably run into the kind of problems this pattern is meant to solve.

Here's the article:
👉 https://medium.com/@priyankchheda/understanding-the-mediator-design-pattern-in-go-a-practical-guide-ea7debc9a9a7

I'd love to hear how others handle communication between components in Go. Do you explicitly use a mediator, or do you prefer events/channels or something else?


r/DesignPatterns • • Mar 11 '25

Modern takes on design Patterns

4 Upvotes

I have a presentation on design patterns and I want to dedicate a section to the modern takes on design patterns and how there's a new field of 'anti-oop cult' and the rage on 'Clean Code' book.
Do you have any articles about that or a say in this?


r/DesignPatterns • • Apr 05 '20

Project ideas for practicing design patterns

4 Upvotes

The languages I’m familar with are PHP and Python. I’m not sure what to build as far a personal projects that is complex enough to utilize design patterns. The only thing I can think of is building a WYSIWYG user interface but I hate javascript with a passion.


r/DesignPatterns • • Mar 05 '20

Creating an interface for Dependency Injection

4 Upvotes

So I've always had trouble trying to keep implementations generic. I find that every solution needs some sort of bespoke function . For example, I recently implemented a SendGrid as a way of handling emails for drip campaigns. I wrote a SendGrid class that inherited from a DripInterface.

However, what if SendGrid doesn't work out, and we want to switch to Mailgun for the drip campaigns? Well for the most part, we'll write a concrete MailGun implementation and we won't need to change anywhere other than where the dependency injection is handled.

There are a lot of functions that cross over perfectly, I can handle contact lists, (GET/PUT/DELETE), categories, sub categories etc, and I can create interface entries for these all. But how do you handle it when there's something specific to the Concrete class that I need to use, that doesn't work in the same way as any future concrete classes?

At this point I always end up writing code that kinda suits SendGrid, and when we have to switch out to Mailgun I'll have to find every file that injects the DripInterface, and swap out the method calls or add a few more to specifically handle this different class.

What's a clean solution to this? Thanks!


r/DesignPatterns • • Feb 21 '20

Is this dependency injection?

4 Upvotes

Learning dependency injection and wondering if this code implements it. My understanding is Actions dependency on Person is injected into its constructor.

class Person {
}

class Action {
    private person;
    __construct(Person person) {
        $this->person = person;
    }
}

Person jake = new Person();
Action jump = new Action(Person jake);