Binary search algorithm

1. Getting. In binary search algorithm, we find an element x in a sorted array by using the principle of divide and conquer. First, we compare x to the middle point of the array. If x is less than the middle point, then we search the left of array. Otherwise, we look for the right… Read More »

Singleton Pattern

1. Definition. Singleton Pattern makes sure that a class only have one instance and provide a global point of access to it. It also belongs to Creation Pattern Group. Singleton Pattern should be used where we only need one of: Thread pools, caches, dialog boxes, object that handle preferences and registry settings, objects used of… Read More »

Observer Pattern

Observer Pattern defines a one-to-many relationship between a set of objects. When the state of one object changes, all of its dependents are notified/updated automatically. It also belongs to Behavior pattern group. 1. A customized notification system. Several newspaper agencies like CNN, NYTime, BBC are subscribed to a feed of new tweets and may want… Read More »

Hibernate cache in theory

The note will follow: 1. Introduction. Hibernate has a two-level cache architecture: first-level cache and second-level cache. Figure 1: Hibernate’s two levels cache (source: Manning) The first-level cache is the persistence context cache (scope of Session). The cache ensures that when the application requests the same persistent object twice in a particular session, it gets back… Read More »

Advantages and Disadvantages of Microservices

To begin with an interesting question, is a microservice architecture a good choice for the system you’re working on? Basically, micro-service often deals with large team, multi-tenancy, supporting many user interaction models, allowing different business functions to evolve independently, and scaling. However, the best answer is it depends on complexity and productivity. If a system… Read More »