Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Everything / patterns

Patterns

patterns

Great Reads

by Akhil Mittal
Repository pattern in MVC3 application with entity framework
by Giovanni Scerra
The following guidelines are not exhaustive and are meant to be applied on top of the SOLID principles and proper use of OO Design Patterns.
by Rahul Rajat Singh
In this article we will try to understand the service locator pattern.

Latest Articles

by Akhil Mittal
Repository pattern in MVC3 application with entity framework
by Giovanni Scerra
The following guidelines are not exhaustive and are meant to be applied on top of the SOLID principles and proper use of OO Design Patterns.
by Rahul Rajat Singh
In this article we will try to understand the service locator pattern.

All Articles

Sort by Score

patterns 

by Priyanka Sabharwal81
Adapter Design Pattern in C++
by Yossi Yaari
A basic yet generic state machine implementation
by Jitendra Ballia
Building data access layer using enterprise library
by omid rezaei hanjani
Customized implementation of the Observer pattern using Generics.
by omid rezaei hanjani
Customized implementation of the Singleton pattern using Generics.
by Paulo Zemek
All classes are naturally Lazy loaded.So a better implementation will be:public class Singletonwhere T: new(){ public static readonly T Instance = new T();}You will notice that before calling the singleton class, the object will not be loaded.Surely there are...
by Kevan Hadvani
This is my humble effort to explain so called complex Design Patterns to explain as simply as possible
by Jaume González
To inherit an Entity Framework class, to extend it, bind to data and unmap it from DBContext.
by AndyLock
Dynamic, one class fits all factory with no need for specific implementations.
by Bankey Sharma
Converting DataReader Result into List of Objects Using Generic Type, Property Attribute and Reflection
by Viktor Kovács
A simple solution for processing spaceless strings
by Artem Elkin
Thoughts of how implementation inheritance violates Dependency Injection and Dependency Inversion principles.
by A. Ganzer
Using snippets to create a full and correct implementation of complex interfaces
by MadhureshK
Interface Segregation Principle - Walk through History
by Pierre Leclercq
How to implement the master page pattern in WPF?
by Marc Leger
ORM, databinding, asynchronous data access, and transactions
by Marc Leger
Microsoft ASP.NET Identity MerlinFramework
by arturomonriv
No more factories in C#.
by Veronica S. Zotali
Real example that shows how to implement Observer pattern using IObservable and IObserver
by Chris_Yu
Why and When to Use the Adapter Pattern in PHP Development
by Pankaj Nikam
PRG or Post Redirect Get pattern focuses on solving the typical problem where the user presses F5 or refresh button and causes duplicate database transactions.
by AllCodify
A Pub/Sub implementation that is PCL compatible for Xamarin iOS and Android
by Rafael Nicoletti
Refactor C# code to become more expressive
by Shashank Bisen
A brief explaination of how to implement the Singleton pattern class in multithreading environment.
by Paulo Zemek
The easiest singleton pattern is the one you used to the lock object itself.Creating any variable as static readonly and initializing it directly (or via a static constructor) will already make it singleton.Also, considering that "lock" clears all the caches, you don't need to declare the...
by schamese
This should do it as well:class Singleton { public static readonly Singleton m_Instance = new Singleton(); // Prevent instance creation from other classes private Singleton() { } public static Singleton Instance { get { return m_Instance; } }}And it is "Singleton",...
by ForgaSw
Another alternative: class Singleton { public static Singleton m_Instance; //Prevent instance creation from other classes private Singleton() { } public static Singleton Instance { get { return m_Instance ?? (m_Instance = new Singleton()); } ...
by Paulo Zemek
The problem with alternative 3 and 4 is that it is not multi-threaded.Two threads may check for null, then the two will create the new instance. The race condition only happens at the first accesses. If a single thread accesses the object, then later many threads do the access, there is no...
by Kabwla.Phone
Make it a generic class and fix your problem forever. This works because the compiler turns the generic into a new class (something like SigletonManagerOfTypeParamterTypeName). So the static variables are not shared amongst instances...public static class Singleton where...
by Eddy Vluggen
I'll be shot for posting this as an alternative, but I'm too curious for the answer.Shashank Bisen wrote: Ensure a class only has one instance.Provide a global point of access to it....As stated above, a singleton is a class that can be instantiated once, and only once.What is the...
by Henry.Ayoola
Jon Skeet has written an article giving six singleton implementations in C#. The simplest only works in .NET 4:public sealed class Singleton{ private static readonly Lazy lazy = new Lazy(() => new Singleton()); public static Singleton Instance {...
by jamesklett
You should do it like this:public sealed class MySingleton { public static readonly MySingleton SharedInstance = new MySingleton (); private MySingleton () : base() { }}
by Atulkumar P Patel
Anti Patterns are wrong practice followed by Developers. They are opposite to Design Patterns.
by Troy W. Locke
The JavaScript Module Pattern used with jQuery
by Niel M.Thomas
A small tip to retry an action, with an easy to use extension.