Skip to main content

Posts

Showing posts from May, 2023

Popular NoSql DB

NO SQL DBs   Use Case : If application requires low latency. If datas are unstructured, or do not have any relational datas. If only need to serialize and deserialize data (JSON, XML, YAML, etc.). if need to store a massive amount of data. 1.  CouchDB:  CouchDB uses multiple formats and protocols to store, transfer, and process its data. It uses JSON  to store data,  J avaScript  as its query language using M apReduce , and HTTP  for an API. Couchbase MongoDB Multi-document ACID transactions Extremely limited Yes Ability to choose your own shard key and refine it at any time without downtime No Yes Continuous backup with cross cluster consistency and point in time recovery No Yes Client Side Field Level Encryption No Requires significant application code, limited data type support, no enforcement, no queries Yes Built-in full-text search powered by Lucene No Yes Partner ecosystem ~100 1k+ Performance Fast compared to competitors like Oracle Fast compar...

Desgin Patterns

 Design Patterns. 1. Creational 2. Structural 3. Behavourial In Behvorial 1. Strategy pattern Example : Step 1 Create an interface. Strategy.java public interface Strategy { public int doOperation ( int num1 , int num2 ); } Step 2 Create concrete classes implementing the same interface. OperationAdd.java public class OperationAdd implements Strategy { @Override public int doOperation ( int num1 , int num2 ) { return num1 + num2 ; } } OperationSubstract.java public class OperationSubstract implements Strategy { @Override public int doOperation ( int num1 , int num2 ) { return num1 - num2 ; } } OperationMultiply.java public class OperationMultiply implements Strategy { @Override public int doOperation ( int num1 , int num2 ) { return num1 * num2 ; } } Step 3 Create  Context  Class. Context.java public class Context { private Strategy strategy ; public ...

Docker Image build and Run

Docker image from a Spring boot application : Docker is a  containerization platform that allows  to package  applications and dependencies into lightweight, portable containers. Containers are a lightweight and efficient way to package and deploy applications, as they provide a consistent and isolated runtime environment that can be easily moved between different computing environments. Benefits of Using Docker :  Easy build, ship, and run their applications on any platform, from local machine to the cloud.  Docker containers are built from images, which are essentially snapshots of a specific   configuration of an application and its dependencies. These images can be shared and reused   across different teams and environments, allowing for greater collaboration and flexibility.  Streamline development with Continuous Integration and Continuous Delivery (CI/CD) workflows. Create Dockerfile : to create an image of a spring boot applicati...
 Java 8 Streams Interview Questions 1.  Given a list of integers, write a Java 8 Stream program to find the sum of all even numbers in the list. List<Integer> numbers =Arrays. asList ( 1 , 2 , 7 , 8 , 9 , 6 , 3 ); int sum = numbers.stream().filter(n-> n% 2 == 0 ).mapToInt(Integer::intValue).sum(); System. out .println(sum); Output : 16 2.Given a list of numbers, write a Java 8 Stream program to find the second largest number in the list. List<Integer> numbers =Arrays. asList ( 1 , 2 , 7 , 8 , 9 , 6 , 3 ); int secondLargestNumber = numbers.stream().sorted(Collections. reverseOrder ()).skip( 1 ).findFirst().orElse(- 1 ); System. out .println( "second largest number is :" + secondLargestNumber); output : second largest number is :8 3.Given a list of integers, write a Java 8 Stream program to find the average of all the numbers in the list. List<Integer> numbers =Arrays. asList ( 1 , 2 , 7 , 8 , 9 , 6 , 3 ); double average = numbers.stream().mapToInt(Integer:...