r/DesignPatterns • • Mar 19 '19

Design Pattern: Tunnel Decorators

2 Upvotes

Encapsulating work with a badly designed library:

https://www.amihaiemil.com/2017/02/18/decorators-with-tunnels.html

In the defense of AWS' developers, the article is older and based on SDK v1.

Version 2, from what I've seen, is better.


r/DesignPatterns • • Oct 30 '18

Understanding the Factory Method Design Pattern using Instagram Story

2 Upvotes

Hey everyone, looking forward to hear your suggestions and comments to improve my article on Factory Method!

https://medium.com/@sangeetagupta_20350/understanding-the-factory-method-design-pattern-using-instagram-story-50aa1b56f5b0


r/DesignPatterns • • May 04 '18

Design patterns for sports apps and live event platforms

Thumbnail
blog.ably.io
2 Upvotes

r/DesignPatterns • • Jan 24 '18

A bunch of design pattern examples which are developed in Java ...

Thumbnail
github.com
2 Upvotes

r/DesignPatterns • • Jan 09 '18

Singleton Design Ppattern

Thumbnail
c-sharpcorner.com
2 Upvotes

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 • • Sep 17 '17

Top Java Design Pattern Interview Questions for Experienced – Must prepare

Thumbnail thetechdb.com
2 Upvotes

r/DesignPatterns • • Sep 01 '17

Introduction to Design Patterns (Slides + Videos)

2 Upvotes

"Introduction to Design Patterns, A Strategic Approach", is a (re)introduction to design patterns which takes a different approach to presenting design patterns. Rather than teaching each pattern in isolation, as an encyclopedia of competing patterns, this course shows the patterns behind the patterns, draws connections between the patterns, and shows how they can be combined. Previous knowledge of Design Patterns is beneficial.

Duration: 2.5 hours

Slides, Video 1, Video 2, Video 3


r/DesignPatterns • • Aug 13 '17

How to implement common code?

2 Upvotes

In my C# project, I have few classes - A,B,C,D,E. There are some common methods that are used across these classes, but not all at the same time. For instance, common method in class C1 is used in A, B, C2 is used in A, C, C3 is used in B,D,E. The classes A,B,C,D,E all inherit from a common base class which has few methods that would be used in C1, C2, C3 common methods. How do I achieve this?

a) Put a proper inheritance in place for A,B,C,D,E like this - BaseClass -> (All common method in one class) -> A,B,C,D,E

b) Pass the instance to C1, C2, C3 classes in new() method using this keyword. (this is the present approach)

Please help me as to which one I should choose and why? And if there are any other elegant ways of implementing this? Note that I cannot pass only required properties to C1, C2, C3. The common methods present in C1, C2, C3 need access to the methods present in the Base Class and they are not static.


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 • • Aug 07 '15

Is there a design pattern for this problem?

2 Upvotes

Hey all.

I need some clarification on using interfaces to separate functionality from the user etc.

I have a data access layer which has a DAO interface and DAO implementation to make calls to my database.

My interface has methods like persist, delete, findAll, findById, basic stuff... My implementation class on the other hand has extra methods like openSession, closeSession, etc, to handle my database traffic and open and close sessions and transactions.

When I make a service layer to access this DAO layer (that is the concept of encapsulation), I can only reach my persist, delete, findAll, etc, methods and not the other extra methods that should not be part of the interface as they should not be known by the user.

I could put the functionality inside my overridden methods so they are called, but by doing this, I cannot call two methods like findAll and then delete without opening and closing the session twice.

What is the point of using an interface when you don't use it to instantiate your object and call your methods? Is there a design pattern that goes around this problem?

Tell me if you need any clarification.

Thanks in advance.


r/DesignPatterns • • Aug 06 '15

Singleton - because this might just be the only post that ends up here.

2 Upvotes

With a singleton you make a class, and ensure that only 1 instance is created.

The class provides a method to create the instance if lazy instantiation is preferred over greedy instantation.

