Learn it from developers who built it.
Tutorials, how-tos and deep dives on AI, .NET, C#, cloud and developer tools, written by the community.
Learn how composition over inheritance helps build flexible, maintainable C# applications, with examples that compare composable components and inheritance hierarchies.
Master Dependency Injection (DI) and Inversion of Control (IoC) in C#! Learn to write flexible, testable, and maintainable code with practical examples and best practices.
Master the Interface Segregation Principle (ISP) in C#! Learn to design lean, focused interfaces by avoiding bloated, general-purpose ones. This article provides practical C# examples demonstrating how to refactor fat interfaces into purpose-specific contracts. Improve code maintainability, testability, and flexibility by adhering to ISP. Discover common violations and refactoring techniques for cleaner, more decoupled code. Explore real-world scenarios like worker management, printer functionalities, and repository patterns.
Master the Open/Closed Principle (OCP) in C#! Learn how to design extensible software that welcomes new features without modifying existing, tested code. Explore practical examples using interfaces, abstract classes, and polymorphism to refactor rigid if-else structures into flexible architectures. Prevent breaking changes and improve maintainability by adhering to OCP. Discover how the Strategy pattern and dependency injection enhance OCP implementation.
Unlock the power of clean code with the Single Responsibility Principle (SRP) in C#! This article provides a practical guide to understanding and applying SRP, the cornerstone of SOLID principles. Learn to identify and refactor classes with multiple responsibilities into focused, maintainable components. Real-world C# examples demonstrate how to transform messy code into testable, understandable, and easily modified solutions, reducing bugs and improving code quality.
Unlock the secrets to robust and maintainable C# code with the SOLID principles! This article introduces the five fundamental design guidelines (SRP, OCP, LSP, ISP, DIP) that every C# developer should master. Learn how SOLID principles work together to create scalable, flexible applications, reduce technical debt, and improve team collaboration. Prepare for a deep dive into each principle with practical examples and refactoring techniques in this series.
This article provides a comprehensive guide, explaining when and how to use this creational design pattern to simplify complex object construction. Explore classic and fluent builder implementations, complete with code snippets for building a house and a person. Learn to avoid telescoping constructors, improve code readability, and encapsulate construction logic for robust and maintainable C# applications.
Master the Saga Design Pattern (Choreography style) with this cheat sheet! Learn how to implement distributed transactions using event-driven architecture. Explore the benefits of loose coupling and decentralized control in microservices. Includes a C# example demonstrating an order workflow with compensating transactions for rollbacks. Ideal for interviews and real-world applications like food delivery apps.
Master the Orchestration Saga pattern for microservices! This cheat sheet explains how to maintain data consistency across distributed systems without 2PC. Learn to break down long transactions into smaller, manageable steps with compensating actions for rollbacks. Includes a C# example and real-world flight booking scenario. Ace your next interview by understanding the 'do + undo' principle and the difference between Orchestration and Choreography Sagas.
Explore the nuances between Static Classes and the Singleton Pattern in C#. This article provides a detailed comparison, covering memory usage, performance, inheritance, thread safety, testing, and practical use cases. Learn when to choose a static class for utility functions or a singleton for managing shared resources. Discover best practices and common pitfalls to avoid in your C# development.
Master the SOLID principles of object-oriented design with this cheat sheet! Learn Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion principles. Improve code maintainability, testability, and scalability. Includes clear explanations, bad/good examples, and memory tips for each principle. Boost your software architecture skills!
Explore the Repository Pattern with Entity Framework in .NET. This article dives into whether wrapping EF with a repository is a boon or burden, covering Unit of Work, generic repositories, read/write separation, and the Specification Pattern. Learn how to build maintainable, testable, and scalable applications by decoupling domain logic from data access, ensuring cleaner code and controlled database interactions. Discover best practices for query optimization and transaction management.
Master the SOLID principles in C# with practical examples! Learn how Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion enhance code maintainability, scalability, and testability. Elevate your C# skills and write cleaner, more robust object-oriented applications. Discover how to avoid common pitfalls and build a solid foundation for future development. Get ready to explore Dependency Injection in our next article!
Explore all 23 Gang of Four (GoF) design patterns implemented in C#. This comprehensive guide provides clear, concise code examples for each pattern, covering creational, structural, and behavioral categories. Learn how to apply Singleton, Factory, Adapter, Observer, and more to build robust, maintainable, and scalable applications. Master object-oriented design principles and improve your C# development skills with these practical examples.
Simplify .NET dependency injection with custom attributes! Automate service registration by defining injection scopes directly on interfaces. This approach reduces boilerplate code, enhances maintainability, and promotes a cleaner, more scalable architecture. Learn how to scan assemblies dynamically and streamline your DI setup for efficient .NET development.
Learn how to build resilient .NET applications with Polly using retry, circuit breaker, timeout, and fallback policies for transient failures.
Command Query Responsibility Segregation (CQRS) separates read and write operations into distinct models, enhancing scalability and performance. Ideal for complex, read-heavy applications and event-driven microservices, CQRS offers optimized read models and better separation of concerns. However, it introduces complexity, eventual consistency challenges, and infrastructure overhead, making it unsuitable for simple CRUD applications. Weigh the pros and cons carefully before implementation.
Explains the differences between Inversion of Control, Dependency Injection, and the Dependency Inversion Principle, with C# examples of loose coupling and abstraction-based design.
Demystifying CQRS and MediatR in .NET! Learn the difference between Command Query Responsibility Segregation and MediatR, with practical examples. Use them right!
Explore how software design patterns offer proven, reusable solutions to common development challenges. Learn their types, benefits, and real-world applications to build scalable, maintainable, and efficient software systems.
This article introduces Dependency Injection (DI) in .NET Framework 4.8, explaining its benefits—like loose coupling and testability—core principles, implementation with Unity container, and common use cases in real-world applications.
This article covers creating flexible, maintainable code for handling multiple databases, while leveraging modern C# features for clean architecture and scalability.
Event-driven architecture (EDA) is a software design pattern where decoupled components communicate via events. It enables real-time, scalable, and flexible systems, commonly used in microservices, IoT, payment processing, and real-time analytics.
Onion Architecture structures code into layers—Domain, Application, Infrastructure, and UI—ensuring separation of concerns, maintainability, and testability by isolating business logic from external dependencies.
The Dependency Inversion Principle (DIP) promotes decoupling by ensuring high-level modules depend on abstractions, not concrete implementations, enhancing flexibility, testability, and maintainability in code.
The Interface Segregation Principle (ISP) is one of the SOLID principles of object-oriented design. It promotes creating small, specific interfaces so that implementing classes don’t need to depend on methods they don’t use, leading to cleaner, modular code.
Understand the Liskov Substitution Principle (LSP), a key SOLID principle that ensures subclasses can replace base classes without errors, promoting reliable inheritance, clean abstraction, and maintainable object-oriented design.
This article explains the Decorator Design Pattern in C#, demonstrating how to dynamically add functionalities to objects without modifying their structure. It includes real-world examples, implementation steps, and code samples.
Domain events and the publish/subscribe pattern are essential for building decoupled, scalable, and maintainable systems. Whether we're working on a microservices architecture or a modular monolith, these patterns help us manage complexity and enforce boundaries between components.
This article explains its benefits, use cases, and implementation in C# with a real-world message-sending example using SmsMessageSender and EmailMessageSender.
Everything on Design Patterns & Practices, not only its articles: the Design Patterns & Practices page →
Write an article and earn +1,000 SHARP when it is approved.
Write an article