Skip to content

Instantly share code, notes, and snippets.

View boubkhaled's full-sized avatar
🗨️
الحمد لله على نعمة الإسلام

Khaled boubkhaled

🗨️
الحمد لله على نعمة الإسلام
View GitHub Profile
@boubkhaled
boubkhaled / SOLID-Principles.md
Created December 18, 2022 08:17
SOLID-Principles

image

  1. 𝗦𝗶𝗻𝗴𝗹𝗲 𝗥𝗲𝘀𝗽𝗼𝗻𝘀𝗶𝗯𝗶𝗹𝗶𝘁𝘆 𝗣𝗿𝗶𝗻𝗰𝗶𝗽𝗹𝗲 (𝗦𝗥𝗣) - A class should have only one reason to change. This means that a class should have a single, well-defined responsibility and that responsibility should be entirely encapsulated by the class.

  2. 𝗢𝗽𝗲𝗻/𝗖𝗹𝗼𝘀𝗲𝗱 𝗣𝗿𝗶𝗻𝗰𝗶𝗽𝗹𝗲 (𝗢𝗖𝗣) - Software entities (classes, functions, etc.) should be open for extension but closed for modification. This means that you should be able to add new functionality to a class without changing its existing code, but you should not need to modify the class itself to do so.

  3. 𝗟𝗶𝘀𝗸𝗼𝘃 𝗦𝘂𝗯𝘀𝘁𝗶𝘁𝘂𝘁𝗶𝗼𝗻 𝗣𝗿𝗶𝗻𝗰𝗶𝗽𝗹𝗲 (𝗟𝗦𝗣) - Subtypes must be substitutable for their base types. In other words, if a class is derived from another class, you should be able to use the derived class in the same way as the base class without any issues.

  4. 𝗜𝗻𝘁𝗲𝗿𝗳𝗮𝗰𝗲 𝗦𝗲𝗴𝗿𝗲𝗴𝗮𝘁𝗶𝗼𝗻 𝗣𝗿𝗶𝗻𝗰𝗶𝗽𝗹𝗲 (𝗜𝗦𝗣) - Clients should not be forced to depend on interfaces they do not use. This me

@boubkhaled
boubkhaled / Allow_CORS_In_WebApi2_In_Global.asax.cs
Created August 3, 2022 10:38
Allow Cross-origin resource sharing - CORS - In WebApi2 In Global.asax.cs
using System.Linq;
private readonly string[] authorizedSites = new string[]
{
"https://site1.com",
"https://site2.com"
};
private void SetAccessControlAllowOrigin()
{
@boubkhaled
boubkhaled / Log queries in EF Core.md
Created June 5, 2022 14:23
Entityframework Logging - Log sql queries in EF Core -
public class MyDbContext : DbContext
    {
        public MyDbContext(DbContextOptions<MyDbContext> options) : base(options) 
        { 
            
        }

        // .....
@boubkhaled
boubkhaled / How to Build Visual Studio Installer Projects in Azure Pipelines.md
Created May 25, 2022 14:53
How to Build Visual Studio Installer Projects in Azure Pipelines

How to Build Visual Studio Installer Projects in Azure Pipelines

How to Build Visual Studio Installer Projects in Azure Pipelines

In a previous post, I mentioned I recently started working on a legacy WPF application. Before adding new features, we wanted to ensure that tests would cover the current functionality and that we could reliably build it for distribution. Since it was configured as a Visual Studio Installer Project, it made creating an Azure Pipeline more difficult than I originally anticipated.

Keep these tips in mind if you want to create a CI pipeline for your own Visual Studio Installer Project.

@boubkhaled
boubkhaled / 8 basic software engineering principles.md
Last active May 17, 2022 17:17
8 basic software engineering principles

8 basic software engineering principles:

  1. DRY - Don't Repeat Yourself
  2. KISS - Keep It Simple Stupid
  3. YAGNI - You Aren't Gonna Need It (avoid creating extra complexity through adding functionality that you assume you may need in the future)

SOLID:

  1. Single Responsibility - every module or class should have only a single responsibility.
  2. Open/Closed - software entities should be open for extension but closed for modification.
  3. Liskov Substitution - objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.
  4. Interface Segregation - small client-specific interfaces are better than one general-purpose interface.
  5. Dependency Inversion - use interfaces instead of concrete implementations.
@boubkhaled
boubkhaled / 𝗥𝗲𝗰𝗼𝗺𝗺𝗲𝗻𝗱𝗲𝗱 𝗹𝗲𝗮𝗿𝗻𝗶𝗻𝗴 𝗿𝗲𝘀𝗼𝘂𝗿𝗰𝗲𝘀 𝗳𝗼𝗿 𝗖# 𝗮𝗻𝗱 .𝗡𝗘𝗧.md
Last active May 9, 2022 08:44
𝗥𝗲𝗰𝗼𝗺𝗺𝗲𝗻𝗱𝗲𝗱 𝗹𝗲𝗮𝗿𝗻𝗶𝗻𝗴 𝗿𝗲𝘀𝗼𝘂𝗿𝗰𝗲𝘀 𝗳𝗼𝗿 𝗖# 𝗮𝗻𝗱 .𝗡𝗘𝗧

In the recent Stack Overflow Developer Survey, .NET is marked as the most loved library, while ASP.NET is in the top 3 Web frameworks used by developers. If you want to become a full-stack or back-end developer in the Microsoft .NET stack or you want to improve your knowledge, it's not easy to find the right resources. Here is the list of curated resources that you can use:

𝟭. 𝗟𝗲𝗮𝗿𝗻 𝗖#

@boubkhaled
boubkhaled / Top 50 .NET Interview Questions & Answers.md
Created February 23, 2022 09:31
Top 50 .NET Interview Questions & Answers

Top 50 .NET Interview Questions & Answers - Intellipaat

The rise in the number of job openings leads to a lot of vacancies and stiff competition to hire the most proficient .NET developers. With these questions, you will gain in-depth knowledge and insight into how to answer the most asked questions in a .NET interview. This guide has been carefully curated, considering many factors and including expert advice from multiple professionals and .NET experts.

Q1. What is.NET framework?
Q2. What are some of the common components of .NET?
Q3. What does JIT stand for in .NET?
Q4. What is the meaning of MSIL?