Home » core java » Page 3

Tag Archives: core java

Java Chain of Responsibility Design Pattern Example

1. Introduction In this article, we will discuss about a widely used Design pattern – Java Chain of Responsibility Design Pattern. In the name itself it suggests that, the Chain of responsibility design pattern generates a chain of receiver objects for a request. This pattern separates the sender and receiver for a request based on the type of request. This design pattern is a classification ...

Read More »

Java Proxy Design Pattern Example

1. Introduction In this article, we will discuss about one of the simple and easiest design pattern – Java Proxy Design Pattern. In real world proxy means representative or on behalf of or in place of are exact synonyms of proxy. In Simple words, proxy means an object representing another object. According to this, we can do many operations like encapsulating the ...

Read More »

Java Observer Design Pattern Example

1. Introduction In this article, we would discuss one of the numerous Java Design Patterns – The Java Observer Design pattern which is being used popularly in a variety of messaging and notification frameworks. The Observer design pattern is a typical way of managing communication between multiple classes. This pattern helps in organising the code in a way that makes ...

Read More »

Java 8 Add Days to Current Date Example

1. Introduction Java 8 added a new set of packages to provide a comprehensive date-time model. Java 8 Date-Time API is a JSR-310 implementation. In this example, I will use classes from the java.time and java.time.format packages to demonstrate how to add days to the current date. java.time is the base package which includes a set of date-time classes: LocalDate, LocalDateTime, Instant, Period, Duration, Clock, ZonedDateTime, ...

Read More »

Java Singleton Design Pattern Example

1. Introduction In this article, we would be focusing on one of the many Java design patterns – The Java Singleton Design pattern with the help of a real-life example. In a massive Java application developed for a large organization, often it ends up hard to oversee and comprehend the code. With a fluctuating profile of designers taking a shot ...

Read More »

Logback OutputStreamAppender Example

This article discusses the OutputStreamAppender of logback, a logging framework for the Java application. 1. Introduction to Logback and Appender Logback is designed to be the successor for Log4j. It has been developed by the same development community. These are some of the advantages logback has over log4j Faster implementation – ~10x faster on some critical areas Automatic Reloading of ...

Read More »

Logback Kafka Appender Example

This article discusses Kafka as a logging destination for a Java application. In this tutorial, We will use logback as the logging framework. 1. Logback Kafka Appender – Introduction Logback is designed to be the successor for Log4j. It has been developed by the same development community. These are some of the advantages logback has over log4j Faster implementation – ...

Read More »

Java Composite Design Pattern Example

1. Introduction In this post, we feature a comprehensive Example on Java Composite Design Pattern. In a large scale Java application built for enterprises, there are certain pre-defined coding standards and structures to be followed. These standards and structures assist in development of a code that is organised and easily manageable. This also ensures that the code is structured in ...

Read More »

Java Facade Design Pattern Example

1. Introduction In an enterprise application, it is extremely important to manage the code base so that the redundancy is reduced. Moreover, in order to make code manageable, we also need to take care that the classes are structured and connected  so that the generic code is not repeated in multiple classes. In Java, we use the features like implementing ...

Read More »

Spring MVC @ControllerAdvice Annotation Example

Unexpected exceptions or errors can be thrown anytime during the execution of a program. In the previous post, we have already seen how the @ExceptionHandler annotation can only be applied to a single controller but what if developers want to handle the exception globally i.e. across multiple controllers. Thus, in this tutorial, we will show how to do the exception ...

Read More »