A Guide to Event Handling in C#

Events provide a mechanism for communication between different parts of your code, allowing one component to notify others when a specific action or condition occurs. {: .prompt-tip } Events are a fundamental aspect of C# programming, playing a crucial role in building responsive and interactive applications. They provide a mechanism for communication between different parts of your code, allowing one component to notify others when a specific action or condition occurs. Whether you’re a beginner or an experienced C# developer, understanding events is essential for effective software development. ...

October 31, 2023 · 6 min · 1112 words · Kamran Sadin

SOLID - Dependency Inversion Principle

In the realm of software design, fundamental principles serve as guiding lights for creating maintainable, flexible, and scalable codebases. One such crucial principle is the Dependency Inversion Principle (DIP). DIP is a fundamental component of the SOLID principles, initially introduced by Robert C. Martin. Understanding and applying the Dependency Inversion Principle is crucial for achieving decoupled and adaptable software systems. Introduction Single Responsibility Principle Open/Closed Principle Liskov Substitution Principle Interface Segregation Principle Dependency Inversion Principle What is the Dependency Inversion Principle? The Dependency Inversion Principle emphasizes that high-level modules should not depend on low-level modules; both should depend on abstractions. Additionally, abstractions should not depend on details; instead, details should depend on abstractions. This principle encourages the use of interfaces or abstract classes to decouple higher-level and lower-level modules. ...

October 26, 2023 · 3 min · 604 words · Kamran Sadin

SOLID - Interface Segregation Principle

In the realm of software design, fundamental principles serve as guiding lights for creating maintainable, flexible, and scalable codebases. One such crucial principle is the Interface Segregation Principle (ISP). ISP is a vital component of the SOLID principles, initially introduced by Robert C. Martin. Understanding and applying the Interface Segregation Principle is fundamental to achieving modular and cohesive software systems. Introduction Single Responsibility Principle Open/Closed Principle Liskov Substitution Principle Interface Segregation Principle Dependency Inversion Principle What is the Interface Segregation Principle? The Interface Segregation Principle advocates that clients should not be forced to depend on interfaces they do not use. In other words, a class should not be forced to implement methods it does not need. Instead of a monolithic interface, classes should have smaller, specific interfaces tailored to their requirements. ...

October 24, 2023 · 3 min · 547 words · Kamran Sadin

SOLID - Liskov Substitution Principle

In the realm of software design, adhering to fundamental principles is essential for creating maintainable, flexible, and scalable codebases. One such crucial principle is the Liskov Substitution Principle (LSP). LSP is a key element of the SOLID principles, initially introduced by Barbara Liskov. Understanding and applying the Liskov Substitution Principle is fundamental to achieving robust and extensible software systems. Introduction Single Responsibility Principle Open/Closed Principle Liskov Substitution Principle Interface Segregation Principle Dependency Inversion Principle What is the Liskov Substitution Principle? The Liskov Substitution Principle defines that objects of a derived class should be substitutable for objects of the base class without affecting the correctness of the program. In simpler terms, any instance of a base class should be replaceable with an instance of a derived class without altering the desired properties of the program. ...

October 22, 2023 · 4 min · 692 words · Kamran Sadin

SOLID - Open Closed Principle

In the realm of software design, certain principles serve as guiding lights for creating maintainable, flexible, and scalable codebases. One such foundational principle is the Open/Closed Principle (OCP). OCP is a crucial component of the SOLID principles, initially introduced by Bertrand Meyer. Understanding and applying the Open/Closed Principle can significantly impact software design. Introduction Single Responsibility Principle Open/Closed Principle Liskov Substitution Principle Interface Segregation Principle Dependency Inversion Principle What is the Open/Closed Principle? The Open/Closed Principle emphasizes that software entities (classes, modules, functions, etc.) should be open for extension but closed for modification. In simpler terms, the behavior of a module can be extended without modifying its source code. This principle promotes the creation of a system that is both adaptable and sustainable over time. ...

