Click here to Skip to main content
15,868,141 members
Everything / Design patterns

Design patterns

design-patterns

Great Reads

by PureNsanity
Fundamental aspects of software design and understanding individual elements of principles and patterns
by Habibur Rony
This will cover how to use Domain Driven Design in your application according to the Onion Architecture. There are short descriptions about architecture Category / Style, N-Layer / N-Tier Architecture, Template Method Pattern and Facade Design Pattern.
by Thoits
A design pattern for C# that reuses a generic base class, modifying it using a traits class to allow changes that cannot be accomplished through overrides in an inherited class.
by Jung Hyun, Nam
Introducing NConcern, a free open source compile-time AOP framework

Latest Articles

by Dev Leader
Learn about the pipeline design pattern in C#, discover how to create and chain pipeline stages and get code examples, tips, and use cases for this design pattern
by Dev Leader
Origin and principles of Memento Pattern in C, and different components & steps to implementation!
by Dev Leader
Integrate Unit of Work Pattern in C# with Clean Architecture for efficient programming, benefits and C# code examples
by Dev Leader
Check out these examples of the observer pattern in C#! Learn how the observer pattern in C# can simplify the usage of events in your next project!

All Articles

Sort by Score

Design patterns 

28 Feb 2017 by PureNsanity
Fundamental aspects of software design and understanding individual elements of principles and patterns
5 May 2017 by Habibur Rony
This will cover how to use Domain Driven Design in your application according to the Onion Architecture. There are short descriptions about architecture Category / Style, N-Layer / N-Tier Architecture, Template Method Pattern and Facade Design Pattern.
15 Apr 2021 by Thoits
A design pattern for C# that reuses a generic base class, modifying it using a traits class to allow changes that cannot be accomplished through overrides in an inherited class.
7 May 2017 by Jung Hyun, Nam
Introducing NConcern, a free open source compile-time AOP framework
29 Aug 2022 by Aleksandr Ulanov
What are Service Objects and how you can use them to make your app cleaner and keep it maintainable
18 May 2017 by Jon Campbell
How to utilize WCF to allow a single instance of any WPF application without needing mutexes, extra assemblies, or special "hacks".
14 Feb 2019 by Rajesh Pillai
Understand Node internals by coding your own tiny implementation of built-in node.js event emitter from scratch.
25 Jan 2018 by Nazar.Bukhari
An article on how to implement Observer Design pattern in Mutithreaded Java application when Function pointer is needed
6 Sep 2018 by Toby Steed
Design pattern - Factory
21 Nov 2018 by Yisrael Lax
Why poorly written code is expensive code
22 Mar 2019 by David_Wimbley
The only reason I would create a shared base class for NonDeterministicFunction is if there is logic that would/could be shared across all implementations of these non deterministic functions. You can still use your abstract class as the base class as an option as well. Personally, what you've...
28 Jul 2020 by Mirambek Nagashbekov
Demonstration of filter pattern along with pipeline on data driven application
29 Jul 2023 by Glenn Viroux
An overview of a couple of useful design patterns with examples in modern Python
22 Nov 2023 by Dev Leader
Check out these examples of the observer pattern in C#! Learn how the observer pattern in C# can simplify the usage of events in your next project!
21 Sep 2017 by RickZeeland
Here is a tutorial, not sure if it is up to date: Website Designing[^] This looks interesting too: [Gravit] If you are looking for something simple the try Crello Crello Is a Graphic Design Tool for Everyone with a Collection of 6,000+ Free Templates[^] Wix seems interesting too: Wix Review...
21 Sep 2017 by Richard Deeming
Adobe have a handy tool for generating colour palettes: Adobe Color CC[^] Several useful CSS generators here, including colour gradients and box shadows: The ultimate CSS tools for web designers | CSSmatic[^] Google Fonts[^] is a good place to find fonts for your site. CC Search[^] is a good...
10 Feb 2018 by Dave Kreskowiak
It says that because you don't have either an appropriate architecture of Office installed or Access Runtime[^] installed on the machine. If your app is compiled AnyCPU and running on a 64-bit machine, you'd have to use the 64-bit Office or Runtime. If your app is compiled AnyCPU and running...
6 Apr 2018 by RickZeeland
Here is an interesting article to get you started, it discusses things like "three tier" architecture: Learn C# Design patterns step by step with a project – Part 1[^] Here is an article about the Provider pattern: Provider Pattern for Beginners[^] And some info about Services patterns:...
12 Nov 2018 by Vincent Maverick Durano
Normally for new members and not enough reputation points, articles will go into a moderation queue where authorize members can review. approve or decline your submission. You should be able to get email notifications when either of those actions happens. For the time being, you can see all...
21 Nov 2018 by OriginalGriff
Well no - children is a collection of ChildRole objects, and you are trying to assign (what looks like) an instance of a single role to it - that won't work. Did you mean to say children.Add(child); If not, then you need to look at exactly what type a child is - we can't tell from here!
7 Apr 2022 by CHill60
I'm with @Richard-Deeming - the nullable foreign key seems like the best option Quote: it would be possible to create an event linked to a session and give it a timestamp that is not between the start and end timestamps of the associated...
15 Feb 2024 by Dev Leader
Integrate Unit of Work Pattern in C# with Clean Architecture for efficient programming, benefits and C# code examples
15 Feb 2024 by Dev Leader
Origin and principles of Memento Pattern in C, and different components & steps to implementation!
7 Dec 2016 by Er. Dinesh Sharma
Hi Experts,Please help me to find the proper way to remove the switch statement when a Interface is implement by number of classes.e.gpublic enum TestClass { Test1, Test2, Test3, Test4 } public interface ITest { void...
7 Dec 2016 by Midi_Mick
I'd be tempted to remove the enumeration altogether, and use generics.public class Test where T: ITest, new() { public ITest GetObject() { return new T(); }}or, if it suits your style a bit better, take the generic away from the class Test, and just apply it to the...
7 Dec 2016 by Richard MacCutchan
If you have too many buttons on the display then the chances are that the design is going to confuse your users. Why do you need multiple button classes, why not one class that contains all the logic for a button?
25 Feb 2017 by Graeme_Grant
Job Interview? Study interview? If it is a job interview and someone else does it for you, they'll quickly cotton on.Time to get a book or start researching online. There are many different design pattern out there, each having a specific purpose. Here is a good starting point: c# design...
25 Feb 2017 by Patrice T
Quote:In one of my final round Interview, Interviewer ask me to design using design pattern for this problem.This is to test your knowledge, not your ability to beg others to do your work !If we answer for you, are we getting the job ?May be it is time to sharpen your skills and study...
25 Feb 2017 by Richard MacCutchan
See design patterns - Google Search[^].
8 Jun 2017 by Patrice T
Quote: I am new in working on project where I need to design Container storage yard software in vb.net. I searched a lot but did not found any source through which i can get some motivation, the only thing I found was design screen shots of other software but did not found any usefull info which...
23 Jan 2018 by Ammar Shaukat
I'm working on a software where software issues commands for hardware panel and once a command is issued, its response received after few seconds . there are different functions for different hardware commands like public void FunctionA() { StartCommandA(); } and other functions on the...
23 Jan 2018 by johannesnestler
have a look at the Task class Task Class (System.Threading.Tasks)[^] and to the ContinueWith methods. This is what you want: call methods each in it's own Task (thread) - wait for method to execute while not blocking the rest of your app. After executing continue with next method call (in it's...
23 Jan 2018 by Ammar Shaukat
Make a list of Action Delegates and add Status Code for each function . let's say 0 mean function has invoked and 1 mean function is not invoked yet. then use LINQ Query to check which function has called and which one is remaining. Change the status of function invocation from OnReponse ...
10 Feb 2018 by abboudi_ammar
I am a beginner at MVVM design patter and WPF I am trying to make a small example of connection to the MS Access database using the WPF and MVVM Light Toolkit patter design. but when i run the program it does not do anything and when i debug i find that the instruction stops at the instruction...
15 Feb 2018 by User98743
I'm struggling to understand how to implement principles of encapsulation, inheritance and polymorphism to break this code into logical parts. My background is in VBS/Classic ASP and database development, not OOP. I'm not asking anyone to write the code, but rather to point me in the right...
14 Feb 2018 by #realJSOP
Inheritance (C# Programming Guide) | Microsoft Docs[^]
15 Feb 2018 by Afzaal Ahmad Zeeshan
Apart from what Solution 1 has, I would also recommend keeping all the classes separate in their own specific files. Other than that, this can be easily converted to two separate classes; database connection management, database connection helpers (check if file or DBMS etc.). But that has to...
6 Apr 2018 by Jefferson Vargas Nilo
Hi guys I'm little bit confuse with provider and service i saw some putting there CRUD in providers and services folder/class. What is the difference with provider and services? Thanks in advance guys :) What I have tried: I tried putting database CRUD in services folder/class like...
17 Jul 2018 by saurabh.15in
Hi, I have a class which have certain functionality and return type is "A" (just an assumption) I need to create few class which will just use the data "A", making some customization and return it in different format. (Say, classB return "Type B" and class C return "Type C". Both the Type B and...
17 Jul 2018 by Gerry Schmitz
Use the "component strategy / pattern" (or whatever): Public Class A { ... } Public Class B { public A ClassA {get;set;} ... } Public Class C { public A ClassA {get;set;} ... }
12 Nov 2018 by Shokouhi Shervin
I write my first article and publish it several hours ago, I reviewed it and then decided to complete my personal information as professional profile. Now, my article has been gone?!! why?? and how can I bring it back? It was my first ever Article :( What I have tried: I check my articles but...
21 Nov 2018 by F-ES Sitecore
sub.Select(role=>new RoleAccess { id = parent.Id, name = parent.Description, children=child }); "children" is a list and you're trying to assign it a single item. What you need to do is make a list with a single item in...
23 Nov 2018 by Richard Deeming
Try something like this: public List SubRole() { return Roles .Where(parent => parent.RoleLevel == 0) .AsEnumerable() .Select(parent => new RoleAccess { Id = parent.Id, Name = parent.Description, children =...
10 Dec 2018 by OriginalGriff
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action. Try it yourself, you may find it is...
21 Dec 2018 by omgdog
Let’s assume a UI where currently we show students details on tiles. One tile per student. Now we need to refactor our code to support a new requirement. The new requirement is to change the order of those tiles based on different kind of sorting like – sort by student’s names, sort by student’s...
21 Dec 2018 by RickZeeland
You could use a framework like Knockout JS, which will make your code a lot cleaner. Knockout offers Observable Arrays which can be sorted and manipulated in other ways, read about it here: Knockout : Observable Arrays[^]. Of course there are other frameworks, here is an overview:...
24 Dec 2018 by omgdog
I have a UI where I show a list of features in a dropwdown. Based on user selection from the dropdown, I render the feature. On landing I keep that dropdown disabled until I receive some data from ajax call. So this is the flow - * User lands on the page, dropdown for selecting features is...
22 Mar 2019 by NickResh777
Suppose, I have the base abstract class Function that looks like this: public abstract class Function { public abstract string Invoke(string[] args); } And also I have a child sub-class DeterministicFunction that looks like this: public abstract class...
2 Sep 2019 by SSP0055
Language: c# Tool: VS2017 I create a complaint view for the user and now I want to notify the user with email. And this notification, I want to do it by design pattern way. But I don't know which pattern is useful to notify the user. Also, I have another service which is sms service. Any...
2 Sep 2019 by phil.o
A design pattern is a construction (a tool) which aims at solving a specific issue/requirement. You choose a design pattern because it solves the issue/requirement, not the other way around. Saying "I want to use a design pattern" is a misconception of what a design pattern is. That would be...
28 May 2020 by Aswin Francis
I have an existing C# console application that takes arguments and based on the arguments creates an instance of markets (UK, US, MX..) using dependency injection. Each market class does a 'string GetData()', 'string ProcessData()' and 'bool...
28 May 2020 by RickZeeland
You can find a nice overview with examples here: .NET Design Patterns in C# and VB.NET - Gang of Four (GOF) - doFactory.com[^]
5 Jun 2020 by Richard MacCutchan
There is no best way. You use design patterns to resolve issues in the design of your project. So you need to start with the project and then decide where and what design patterns will make the development easiest.
23 Jun 2020 by m.bleimuth
i am searching the web now for a while without real success. Lets assume following simple model, which i get from a webservice. public class A { public int Id { get; set; } public ObservableCollection Bs { get; set; } public A () {...
13 Nov 2020 by Richard MacCutchan
You already posted this in the Web Development forum at Design question with asp.net core and asp.net core api - Web Development Discussion Boards[^]. Please do not crosspost.
10 Dec 2020 by khalid4775
I have MVP project I am trying to display the selected row to 3 textboxs and 1 checkbox : I know I can do it from the CellClick event like so: private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { int index =...
10 Dec 2020 by Richard Deeming
Taking the errors one at a time: The name 'e' does not exist in the current context. Would not happen in the GetDataToTextBox method shown, since e is a parameter to the method. 'object' does not contain a definition for 'Rows' The...
10 Dec 2020 by khalid4775
Thanks For Help Errors removed after fixing the code to be like so : public void GetDataToTextBox(DataGridViewCellEventArgs e) { int index = e.RowIndex;// get the Row Index DataGridViewRow selectedRow =...
24 Feb 2021 by code4Better
Hello All, My requirement is to send diff actions to vendor through rest API (actions will be for ex: simple notes, some docs etc through xml payload). I will have to support unit testing (so logic should be decoupled from UI) for all the...
24 Feb 2021 by RickZeeland
Take a look at the Factory Pattern, it is discussed here: Design Pattern - Overview - Tutorialspoint[^] And here is a C# example: C# Design Patterns - Factory Method - Code Maze[^]
30 May 2021 by Richard MacCutchan
Onion architecture - Google Search[^]
28 Jun 2021 by Greg Utas
It's difficult to answer given the brevity of your question. I wouldn't call a session a design pattern. It could be called a protocol pattern, but it's not a software pattern in the usual sense of the term. As a protocol pattern, it consists of...
3 Apr 2022 by Member 15589097
Im trying since a couple of weeks to create a chain of WebSockets clients, to form a middleware pattern. Like in express/connect where you call `app.use(() => {...})` but with WebSocket clients. Illustration about the data/events flow:...
7 Apr 2022 by Gianluca Locri
I have a question is about good database design. In my current project I have a SQL database with two tables. A sessions table containing: - session id: the primary key - login timestamp: the unix timestamp of the start of the session - logout...
15 Jul 2022 by Akshay malvankar
I just want to use a singleton design pattern in my asp.net MVC project, I don't know where and in which case is more suitable to used can anyone give me 1 or 2 examples where I can used a singleton design pattern in my project with an example ...
15 Jul 2022 by Richard MacCutchan
You are trying to work it the wrong way round. You need to examine your design to see where a singleton pattern might be useful, not try to fit the design to the pattern. See Singleton pattern - Wikipedia[^].
17 Aug 2022 by CCT TestPSQA
We presently use Automation Framework with MStest and Selenium C# POM framework for the e-commerce domain in our organization. Currently, organizations are moving toward an AB testing strategy for a few pages. Therefore, I am unsure of the...
21 Sep 2017 by Member 13422476
Hello there, i need help. Im not great web designer, and i need help from you. So, i need help about color picking and image picking etc. Btw. all what can help me to finish this project. I have a concept in my head, now you can see how looks website for my think this, but i have problem to...
15 Feb 2024 by Dev Leader
Learn about the pipeline design pattern in C#, discover how to create and chain pipeline stages and get code examples, tips, and use cases for this design pattern
16 Mar 2017 by Hamidreza Ebtehaj
Designing the simplest function evaluator
16 Apr 2018 by Valerii Tereshchenko
Example of implementing logging using Aspect Oriented approach with DispatchProxy class
28 Apr 2017 by Ganesh Prabu
Simple design idea to use Task class and implement batch processing of requests
17 Mar 2022 by Greg Utas
Are we about to go over a cliff?
9 Aug 2022 by Mark Pelf
We explain DI Pattern, DIP, IoC, DI Container
17 Jan 2021 by Tomas Takac
How to implement your retry strategy in an object-oriented way
10 Jun 2019 by Viral Surani
This article is a first article of a series called Keep It Simple. This article is about how we can create reusable component of partially common operation (method) using Strategy Design Pattern. We will see the need of Strategy Design Pattern.
23 Jan 2017 by OriginalGriff
We do not do your homework - and interview questions are homework, of a kind. If we give you the answer (if there was an answer, what you ask involves no patterns as it has no real question in it) then that would give you an advantage over those who know their subject and deserve the job. That...
24 Apr 2017 by Habibur Rony
This topic will cover the bad design practice using STUPID and good design practice using SOLID. Detailed explanation for Single Single Responsibility Principle, Open and Closed Principle, Liskov Substitution Principle, Interface Segregation Principle and Dependency Inversion (DI) Principle.
15 Oct 2017 by Vinayak Hegde (Vinnie)
JavaScript Design patterns - The Constructor Pattern
10 Apr 2020 by Surajit T. Karmakar
This article demonstrates usage of Decorator pattern in C# with a practical software programming example.
4 Sep 2019 by Lộc Nguyễn
Revisiting Event Aggregator/Message Bus/Broker in C#.NET
18 Jan 2013 by Mohammad Ashraful Alam
Design patterns for Model
14 May 2017 by Habibur Rony
Application design - a post mortem of a bad design
27 Feb 2017 by Ramachandran Murugan
"A Creation Design Pattern which is used to duplicate or clone the resource and time consuming expensive object"
3 Feb 2019 by Vahid Asbaghi
This tip describes one of the beneficial design patterns that is named Multiton. Multiton pattern is used when we want to have a singleton instance of our class for each key.
3 Sep 2019 by Nilendra Nath
To get the solution of notifications, You can choose Strategy pattern or Observer. Observer will keep your solution loosely coupled and provide a way to automatically notify to subscriber. Whereas using Strategy pattern you can define notification strategy based on context ie email in you case....
26 Feb 2017 by Vijai Anand.G
Hi All,I am a newbie in Design Patterns.Let’s assume that we have an N number of flat files inside the directory. Let the flat files having comma separated information and consider the first line will be column information that is improperly ordered and next lines will be row...
28 Jun 2021 by Ishmeet Kaur
I Have got two answers for the internet Singleton and Factory design pattern? Which should we use? Both of them? and Why? What I have tried: I Have got two answers for the internet Singleton and Factory design pattern?
7 Dec 2016 by Member 12701313- questforimprovement
I have a project design that uses Java Swing for the GUI part of the application and it consists of multiple button classes that corresponds to each button on the main GUI. Is it useful to have so many button classes? What are the advantages of this approach? Are there alternative ways I can...
23 Jan 2017 by Member 12775576
I attended an interview and got the following question:which design patterns is used from unix shell for created an command like:What I have tried:ls -l * | cut -f1,2 | sortwhich is the correct answer?
8 Jun 2017 by Member 10977208
Hello Experts, I am new in working on project where I need to design Container storage yard software in vb.net. I searched a lot but did not found any source through which i can get some motivation, the only thing I found was design screen shots of other software but did not found any usefull...
30 Sep 2018 by Lokesh Zende
Hi, I recently switched to a new company where my manager wants me to develop entirely new cloud based project in MVC. I have never worked on a project from the start and I think this is a good opportunity for me to lead. However, I think the requirements of the clients are bit confusing. Here...
23 Nov 2018 by kia9372
hi. this my modelview . public class RoleAccess { public int id { get; set; } public string name { get; set; } public List children { get; set; } } and this is ChildRole : public class ChildRole { public int id { get; set;...
5 Jun 2020 by Coder969
I have gone through some online course to learn design pattern. What is the best way to start applying in real projects. What I have tried: Searched online but didnt find best ways
14 Sep 2022 by Akshay malvankar
Can anyone explain me what is advantage of writing some logic in Class Library file (.BLL) then writing same logic in model class in asp.net MVC. What is advantage of using class library file (.BLL) in asp.net MVC project Please explain with...