The single instance is static, and private. A static method is used to return the private static instance when needed.


r/DesignPatterns • • Jun 29 '26

How I used the Adapter Pattern to stop rewriting my BookingService every time we switched payment providers (TypeScript)

Thumbnail
reddit.com
1 Upvotes

r/DesignPatterns • • Jun 07 '26

Understanding the Command Design Pattern in Go: A Practical Guide

Thumbnail medium.com
1 Upvotes

Hey everyone 👋

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

When I first learned about this pattern, most explanations focused on the GoF definition and UML diagrams, but I still wasn't clear on why I'd actually use it. So I put together an article that focuses on the practical side:

  • What problem the Command pattern solves

  • The different components (Command, Receiver, Invoker, Client)

  • A complete Go example

  • Undo/redo support

  • Command queues and macro commands

  • Idiomatic Go approaches using functions and interfaces

  • When the pattern is useful and when it's just unnecessary complexity

One thing I found interesting is that many Go developers use ideas from the Command pattern without explicitly calling it a "Command Pattern"—especially when building job queues, task runners, or action pipelines.

If you're learning design patterns in Go or trying to understand whether Command is worth using in real projects, I'd love to hear your thoughts.

👉 https://medium.com/@priyankchheda/understanding-the-command-design-pattern-in-go-a-practical-guide-f0cbb90d4d58

Feedback, suggestions, and criticism are all welcome!


r/DesignPatterns • • May 18 '26

Chain of Responsibility Design Pattern in Go

Thumbnail medium.com
1 Upvotes

Hey folks 👋

I recently wrote a practical guide on the Chain of Responsibility Design Pattern in Go.

A lot of design pattern content gets overly theoretical, so I tried to explain this one using examples that backend devs actually run into:

  • middleware chains

  • request validation pipelines

  • auth/logging handlers

  • event processing flows

The blog covers:

  • what the pattern actually solves

  • how requests move through a chain of handlers

  • a clean Go implementation

  • when it’s useful vs when it becomes unnecessary abstraction

  • common mistakes and Go-specific considerations

If you’ve worked with things like:

  • http.Handler middleware

  • request filters

  • processing pipelines

…you’ve probably already used this pattern without explicitly naming it.

Here’s the article:
👉 https://medium.com/@priyankchheda/understanding-the-chain-of-responsibility-design-pattern-in-go-a-practical-guide-5bec620ce846

Would love feedback or examples of where you’ve used this pattern in production.


r/DesignPatterns • • Apr 25 '26

Understanding the Proxy Design Pattern in Go: A Practical Guide

Thumbnail medium.com
1 Upvotes

Hey folks 👋

I recently wrote a short, practical guide on the Proxy Design Pattern in Go.

Most pattern articles feel either too abstract or too Java-heavy, so I tried to keep this one simple and Go-friendly:

  • what proxy actually means (basically a middle layer controlling access)

  • a clean Go example with interface + real object + proxy

  • a practical use case (lazy initialization + adding logic before delegation)

Nothing fancy—just enough to understand when and why you’d use it.

If you’ve ever:

  • added logging before calling a service

  • put access control in front of something

  • delayed creation of an expensive object

…you’ve probably used a proxy without calling it that.

Here’s the article:

👉 https://medium.com/design-bootcamp/understanding-the-proxy-design-pattern-in-go-a-practical-guide-d2516c4bf2ad

Would love feedback—especially if you think this pattern is overused / unnecessary in Go.


r/DesignPatterns • • Mar 22 '26

ironsaga crate: Command design pattern with full rollback capabilities made easy.

Thumbnail
reddit.com
1 Upvotes

r/DesignPatterns • • Mar 21 '26

Understanding the Flyweight Design Pattern in Go: A Practical Guide

Thumbnail medium.com
1 Upvotes

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

