Book Image

Spring 5 Design Patterns

By : Dinesh Rajput
Book Image

Spring 5 Design Patterns

By: Dinesh Rajput

Overview of this book

Design patterns help speed up the development process by offering well tested and proven solutions to common problems. These patterns coupled with the Spring framework offer tremendous improvements in the development process. The book begins with an overview of Spring Framework 5.0 and design patterns. You will understand the Dependency Injection pattern, which is the main principle behind the decoupling process that Spring performs, thus making it easier to manage your code. You will learn how GoF patterns can be used in Application Design. You will then learn to use Proxy patterns in Aspect Oriented Programming and remoting. Moving on, you will understand the JDBC template patterns and their use in abstracting database access. Then, you will be introduced to MVC patterns to build Reactive web applications. Finally, you will move on to more advanced topics such as Reactive streams and Concurrency. At the end of this book, you will be well equipped to develop efficient enterprise applications using Spring 5 with common design patterns
Table of Contents (20 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Dedication
Preface

Creational design patterns


Let's look at the underlying design patterns of this category and how Spring Framework adopts them to provide loose coupling between components and create and manage the lifecycle of Spring components. Creational design patterns are associated with the method of object creation. The creation logic of the object is hidden to the caller of this object.

We are all aware of how to create an object using the new keyword in Java, as follows:

     Account account = new Account(); 

But this way is not suitable for some cases, because it is a hardcoded way of creating an object. It is also not a best practice to create an object because the object might be changed according to the nature of the program. Here, the creational design pattern provides the flexibility to create an object according to the nature of the program.

Now let's look at the different design patterns under this category.

Factory design pattern

Define an interface for creating an object, but let subclasses decide...