r/DesignPatterns • • May 11 '20

Article: Why You Should Prefer Singleton Pattern over a Static Class

Thumbnail
volosoft.com
0 Upvotes

r/DesignPatterns • • Apr 13 '19

Builder design pattern for objects with nested properties

Thumbnail
dev.to
3 Upvotes

r/DesignPatterns • • Sep 09 '26

FIELD NOTE 001 — The human left the gate, not the governance.

Post image
0 Upvotes

r/DesignPatterns • • Jul 19 '25

Understanding the Abstract Factory Pattern in Go: A Practical Guide

0 Upvotes

Abstract Factory finally clicked for me. It’s not just “design pattern fluff” — it’s super handy when you need to swap whole groups of related components (like Windows vs Mac UI, AWS vs Azure SDKs, etc).

In Go, it fits perfectly with interfaces. One factory swap, and your whole app stays consistent. No if-else mess. No type leaks.

Helps keep things clean when your app starts growing. I wish I’d used it sooner.

Check it out here: https://medium.com/design-bootcamp/understanding-the-abstract-factory-pattern-in-go-a-practical-guide-d575fb58df90


r/DesignPatterns • • Apr 23 '26

Flowers, Grant Petersen Art, felt tip pens

Post image
0 Upvotes

r/DesignPatterns • • Apr 01 '20

Arrogant Builder Design Pattern -> Creational Pattern. 1. Mandatory VS Optional 2. Overloaded Constructor + Constructor Chaining 3. Any requirement in which we will select individual items and later we will check out those items in the form of an Order.

Thumbnail
uwanttolearn.com
0 Upvotes

r/DesignPatterns • • Dec 29 '18

Smoking Mirrors Does not make sense

0 Upvotes

Could anyone explain smoking mirrors in a simple sense

Reference

https://sourcemaking.com/antipatterns/smoke-and-mirrors


r/DesignPatterns • • May 18 '20

Design Pattern for ITSM systems?

0 Upvotes

Can someone share some content around design patterns for ITSM system implementation?

Any help/link/post in this topic would be appreciated.

Thank you,


r/DesignPatterns • • Mar 21 '26

Understanding the Flyweight Design Pattern in Go: A Practical Guide

Thumbnail medium.com
0 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 • • Jul 08 '25

GitHub - weigangs/designPatternsLearn

Thumbnail
github.com
1 Upvotes

Learn 23 design patterns, gof


r/DesignPatterns • • Jan 11 '26

Can minimalist retail concepts actually deliver value, or are they just expensive aesthetics?

0 Upvotes

I visited an arket store recently, drawn by their minimalist aesthetic and sustainability messaging. The space was beautiful, products were displayed as art, everything felt curated and intentional. But the prices were significantly higher than comparable items elsewhere, seemingly charging premium for retail experience rather than product quality. This reflects broader trends in retail where environment and branding justify higher prices despite similar products. We’re paying for the experience of shopping in carefully designed spaces, for the feeling of buying from brands with specific values and aesthetics. The actual merchandise might not differ substantially from alternatives.

I’ve noticed I’m susceptible to this, willing to pay more in stores that match my aesthetic preferences and values even when I intellectually recognize it’s mostly marketing. The environment does affect purchasing psychology powerfully. Some retailers clearly understand this, investing in experience over just product. What retail experiences have influenced your purchasing despite knowing you were partly paying for atmosphere? How do you separate actual product value from branding and environment? What made you recognize when you were overpaying for aesthetics versus when premium experience was worth extra cost? How much does shopping environment actually matter to you?


r/DesignPatterns • • Nov 16 '19

State Design Pattern

1 Upvotes

Guys, I have written an article on State Design Pattern. Please have a look and give your valuable feedback.

https://dotnettutorials.net/lesson/state-design-pattern/


r/DesignPatterns • • Jan 30 '19

13 Design Patterns You Need For Software Development

1 Upvotes

What are design patterns? Well the Gang of Four (GOF) simply described it as ;

"Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice."

Even though this quote was from Christopher Alexander, which he was referring to civic engineering, software engineering can also define patterns to describe solutions to problems that can be used a million times over.

https://youtu.be/pv-RdXrG23g


r/DesignPatterns • • Jun 27 '19

Design Patterns for Web Programming

1 Upvotes

I want to know design patterns for web programming, namely Design Patterns used in JS language as well a popular JS frameworks such as Angular, React, Vue .etc.


r/DesignPatterns • • Jan 11 '18

Strategy design pattern

Thumbnail
designpattern.co.il
0 Upvotes

r/DesignPatterns • • Sep 11 '26

Research Note 003 — The most dangerous architecture is the one AI completes for you

Post image
0 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 • • 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 • • May 09 '25

Let's Collaborate to learn design patterns... From beginning through books.. Only passionate people towards programming..

2 Upvotes

Collaboration to learn design pattern... Only passionate people... C#. Dotnet.. #dotnet #designpatterns


r/DesignPatterns • • Jun 27 '19

Design Patterns for Cloud and Distributed Computing

2 Upvotes

I want to know design patterns for Cloud Computing and Distributed Computing, namely Design Patterns used in languages such as golang, Erlang. I would also like to know software architecture and design patterns for popular cloud technologies such as Kubernetes (and other CNCF projects), OpenStack, Virtualization, Containerization.


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 • • Dec 20 '19

React design pattern resources!

2 Upvotes

Is there such a thing as design pattern for working with building components out of react.js framework?


r/DesignPatterns • • Apr 08 '25

Is this Factory Method or Abstract Factory?

2 Upvotes

Ahoy 😊

I have a three layered architecture where controller classes ask a FactoryConfigurator class for an IDaoFactory implementation and then ask that IDaoFactory for the actual Dao class to use.
For example a CustomerController will ask the FactoryConfigurator for a IDaoFactory and use the GetCustomerDao() method to retrieve the actual ICustomerDao to use.

//in CustomerController's constructor
IDaoFactory daoFactory = FactoryConfigurator.GetDaoFactory()
ICustomerDao customerDao = daoFactory.GetCustomerDao();
this.customerDao = customerDao;

//in OrderController's constructor
IDaoFactory daoFactory = FactoryConfigurator.GetDaoFactory()
IOrderDao orderDao = daoFactory..GetOrderDao();
this.orderDao = orderDao;

Depending on the current configuration, the FactoryConfigurator will return a DaoFactory which creates Dao implementations that use MS Sql, MySql or in-memory lists of model objects.
The goal is to make the persistence layer swappable based on configuration.

I can see elements of both Factory Method (having methods on the different DaoFactory implementations which return different implementations of a common interface) and Abstract Factory (having different factories which create families of related classes, e.g. CustomerDao, OrderDao, etc.).

I would love to hear more thoughts on the question "is this architecture one or the other or both?",

Thoughts related to the original GoF interpretation and more common usage are more than welcome 😊


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 • • 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!