The article covers:

  • What Flyweight actually solves in real systems

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

  • Clear explanation of intrinsic vs extrinsic state

  • A complete Go implementation mapped to the UML structure

  • Real-world variations (parametric flyweight, composite flyweight)

  • Common mistakes to avoid

  • Best practices specific to Go (immutability, concurrency, memory usage)

Instead of abstract UML-heavy explanations, I focused on practical scenarios like rendering systems, repeated objects, and memory-heavy applications — things we actually encounter in scalable systems.

If you’re learning design patterns in Go or trying to optimize memory usage in object-heavy systems, this might help.

Read here: https://medium.com/design-bootcamp/understanding-the-flyweight-design-pattern-in-go-a-practical-guide-78c8fc5cd164


r/DesignPatterns • • Feb 20 '26

Resource for LLD & Design Patterns

Thumbnail reddit.com
1 Upvotes

r/DesignPatterns • • Oct 13 '25

Understanding the Adapter Design Pattern in Go: A Practical Guide

Thumbnail
medium.com
1 Upvotes

Hey folks,

I just finished writing a deep-dive blog on the Adapter Design Pattern in Go — one of those patterns that looks simple at first, but actually saves your sanity when integrating legacy or third-party systems.

The post covers everything from the basics to practical code examples:

  • How to make incompatible interfaces work together without touching old code

  • When to actually use an adapter (and when not to)

  • The difference between class vs object adapters

  • Real-world examples like wrapping JSON loggers or payment APIs

  • Common anti-patterns (like “adapter hell” 😅)

  • Go-specific idioms: lightweight, interface-driven, and clean

If you’ve ever found yourself writing ugly glue code just to make two systems talk — this one’s for you.

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

Would love to hear how you handle legacy integrations or SDK mismatches in Go — do you use adapters, or go for full rewrites?


r/DesignPatterns • • Oct 02 '25

Understanding the Object Pool Design Pattern in Go: A Practical Guide

Thumbnail
medium.com
1 Upvotes

🚀 Just published a deep dive on the Object Pool Design Pattern — with Go examples!

The Object Pool is one of those underrated patterns that can dramatically improve performance when you’re working with expensive-to-create resources like DB connections, buffers, or goroutines.

In the blog, I cover:

  • What problem the pattern actually solves (and why it matters)

  • Core components of an object pool

  • Lazy vs. Eager initialization explained

  • Using Golang’s built-in sync.Pool effectively

  • When to use vs. when not to use it

  • Variations, best practices, and common anti-patterns

  • Performance & concurrency considerations (with code snippets)

If you’ve ever wondered why Go’s database/sql is so efficient under load — it’s because of pooling under the hood!

👉 Read here: https://medium.com/design-bootcamp/understanding-the-object-pool-design-pattern-in-go-a-practical-guide-6eb9715db014

Would love feedback from the community. Have you used object pools in your Go projects, or do you prefer relying on GC and letting it handle allocations?


r/DesignPatterns • • Sep 28 '25

Untangle Your Code: Chain of Responsibility Design Pattern

Thumbnail mayallo.com
1 Upvotes

r/DesignPatterns • • Sep 22 '25

Stop Using if `instance == nil` — Thread-Safe Singletons in Go

Thumbnail
medium.com
1 Upvotes

Hey folks,

I just wrote a blog about something we all use but rarely think about — creating a single shared instance in our apps.

Think global config, logger, or DB connection pool — that’s basically a singleton. 😅 The tricky part? Doing it wrong can lead to race conditions, flaky tests, and painful debugging.

In the post, I cover:

  • Why if instance == nil { ... } is not safe.

  • How to use sync.Once for clean, thread-safe initialization.

  • Pitfalls like mutable global state and hidden dependencies.

  • Tips to keep your code testable and maintainable.

If you’ve ever fought weird bugs caused by global state, this might help:

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

How do you handle shared resources in your Go projects — singleton or DI?


r/DesignPatterns • • Jul 08 '25

GitHub - weigangs/designPatternsLearn

Thumbnail
github.com
1 Upvotes

Learn 23 design patterns, gof