October 20, 2023 · 3 min · 570 words · Kamran Sadin

Single Responsibility Principle

In the realm of software development, adhering to well-established design principles is paramount for creating maintainable, flexible, and scalable codebases. One such foundational principle is the Single Responsibility Principle (SRP). SRP is one of the SOLID principles, initially introduced by Robert C. Martin, emphasizing a fundamental concept that profoundly influences software design. Introduction Single Responsibility Principle Open/Closed Principle Liskov Substitution Principle Interface Segregation Principle Dependency Inversion Principle What is the Single Responsibility Principle? At its core, SRP advocates that a class should have a single reason to change, meaning it should only have one responsibility. Essentially, a class should encapsulate one aspect of the functionality within the software. By adhering to this principle, the design becomes more modular, maintainable, and easier to extend. ...

October 18, 2023 · 4 min · 650 words · Kamran Sadin

Abstract and Interface in C#

Definition An abstract class in C# is a class marked with the abstract keyword that may contain abstract and non-abstract members (methods, properties, events, etc.). An abstract class provides a common structure and behavior for derived classes and allows for partial implementation by providing some method implementations while requiring derived classes to implement others. An abstract class is like an uncompleted class that can be developed in the future and it is like an interface with a wide vision. An abstract class can have abstract methods like interfaces that should be implemented in the derived class, furthermore, you can have non-abstract methods that do not have to be implemented in a derived class, and abstract methods can be abstract in subclasses if a subclass is defined as abstract. An abstract class can not be instantiated. A derived class can implement or override an abstract class. Also, an abstract class can have constructors and this is a major difference between an abstract class and an interface. Let me summarize, the abstract class is more powerful than the interface in that you have the ability to decide if you want to let the user decide to use the original methods in the abstract class or override them or even you can have abstract methods that the user can decide how to implement them. ...

October 6, 2023 · 5 min · 975 words · Kamran Sadin

Mastering SOLID Principles in C#, Building Robust and Maintainable Applications

In the realm of software development, crafting code that stands the test of time and remains flexible in the face of evolving requirements is an art. Enter the SOLID principles, a set of guiding lights that illuminate the path toward building robust and maintainable applications. Let’s delve into these principles, accompanied by C# examples, and explore how they transform real-world projects. Introduction Single Responsibility Principle Open/Closed Principle Liskov Substitution Principle Interface Segregation Principle Dependency Inversion Principle Understanding Principles in Software Design In software design, a principle is a fundamental and foundational guideline that guides developers in creating software that is maintainable, scalable, and robust. Principles act as a set of recommended practices and rules that help in making design decisions throughout the software development lifecycle. They are based on experience, industry best practices, and lessons learned over time. These principles provide a higher-level understanding of how to structure code, organize components, and manage dependencies. ...

October 4, 2023 · 4 min · 805 words · Kamran Sadin

Delegates Part 2

Delegates Part 1 Delegates Part 2 Prerequisits You want to read the second part of Delegates, right? The first thing that you need is to read the previous part (Part 1). The next thing is putting a smile please put a smile on your face then start to read the article. Target methods As you remember, we agreed that a delegate can point to a method, right? In simple words, it means that we can have a variable that can hold a method in it and then we can call that method by calling this variable. We have local, static, and instance methods in C#, so the delegate can point to which of them? All! A delegate’s target method can be a local, static, or instance method. ...

October 4, 2023 · 9 min · 1726 words · Kamran Sadin

Delegates Part 1 Plugin Methods With Delegates

Delegates Part 1 Delegates Part 2 This post is just to get familiar with Delegates in C#, in the next posts I will talk about delegates in advance. What is Delegate A delegate is an object that knows how to call a method. {: .prompt-tip } You know variables in C#, right? A delegate is a reference type variable that holds the reference to a method and the reference can be changed at runtime. Delegates are usually used for implementing events and the call-back methods (We will get back to this soon). Before getting started, let’s see the syntax of a delegate: ...

October 1, 2023 · 4 min · 754 words · Kamran Sadin