Posts

Aggregation and Association and Composition and Its differences with examples

 Aggregation, association, and composition are object-oriented programming concepts that define relationships between classes or objects. Here are their definitions and differences: 1. Aggregation: Aggregation is a relationship where one object has a reference to another object, but the referenced object can exist independently of the object that references it. The object that references the other is known as the container or owner, while the referenced object is known as the contained or member object. Here are a few examples of aggregation in C#: Example - 1 : A university has many departments, and each department has many students. In this case, the Department class is the container, and the Student class is the contained object. Here's an example code: public class Department {     public List<Student> Students { get ; set ; } } public class Student {     public string Name { get ; set ; } } Example - 2 : A car has an engine, and the engine can ...

Difference of High-Level Design (HLD) and Low-Level Design (LLD)

High-Level Design (HLD) and Low-Level Design (LLD) are software design concepts that are not specific to any programming language. However, to illustrate the differences between HLD and LLD, we can use C# programming language examples. Suppose we are designing a software system that involves creating a payment gateway application in C#.  Here are examples of HLD and LLD for this system: High-Level Design (HLD): Define the functional requirements of the payment gateway system, such as processing payment transactions, handling errors, and providing a user interface. Identify the non-functional requirements, such as performance, scalability, and security. Identify the key components of the payment gateway system, such as payment processing engine, database, user interface, and error handling. Create an architecture diagram that shows how these components will fit together to form the payment gateway system. In HLD, the focus is on defining the system's overall structure and architectu...

Clean Architecture in a C#

Clean Architecture is a software design pattern that separates the application into independent layers, where each layer has a specific responsibility and interacts with other layers through well-defined interfaces. The main goal of clean architecture is to create a flexible, testable, and maintainable software system. By following this architecture, we have created a flexible, testable, and maintainable software system. The domain layer is independent of any external dependencies and frameworks, making it easy to test and change without affecting other layers. The application layer contains the use cases or application-specific logic, which is decoupled from the infrastructure Here's an example of how to implement Clean Architecture in a C# project: 1. Domain Layer: This layer contains the business logic and domain-specific entities. It should be independent of any external dependencies and frameworks. C# ...

Implementing DIP (Dependency Inversion Principle) in .NET Core project

Dependency Inversion Principle (DIP) is one of the SOLID principles that states that high-level modules should not depend on low-level modules, instead both should depend on abstractions. In .NET Core, we can implement DIP using various techniques such as Dependency Injection, Inversion of Control (IoC), and Service Locator. Here's a simple example of how to implement DIP using Dependency Injection in a .NET Core project: By following below steps, we can implement DIP in our .NET Core project using Dependency Injection. 1. Define interfaces for the low-level modules (dependencies) that the high-level module needs to use. For example: public interface ILogger {     void Log( string message); } public interface IDataProvider {     string GetData(); } 2. Create implementations for these interfaces.  For example: public class FileLogger : ILogger {     public void Log( string message)     {         // cod...

Create Extension Method in typescript - String.IsNullOrEmpty()

Image
How to Create Extension Method using Typescript in Angular Application - String.IsNullOrEmpty() Step 1 : Create typings.d.ts (declaration file) in the application and declare the method in interface like below. HTML interface StringConstructor { isNullOrEmpty(value: string): boolean; } Step 2 : Create extension.ts file in the application and implement the method like below. HTML String.isNullOrEmpty = function (value: string): boolean { return value === undefined || value.trim() === '' || value === null; }; Step 3 : Usage of the Method in the component or class file. HTML import './extensions'; export class TestComponent implements OnInit { public ngOnInit(): void { let abc; console.log(String.isNullOrEmpty(abc)); } } Step 4 : Output like below.

Javascript Hoisting

JavaScript hoisting is a mechanism where variable and function declarations are moved to the top of their respective scopes (either the global scope or function scope) during the compilation or interpretation phase, regardless of where they are declared in the source code. This means that even if a variable or function is declared later in the code, it can be used before its actual declaration. However, it is important to note that only the declaration is hoisted, not the initialization or assignment. In other words, if a variable is initialized after its declaration, its value will not be available until after the initialization. Similarly, if a function expression is used, it will not be hoisted, only function declarations are hoisted. JavaScript hoisting can have some advantages and disadvantages. Advantages: Flexibility : Hoisting provides developers with the flexibility to declare functions or variables anywhere in t...

Recommended Visual Studio Code Extensions for Angular Development

Every Angular Developer should know these recommended VS Code Extensions. I guess most of the developers using the Visual Studio Code tool for coding. There are large number of extensions are available in market place. But I choose necessary extensions, which is related to angular development. It will speed up your work when you're doing development. Extensions can help to improve productivity and code quality for Angular development in VS Code. By automating tasks and enforcing best practices, these extensions can help developers to create better code more quickly and with fewer errors. Angular Language Service - Provides rich editing experience for Angular templates with autocompletion, diagnostics, and jump-to-definition features. Angular Snippets - Provides a collection of Angular snippets to quickly insert common code structures, such as components, directives, and services. Angular Console - Provides a GUI tool for generating and managing Angular projects and associated fi...