Wednesday, 24 October 2018

Declarative Transaction Management Declarative transaction management is the most common Spring implementation as it has the least impact on application code. The XML declarative approach configures the transaction attributes in a Spring bean configuration file. Declarative transaction management in Spring has the advantage of being less invasive.   There is no need for changing application code when using...

An object is chunk of memory , and the reference to the object is way to reach up to that object in the memory Object reference variable contains address of the object which is declared in the heap memory Class Box { double height; double width; double depth; } Box b1; //declare reference ..it will be null b1 = new Box(); //Create an instance assign to reference variable b1 Box b2 = b1; //Only creates reference...

This algorithm uses idea of divide and conquer. Find the element called pivot which divides the array into two halves Left side elements should be smaller than the pivot Right side elements are geater than the pivot Steps Bring the pivot to its appropriate position such that left of the pivot is smaller and right is greater. Quick...

Monday, 22 October 2018

Create shared Semaphore object , lock and unlock in consumer - producer  blocks by limiting thread accessible count to 1 Output will be like produce 1 and consume 1 , produce 2 and consume 2 ... Producer.java public class Producer implements Runnable { private static List LIST; private static Semaphore semaphore; public Producer(List LISTv, Semaphore semaphoreV) { LIST = LISTv; semaphore = semaphoreV; ...

BlockingQueue amazingly simplifies implementation of Producer-Consumer design pattern by providing outofbox support of blocking on put() and take(). No need of manual empty or full check, Blocking Queue handle it internally. Only put and take operation required Output is like one N produce and then consume like FIFO ordedr Producer.java public class Producer implements Runnable { private static BlockingQueue QUEUE; ...

If List is full then our PRODUCER thread waits until CONSUMER thread consume one item and make space in your queue and call notify() method to inform PRODUCER thread. Both wait() and notify() method are called on shared object which is List in our case. Need synchronised block Check for List size manually and wait for consumer and producer threads Since it is synchronised, Needs to wait till N production Needs to wait till...

Saturday, 13 October 2018

LRU Cache (Java) Design and implement a data structure for Least Recently Used (LRU) cache.  The LRU caching scheme is to remove the least recently used frame when the cache is full and a new page is referenced which is not there in cache. Properties are, Fixed Size: Cache needs to have some bounds to limit memory usages. Fast Access:...

Friday, 12 October 2018

What is a Query Plan? A query plan is a set of steps that the database management system executes in order to complete the query.  The reason we have query plans is that the SQL you write may declare your intentions, but it does not tell SQL the exact logic flow to use.  The query optimizer determines that.  The result of that is the query plan The lesson to learn from this when in doubt check the execution...

Java Memory Management, with its built-in garbage collection, is one of the language's finest achievements  It allows developers to create new objects without worrying explicitly about memory allocation and deallocation, because the garbage collector automatically reclaims memory for reuse How Garbage Collection Really Works Many...

Java 8  : How to Sort a List using lambdas? Integer[] arr = { 1, 7, 3, 9, 4, 67, 100, 23, 26, 76, 8 }; List list = Arrays.asList(arr); list.sort((a1, a2) -> a1.compareTo(a2)); System.out.print(list); Is singleton is lazy initialisation? Yes. As in the below code singleton is lazy initialisation. We will not initialise on static instance property. And initialise only on getInstance method, so it will...

It is the first concurrent utility framework in java and used for standardising invocation, scheduling, execution and control of asynchronous tasks in parallel threads. Executor implementation in java uses thread pools which consists of worker threads. The entire management of worker threads is handled by the framework. So the overhead in memory management is much reduced compared to earlier multithreading approaches. The...

A Semaphore is a thread synchronization construct that can be used either to send signals between threads to avoid missed signals, or to guard a critical section like you would with a lock Simple Semaphore implementation: The take() method sends a signal which is stored internally in the Semaphore. The release() method waits for a signal. When received the signal flag is cleared again, and the release() method exited. //...

How Volatile in Java works? The Java volatile keyword cannot be used with method or class and it can only be used with a variable. Java volatile keyword also guarantees visibility and ordering and write to any volatile variable happens before any read into the volatile variable. Example: Singleton Class  public class Singleton{ private static volatile Singleton _instance; //volatile variable public static Singleton...

If your code is executing in a multi-threaded environment, you need synchronization for objects, which are shared among multiple threads, to avoid any corruption of state or any kind of unexpected behavior. Synchronization in Java will only be needed if shared object is mutable. JVM guarantees that Java synchronized code will only be executed by one thread at a time.  we can not have synchronized variable in java. Using...

Thursday, 11 October 2018

S.O.L.I.D is an acronym for the first five object-oriented design(OOD) principles by Robert C. Martin, popularly known as Uncle Bob. These principles, when combined together, make it easy for a programmer to develop software that are easy to maintain and extend They also make it easy for developers to avoid code smells, easily refactor code, and are also a part of the agile or adaptive software development. S - Single-responsiblity...

Tuesday, 9 October 2018

Prototype pattern refers to creating duplicate object  This pattern involves implementing a prototype interface which tells to create a clone of the current object. This pattern is used when creation of object directly is costly. For example, an object is to be created after a costly database operation. We can cache the object, returns its clone on next request and update the database as and when needed thus reducing database...

This pattern involves a single class which is responsible to create an object while making sure that only single object gets created. SingleObject class have its constructor as private and have a static instance of itself.                               ...

Abstract Factory patterns work around a super-factory which creates other factories. This factory is also called as factory of factories. This type of design pattern comes under creational pattern as this pattern provides one of the best ways to create an object. In Abstract Factory pattern an interface is responsible for creating a factory...

The factory method pattern is a creational pattern that uses factory methods to deal with the problem of creating objects without having to specify the exact class of the object that will be created. Design problems to design flexible and reusable object-oriented software, that is, objects that are easier to implement, change, test,...

The Builder is a design pattern designed to provide a flexible solution to various object creation problems in object-oriented programming.  The intent of the Builder design pattern is to separate the construction of a complex object from its representation. The Builder design pattern solves problems like Create different representations...

Creational design patterns are design patterns that deal with object creation mechanisms, trying to create objects in a manner suitable to the situation.  The basic form of object creation could result in design problems or in added complexity to the design. Creational design patterns solve this problem by somehow controlling this object creation. Creational design patterns are composed of two dominant ideas. Encapsulating...

Friday, 5 October 2018

Spring Boot is a Spring framework module which provides RAD (Rapid Application Development) feature to the Spring framework.  It is highly dependent on the starter templates feature Starter Template Spring Boot starters are templates that contain a collection of all the relevant  dependencies that are needed to start a particular...
Page 1 of 101234567...10Next »Last

Search This Blog

Contact us

Name

Email *

Message *