{"id":1517,"date":"2025-12-02T09:29:58","date_gmt":"2025-12-02T09:29:58","guid":{"rendered":"https:\/\/oussamasaidi.com\/?p=1517"},"modified":"2025-12-20T11:14:43","modified_gmt":"2025-12-20T11:14:43","slug":"solid-principles-in-c-explained-definitions-examples-best-practices","status":"publish","type":"post","link":"https:\/\/oussamasaidi.com\/en\/solid-principles-in-c-explained-definitions-examples-best-practices\/","title":{"rendered":"SOLID Principles in C# Explained: Definitions, Examples &amp; Best Practices"},"content":{"rendered":"<p>When you begin learning C# or building real-world .NET applications, you quickly notice that writing clean, maintainable code is challenging. This is exactly why the <strong>SOLID principles<\/strong> exist. These rules help developers write software that is <strong>easier to understand, safer to modify, and simpler to test<\/strong>.<\/p>\n\n\n\n<p>In this guide, we will gradually explore each SOLID principle using clear explanations and C# examples. Additionally, for every principle we will compare a <strong>bad implementation<\/strong> with the <strong>correct version<\/strong>, making the learning process much smoother.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/c-sharp-solid.png\" alt=\"SOLID Principles in C#\" class=\"wp-image-1543\" srcset=\"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/c-sharp-solid.png 1024w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/c-sharp-solid-300x300.png 300w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/c-sharp-solid-150x150.png 150w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/c-sharp-solid-768x768.png 768w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/c-sharp-solid-12x12.png 12w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/c-sharp-solid-140x140.png 140w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/c-sharp-solid-256x256.png 256w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/c-sharp-solid-950x950.png 950w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What Are the SOLID Principles?<\/strong><\/h2>\n\n\n\n<p>Before we dive deeper, it&rsquo;s important to understand what SOLID represents.<br>SOLID is an acronym created by Robert C. Martin (Uncle Bob) and includes five essential principles:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>S<\/strong> \u2014 Single Responsibility<\/li>\n\n\n\n<li><strong>O<\/strong> \u2014 Open\/Closed<\/li>\n\n\n\n<li><strong>L<\/strong> \u2014 Liskov Substitution<\/li>\n\n\n\n<li><strong>I<\/strong> \u2014 Interface Segregation<\/li>\n\n\n\n<li><strong>D<\/strong> \u2014 Dependency Inversion<\/li>\n<\/ul>\n\n\n\n<p>Now, let\u2019s explore each principle step by step.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>1. Single Responsibility Principle (SRP)<\/strong><\/h2>\n\n\n\n<p>To begin, the Single Responsibility Principle suggests that every class should focus on <strong>just one task<\/strong>.<br>When a class tries to handle too many responsibilities, it becomes difficult to test and prone to bugs.<br>By keeping responsibilities separated, your code becomes more organized and maintainable.<br>Simply put, one class should do <strong>one thing only<\/strong>.<\/p>\n\n\n\n<p>&#x274c; <strong>Bad Example (Violating SRP)<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public class InvoiceService\n{\n    public void CreateInvoice() { }\n    public void SendEmail(string email) { }\n    public void SaveToDatabase() { }\n}\n<\/pre>\n\n\n\n<p>However, this class mixes three unrelated responsibilities, making it fragile and harder to update.<\/p>\n\n\n\n<p>&#x2705; <strong>Good Example (SRP Applied)<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public class InvoiceCreator\n{\n    public void CreateInvoice() { }\n}\n\npublic class EmailService\n{\n    public void SendEmail(string email) { }\n}\n\npublic class InvoiceRepository\n{\n    public void SaveToDatabase() { }\n}\n<\/pre>\n\n\n\n<p>Now each class does exactly one job, which makes the system more modular and easier to manage.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>2. Open\/Closed Principle (OCP)<\/strong><\/h2>\n\n\n\n<p>Next, the Open\/Closed Principle teaches us that classes should be <strong>open for extension<\/strong> but <strong>closed for modification<\/strong>.<br>This means you should be able to add new features without altering existing code.<br>This avoids introducing new bugs into working logic.<br>In other words, extend behavior \u2014 don\u2019t rewrite it.<\/p>\n\n\n\n<p>&#x274c; <strong>Bad Example (Violating OCP)<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public class DiscountService\n{\n    public double GetDiscount(string type, double price)\n    {\n        if (type == \"Regular\") return price * 0.1;\n        if (type == \"VIP\") return price * 0.2;\n        return 0;\n    }\n}\n<\/pre>\n\n\n\n<p>As you can see, every time we add a new discount type, we must modify this method \u2014 a direct violation of OCP.<\/p>\n\n\n\n<p>&#x2705; <strong>Good Example (OCP Applied)<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public interface IDiscountStrategy\n{\n    double ApplyDiscount(double price);\n}\n\npublic class RegularCustomerDiscount : IDiscountStrategy\n{\n    public double ApplyDiscount(double price) => price * 0.1;\n}\n\npublic class VipCustomerDiscount : IDiscountStrategy\n{\n    public double ApplyDiscount(double price) => price * 0.2;\n}\n<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public class DiscountService\n{\n    private readonly IDiscountStrategy _strategy;\n    public DiscountService(IDiscountStrategy strategy) => _strategy = strategy;\n\n    public double GetDiscount(double price) => _strategy.ApplyDiscount(price);\n}\n<\/pre>\n\n\n\n<p>With this design, you only need to create a new discount class whenever new behavior is required \u2014 no modifications needed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>3. Liskov Substitution Principle (LSP)<\/strong><\/h2>\n\n\n\n<p>Moving forward, the Liskov Substitution Principle ensures that child classes can safely replace their parent classes.<br>A subclass must behave consistently with what the parent class promises.<br>If a child class breaks expectations or throws strange exceptions, it violates LSP.<br>This principle keeps inheritance predictable and reliable.<\/p>\n\n\n\n<p>&#x274c; <strong>Bad Example (Violating LSP)<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public class Bird\n{\n    public virtual void Fly() => Console.WriteLine(\"Flying...\");\n}\n\npublic class Penguin : Bird\n{\n    public override void Fly()\n    {\n        throw new NotSupportedException(\"Penguins cannot fly!\");\n    }\n}\n<\/pre>\n\n\n\n<p>This example breaks LSP because a \u00ab\u00a0Penguin\u00a0\u00bb cannot logically replace a \u00ab\u00a0Bird\u00a0\u00bb that is expected to fly.<\/p>\n\n\n\n<p>&#x2705; <strong>Good Example (LSP Applied)<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public abstract class Bird { }\n\npublic interface IFlyingBird\n{\n    void Fly();\n}\n\npublic class Sparrow : Bird, IFlyingBird\n{\n    public void Fly() => Console.WriteLine(\"Flying...\");\n}\n\npublic class Penguin : Bird\n{\n    \/\/ Penguins do not fly \u2014 so no Fly() method\n}\n<\/pre>\n\n\n\n<p>With this structure, flying and non-flying birds are clearly separated, and inheritance becomes safe<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>4. Interface Segregation Principle (ISP)<\/strong><\/h2>\n\n\n\n<p>In addition, the Interface Segregation Principle encourages us to create <strong>focused and lightweight interfaces<\/strong>.<br>Classes should not be forced to implement methods they do not need.<br>Large, bloated interfaces make code harder to use and maintain.<br>Therefore, breaking interfaces into logical groups keeps everything clean and flexible.<\/p>\n\n\n\n<p>&#x274c; <strong>Bad Example (Violating ISP)<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public interface IWorker\n{\n    void Work();\n    void Eat();\n}\n\npublic class Robot : IWorker\n{\n    public void Work() { }\n    public void Eat() => throw new NotImplementedException();\n}\n<\/pre>\n\n\n\n<p>Here, the robot is forced to implement a method that makes no sense for its behavior.<\/p>\n\n\n\n<p>&#x2705; <strong>Good Example (ISP Applied)<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public interface IWorkable { void Work(); }\npublic interface IEatable { void Eat(); }\n\npublic class Human : IWorkable, IEatable\n{\n    public void Work() { }\n    public void Eat() { }\n}\n\npublic class Robot : IWorkable\n{\n    public void Work() { }\n}\n<\/pre>\n\n\n\n<p>Now each class implements only the methods that are relevant to it \u2014 exactly what ISP recommends.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>5. Dependency Inversion Principle (DIP)<\/strong><\/h2>\n\n\n\n<p>Finally, the Dependency Inversion Principle states that high-level modules should depend on <strong>abstractions<\/strong>, not concrete classes.<br>By depending on interfaces, your application becomes more flexible and testable.<br>Low-level classes should also depend on abstractions, not specific implementations.<br>This principle forms the foundation of modern Dependency Injection in .NET.<\/p>\n\n\n\n<p>&#x274c; <strong>Bad Example (Violating DIP)<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public class FileLogger\n{\n    public void Log(string message) { }\n}\n\npublic class OrderService\n{\n    private FileLogger logger = new FileLogger();\n\n    public void PlaceOrder()\n    {\n        logger.Log(\"Order placed\");\n    }\n}\n<\/pre>\n\n\n\n<p>This creates tight coupling, meaning you cannot easily switch to another logger like a database or cloud logger.<\/p>\n\n\n\n<p>&#x2705; <strong>Good Example (DIP Applied)<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public interface ILogger\n{\n    void Log(string message);\n}\n\npublic class FileLogger : ILogger\n{\n    public void Log(string message) { }\n}\n\npublic class DatabaseLogger : ILogger\n{\n    public void Log(string message) { }\n}\n\npublic class OrderService\n{\n    private readonly ILogger _logger;\n\n    public OrderService(ILogger logger)\n    {\n        _logger = logger;\n    }\n\n    public void PlaceOrder()\n    {\n        _logger.Log(\"Order placed\");\n    }\n}\n<\/pre>\n\n\n\n<p>Now your service depends on an interface, making it easy to replace one logger with another without changing the code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p>To sum up, the SOLID principles are essential for writing clean, professional, and maintainable C# code. They help you avoid complexity, reduce bugs, and build <a href=\"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/securing-sensitive-information-in-net-core.png\" target=\"_blank\" rel=\"noopener\" title=\"securing-sensitive-information-in-net-core\">secured<\/a> systems that scale over time.<\/p>\n\n\n\n<p>Here\u2019s a quick recap:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Principle<\/th><th>Goal<\/th><\/tr><\/thead><tbody><tr><td>SRP<\/td><td>One responsibility per class<\/td><\/tr><tr><td>OCP<\/td><td>Extend behavior without modifying existing code<\/td><\/tr><tr><td>LSP<\/td><td>Subclasses must behave like their parent classes<\/td><\/tr><tr><td>ISP<\/td><td>Create small, focused interfaces<\/td><\/tr><tr><td>DIP<\/td><td>Depend on abstractions, not concrete classes<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>By consistently applying these principles, you will write code that is easier to test, reuse, and evolve \u2014 exactly how modern .NET applications should be built.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">More resources : <\/h2>\n\n\n\n<p><a href=\"https:\/\/learn.microsoft.com\/en-us\/archive\/msdn-magazine\/2014\/may\/csharp-best-practices-dangers-of-violating-solid-principles-in-csharp\" target=\"_blank\" rel=\"noopener\" title=\"\">Learn microsoft<\/a><\/p>\n\n\n\n<div class=\"buy-coffee-container\">\n<p style=\"text-align:center; color:#555; font-size:14px;\">\n  If this article helped you, consider supporting my work.\n<\/p>\n  <a\n    href=\"https:\/\/buymeacoffee.com\/oussamasaii\"\n    target=\"_blank\"\n    rel=\"noopener noreferrer\"\n    class=\"buy-coffee-button\"\n  >\n    &#x2615; Buy me a coffee\n  <\/a>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>When you begin learning C# or building real-world .NET applications, you quickly notice that writing clean, maintainable code is challenging&#8230;. <\/p>\n<div class=\"art-el-more\"><a href=\"https:\/\/oussamasaidi.com\/en\/solid-principles-in-c-explained-definitions-examples-best-practices\/\" class=\"art-link art-color-link art-w-chevron\">Read more<\/a><\/div>","protected":false},"author":1,"featured_media":1535,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[40,250,68,45,274,275,41,56,17,90,85,84,279,58,42,43,272,86,282,46,98,60,20,92,61],"tags":[47,48,49,54,97,53,96],"ppma_author":[286],"class_list":["post-1517","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-netcore","category-ai","category-api","category-asp-net","category-azure","category-azure-ai","category-c","category-c-2","category-design","category-devops","category-docker","category-ef-core","category-en","category-hangfire","category-log","category-logging","category-openai","category-podman","category-scalar","category-serilog","category-solid","category-swagger-ui","category-technology","category-test","category-web-api","tag-net-core","tag-asp-net","tag-c-sharp","tag-c","tag-clean-code","tag-dot-net-core","tag-solid"],"acf":[],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/solid-in-c-sharp-definitions-examples-and-best-practices.png","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":1325,"url":"https:\/\/oussamasaidi.com\/en\/building-professional-modern-api-documentation-in-net-core-with-scalar\/","url_meta":{"origin":1517,"position":0},"title":"Building Professional, Modern API Documentation in .NET Core with Scalar","author":"Saidi Oussama","date":"November 19, 2025","format":false,"excerpt":"Introduction In today\u2019s software ecosystem, APIs are everywhere. Whether you are building a mobile application, a microservices architecture, or an internal company platform, your API is often the backbone of the system. But even the best API becomes useless if developers cannot understand how to consume it. This is why\u2026","rel":"","context":"In &quot;.Net Core&quot;","block_context":{"text":".Net Core","link":"https:\/\/oussamasaidi.com\/en\/category\/netcore\/"},"img":{"alt_text":"Building Professional, Modern API Documentation in .NET Core with Scalar","src":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/Building-Professional-Modern-API-Documentation-in-.NET-Core-with-Scalar.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/Building-Professional-Modern-API-Documentation-in-.NET-Core-with-Scalar.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/Building-Professional-Modern-API-Documentation-in-.NET-Core-with-Scalar.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/Building-Professional-Modern-API-Documentation-in-.NET-Core-with-Scalar.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/Building-Professional-Modern-API-Documentation-in-.NET-Core-with-Scalar.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/Building-Professional-Modern-API-Documentation-in-.NET-Core-with-Scalar.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":1714,"url":"https:\/\/oussamasaidi.com\/en\/https-oussamasaidi-com-restful-api-mastery-best-practices-with-asp-net-core-part-2\/","url_meta":{"origin":1517,"position":1},"title":"RESTful API best practices\u00a0with ASP.NET Core Part 2","author":"Saidi Oussama","date":"December 20, 2025","format":false,"excerpt":"Testing, Performance, Security, Microservices & Deployment Introduction: From Solid Foundations to Production Excellence In Part 1 of RESTful API Mastery, we established the architectural and technical foundations required to build reliable, evolvable RESTful APIs with ASP.NET Core. However, a well-designed API only becomes truly valuable when it is tested, observable,\u2026","rel":"","context":"In &quot;.Net Core&quot;","block_context":{"text":".Net Core","link":"https:\/\/oussamasaidi.com\/en\/category\/netcore\/"},"img":{"alt_text":"RESTful API Mastery","src":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-2r.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-2r.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-2r.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-2r.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-2r.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-2r.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":1639,"url":"https:\/\/oussamasaidi.com\/en\/restful-api-mastery-best-practices-with-asp-net-core\/","url_meta":{"origin":1517,"position":2},"title":"RESTful API Best Practices with ASP.NET Core","author":"Saidi Oussama","date":"December 16, 2025","format":false,"excerpt":"Professional Best Practices, Versioning Strategies & Advanced Serialization (Part 1) In this blog Introduction: Building Enterprise-Grade RESTful APIs with ASP.NET Core1. RESTful APIs in the Modern ASP.NET Core EcosystemWhy REST Still Dominates2. REST Architectural Constraints Every ASP.NET Core API Must EnforceClient\u2013Server SeparationStatelessnessUniform Interface3. Establishing a Clean and Scalable ASP.NET Core\u2026","rel":"","context":"In &quot;.Net Core&quot;","block_context":{"text":".Net Core","link":"https:\/\/oussamasaidi.com\/en\/category\/netcore\/"},"img":{"alt_text":"RESTful API Mastery","src":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-cover-scaled.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-cover-scaled.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-cover-scaled.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-cover-scaled.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-cover-scaled.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-cover-scaled.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":1406,"url":"https:\/\/oussamasaidi.com\/en\/net-8-test-driven-design-architecture-7-proven-patterns-to-build-robust-maintainable-systems\/","url_meta":{"origin":1517,"position":3},"title":"Net 8 Test Driven Design Architecture 7 Proven Patterns to Build Robust, Maintainable Systems","author":"Saidi Oussama","date":"November 25, 2025","format":false,"excerpt":"Introduction to Test Driven Design \u2014 What this guide covers If you want a battle-tested approach to designing systems that are maintainable, testable, and production-ready, .Net 8 Test Driven Design Architecture combines the stability of .NET 8 with Test Driven Design discipline and modern architecture patterns. This guide gives patterns,\u2026","rel":"","context":"In &quot;.Net Core&quot;","block_context":{"text":".Net Core","link":"https:\/\/oussamasaidi.com\/en\/category\/netcore\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/dot-net-8-tdd-architecture-article-cover.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/dot-net-8-tdd-architecture-article-cover.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/dot-net-8-tdd-architecture-article-cover.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/dot-net-8-tdd-architecture-article-cover.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/dot-net-8-tdd-architecture-article-cover.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/dot-net-8-tdd-architecture-article-cover.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":1565,"url":"https:\/\/oussamasaidi.com\/en\/securing-sensitive-information-in-net-core\/","url_meta":{"origin":1517,"position":4},"title":"Securing Sensitive Information in .NET Core: A Complete Guide for Developers","author":"Saidi Oussama","date":"December 8, 2025","format":false,"excerpt":"Protecting user data is one of the most critical responsibilities of any software developer. In today\u2019s connected world, even a small leakage of sensitive information \u2014 API keys, passwords, or tokens \u2014 can have devastating consequences. Fortunately, .NET Core (or .NET 9 and later) offers several mechanisms to help you\u2026","rel":"","context":"In &quot;.Net Core&quot;","block_context":{"text":".Net Core","link":"https:\/\/oussamasaidi.com\/en\/category\/netcore\/"},"img":{"alt_text":"Securing sensitive Information in .NET Core","src":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/securing-sensitive-information-in-net-core.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/securing-sensitive-information-in-net-core.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/securing-sensitive-information-in-net-core.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/securing-sensitive-information-in-net-core.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/securing-sensitive-information-in-net-core.png?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":981,"url":"https:\/\/oussamasaidi.com\/en\/net-8-testing-libraries-complete-guide-for-developers\/","url_meta":{"origin":1517,"position":5},"title":"Best .NET 8 Testing Libraries: The Complete Guide for Developers","author":"Saidi Oussama","date":"December 15, 2025","format":false,"excerpt":"IntroductionWhy Testing Matters More Than Ever in .NET 8Types of Tests in .NET ApplicationsUnit TestsIntegration TestsEnd-to-End (E2E) Tests1. xUnit \u2013 The Most Popular .NET Testing FrameworkWhy xUnit Is a Top ChoiceInstalling xUnit in .NET 8Writing Your First xUnit TestWhy xUnit Works Well for Professionals2. NUnit \u2013 A Mature and Feature-Rich\u2026","rel":"","context":"In &quot;.Net Core&quot;","block_context":{"text":".Net Core","link":"https:\/\/oussamasaidi.com\/en\/category\/netcore\/"},"img":{"alt_text":"Best .NET 8 Testing Libraries","src":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/best-dot-net-8-testing-libraries.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/best-dot-net-8-testing-libraries.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/best-dot-net-8-testing-libraries.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/best-dot-net-8-testing-libraries.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/best-dot-net-8-testing-libraries.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/best-dot-net-8-testing-libraries.png?resize=1400%2C800&ssl=1 4x"},"classes":[]}],"authors":[{"term_id":286,"user_id":1,"is_guest":0,"slug":"oussama_sa","display_name":"Saidi Oussama","avatar_url":{"url":"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2022\/02\/001_001_cv1.jpg","url2x":"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2022\/02\/001_001_cv1.jpg"},"author_category":"1","first_name":"Oussama","last_name":"SAIDI","user_url":"https:\/\/oussamasaidi.com","job_title":"Senior Fullstack .NET Developer","description":"I\u2019m a Senior Fullstack .NET Developer specializing in building scalable, high-performance web applications with .NET, C#, and modern frontend frameworks like React.js. I\u2019m passionate about clean architecture, automated testing, and sharing knowledge through blogs and tutorials."}],"_links":{"self":[{"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/posts\/1517","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/comments?post=1517"}],"version-history":[{"count":28,"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/posts\/1517\/revisions"}],"predecessor-version":[{"id":1706,"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/posts\/1517\/revisions\/1706"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/media\/1535"}],"wp:attachment":[{"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/media?parent=1517"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/categories?post=1517"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/tags?post=1517"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/ppma_author?post=1517"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}