Skip to main content

Posts

Showing posts from March, 2025

Service Oriented Architecture (SOA) to Microservice

  Service-oriented architecture (SOA) is a method of software development that uses software components called  services  to create business applications. Each service provides a business capability. They can also communicate with each other across platforms and languages. Developers use SOA to reuse services in different systems or combine several independent services to perform complex tasks.  Microservices architecture is an evolution of the SOA architectural style. While each SOA service is a full business capability, each microservice is a much smaller software component that specializes in a single task only. Microservices address the shortcomings of SOA to make the software more compatible with modern cloud-based enterprise environments. While service-oriented architecture (SOA) might work well for building large enterprise applications, it needs more flexibility to scale smaller, business-specific applications. These are some limitations of SOA: The enterpris...

Design Pattern

 Design pattern is time tested solution for reoccurring software design problems. It is reusable solution to common problem in software design.  It helps in Organizing code, improve scalability and enhance maintainability. Three major category - 1. Creational (object creation) Factory - eg( Notification (Email/PushNotification/SMS) Abstract Factory 2. Structural Singleton Prototype Adaptor - Non compatible Interface/system , made to communicate Proxy           eg. (ecommerce platform, use IPaymentProcessor interface implemented for payment, while one of old payment gateway OldPaymentSystem, which is not compatible with IPaymentProcessor,  3. Behavioral Iterator:                      Provides a way to access the elements of a collection without exposing its underlying                             ...

UML diagrams

  Class diagrams   Type of UML ( Unified Modeling Language ) diagram used to visually represent the structure and relationships of classes within a system. classes are depicted as boxes, each box contain three compartments (i)class name, (ii)attributes/properties,  (iii)methods/functions/operations.  Lines connecting classes illustrate associations , showing relationships such as one-to-one or one-to-many. Attributes, also known as properties or fields, represent the data members of the class.  include the visibility (e.g., public, private) and the data type of each attribute. Methods, also known as functions or operations, represent the behavior or functionality of the class,  include the visibility (e.g., public, private), return type, and parameters of each method. visibility notations include: +  for public (visible to all classes) -  for private (visible only within the class) #  for protected (visible to subclasses) ~  for package ...

Microservices

  Microservice is a small, loosely coupled service that is designed to perform a specific business function and each microservice can be developed, deployed, and scaled independently How to manage high availability of the system:      horizontal scaling , load balancing , service discovery , and a utomated restarts , allowing applications to continue running even if individual components fail.   Redundancy and Replication:  Multiple Instances: Deploy multiple instances of each microservice to ensure that if one instance fails, others can take over the load Replication: Replicate data across multiple databases or storage systems to prevent data loss and ensure availability.        2. Load Balancing: Distribute Traffic: Use load balancers to distribute incoming traffic across multiple instances of a microservice, preventing any single instance from being overloaded 3. Auto-Scaling Dynamic Scaling: Implement auto-scaling to automatically ad...

how to handle failure of dependent services from calling service

 Handling failures of dependent services in a calling service requires implementing proper fault tolerance strategies to ensure the system remains resilient.  There are several common patterns and techniques used to handle such failures as:  Retries Circuit breakers Timeouts Fallbacks To achieve fault tolerance in microservices,  implement strategies like redundancy, circuit breakers, health checks, timeouts, retries, and design for failure , ensuring that services can gracefully handle failures and continue operating effectively

How to implement Caching in API or FrontEnd

Implementing caching efficiently on both the server and client side, can significantly improve the performance and responsiveness of the application.  implement caching in .NET Core backend , and how to use it with your Angular frontend : Set up Caching in .NET Core Backend In .NET Core, we can use different types of caching, such as: In-memory caching : Suitable for short-term data storage. Distributed caching : Suitable for large-scale applications (e.g., using Redis or SQL Server). Step 1: Add Caching Services to Startup.cs ( .NET 6 and later - use program.cs - builder.Services.AddMemoryCache())

DS problems

Array 1. Most frequently occurring Item in an Array 2. Common elements in two sorted Arrays - return array 3. Is one Array a rotation of Another? String 1. first Non-repeating character. 2. Two string - one character away

Compare dictionaries

  Compare two dictionary (dic1, dic2) 1. Loop (I terating through the key-value pairs) if ( dict1. Count != dict2. Count ) return false ; foreach ( var kvp in dict1 ) { if ( !dict2. TryGetValue ( kvp. Key , out var value ) || ! value . Equals ( kvp. Value )) { return false ; } }      return true ; 2. C ompare two dictionaries in C# by invoking the   SequenceEqual()   method { if  ( dict1.Count != dict2.Count )  return false; return dict1.OrderBy ( kvp = >  kvp.Key ) .SequenceEqual ( dict2.OrderBy ( kvp = >  kvp.Key )) ; }   3. use the Enumerable.All() method to check our dictionaries for equality:   if  ( dict1.Count != dict2.Count )  return false; return dict1.All ( kvp = >  dict2.TryGetValue ( kvp.Key, out var value )  &&  value.Equals ( kvp.Value )) ;  Compare all 3 method:  Loop  is  best....

Coding Problems -2

 1. Is Anagram ( Anagram is a word or phrase formed by rearranging the letters in another word or phrase)   public static bool AreAnagrams(string str1, string str2)   {      if (str1.Length != str2.Length)       {           return false;       }      Dictionary<char, int> charCount = new Dictionary<char, int>();     // Iterate through the first string and count the occurrences of each character   foreach (char c in str1)   {       if (charCount.ContainsKey(c))       {           charCount[c]++;       }       else       {           charCount[c] = 1;       }   }   /...