Select Page

Get Free Big O Cheatsheet

To get free Big O cheatsheet, Fill in your name and email to get your copy.

Do not scared, we do not spam your inbox.

Start learning

📚 Micro services Architecture and Design patterns.
📚 Data Structures and Algorithm

Introduction and Characteristics of Algorithm

Introduction and Characteristics of Algorithms is explained in detail below

Recap – Data Structures

The programmatic way of storing data, so that it can be used efficiently. Almost every enterprise application uses various types of data structures in one or the other way.

Algorithm Introduction

Introduction and Characteristics of Algorithms, Algorithm is a step-by-step  programmatic way of storing data, so that it can be used efficiently. Almost every enterprise application uses various types of data structures in one or the other way.

Algorithm is step-by-step procedure for solving a problem in finite number of steps. In other words it is finite set of well-defined instructions written in human readable language for solving a given problem. An algorithm is division of a problem into small steps which are in sequence. Algorithm is very important way for computers to understand the problem and process the information accordingly.

Problem can always be solved in multiple ways or can have multiple solutions to solve. Similarly Algorithms also can be written any number ways to solve the problem. Let us see the characteristic of an Algorithm.

Characteristic of an Algorithm:

Writing an Algorithm must possess the following characteristics.

• Finiteness : Each algorithm must have finite number of steps, or must terminate after finite number of steps.
• Input : algorithm may not have input or have many inputs.
• Output :  Must have 1 or more well-defined output, should match the desired output.
• Unambiguous : Algorithm must be clear and unambiguous, each of the input and output
• Feasibility : Resources must be utilized properly, Should never waste the resource.
• Independent : Algorithm must be independent of any Programming languages.

In the next article in details about the Big O Notations in data structures with example.

LIKE | SHARE | FOLLOW

Free Ebook on Microservice Architecture and Design Patterns

“You are never too old to set another goal or to dream a new dream”-S. Lewis

Start learning 📚 Micro services Architecture and Design patterns.

What are the Saga design pattern and types available?

Today we will see what are the Saga Design Pattern and types available.

Previously we saw about What is Microservice? and the principles followed while developing MSA and the available design patterns.

What are the Saga design pattern and types available?

The Saga Pattern is a microservices architectural pattern to implement a transaction that extends multiple services.

A saga is a sequence of local transactions. Each service in a saga performs its own transaction and publishes an event. The other services listen to that event and perform the next local transaction. If one transaction fails for some reason, the saga also executes compensating transactions to undo the impact of the preceding transactions.

Example:

Consider a Food delivery service flow, When a user places an order, below could be the flow.

1. The food ordering service creates an order. At this point, the order is in PENDING status.
2. With the Saga pattern, it contacts the restaurant via the restaurant service.
3. The restaurant service attempts to place an order with the selected restaurant, Once the order is received by Restaurant it sends back an ORDER_ACCEPTED (if the order is accepted) or ORDER_REJECTED (if the order cannot be accepted) status.
4. The saga received the status ORDER_ACCEPTED or ORDER_REJECTED status and process the response to the customer accordingly.
5. The food order service then changes the status of the order, if the order is accepted then it displays an order confirmation message if the order is rejected it display an apologies message and suggest alternative restaurants.

Types of Saga:

1. Orchestration-based saga
2. Choreography-based saga

In the next article, we will see in detail about the Type of Saga design patterns.

LIKE | SHARE | SUBSCRIBE

WeCanCode-Author

December 07, 2021

Senior Developer | Java & C#.NET | 10++ years of IT experience.

Planning to learn ReactJS or Angular or Flutter.!

What is the Circuit breaker design pattern?

Today we will see what is the Circuit breaker Design Pattern is.

Previously we saw about What is Microservice? and the principles followed while developing MSA and the available design patterns.

Circuit breaker design pattern?

As the name suggests the Circuit breaker design pattern is used to stop the process of request and return with the response if a service is not working.

This design pattern can improve the stability and flexibility of an application.

In a distributed environment, calls to remote services and resources can fail due to transient faults, such as slow network connection, timeouts, or the resource being over-committed or temporarily unavailable. These faults typically fix themselves after a short period of time.

However there can also be situations where faults are due to unforeseen events, that might take longer to fix. These faults vary from partial loss of connectivity to complete failure of a service. In these situations, it might be pointless for an application to keep retrying an operation that is unlikely to succeed, instead, the application should accept that the operation has failed and handled this failure accordingly.

A circuit breaker pattern can prevent an application from repeatedly trying to execute an operation that’s likely to fail. Allowing it to continue without waiting for the fault to be fixed or the utilization of resources does not kill the CPU and memory.

It also enables an application to detect whether the fault has been resolved.

How does the Circuit breaker work?

A client should invoke a remote service via a proxy. When the number of consecutive failures crosses a threshold, the circuit breaker trips, and for the duration of a timeout period all attempts to invoke the remote service will fail immediately. After the timeout expires the circuit breaker allows a limited number of test requests to pass through. If those requests succeed the circuit breaker resumes normal operation. Otherwise, if there is a failure the timeout period begins again.

Circuit breaker design pattern

Example:

Consider we have Video Upload and View service when there is a failure in one of the services which triggers the Circuit open and enables the proxy service.

In the next article, we will see the Decomposition design pattern.

LIKE | SHARE | SUBSCRIBE

WeCanCode-Author

November 30, 2021

Senior Developer | Java & C#.NET | 10++ years of IT experience.

Planning to learn ReactJS or Angular or Flutter.!