From the course: Spring: Design Patterns

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

The Builder pattern

The Builder pattern

From the course: Spring: Design Patterns

Start my 1-month free trial

The Builder pattern

- [Instructor] Another common creation pattern is the so-called builder pattern. Now in Spring, you will see that this pattern is used in various places throughout the framework. One of the most common ones that I use is the ResultActions, which is part of the MockMvc structure used for testing web applications and web services within the Spring framework. One thing I want to notice, even though it's not really in Spring, is that Lombok actually has taken this builder pattern to a whole new level by providing you an annotation that does all the work that we're about to do in the next video based on a simple annotation, and it's really a time saver. If you haven't looked at Lombok, I highly encourage you to do so. So let's take a look at the pattern as it exists in a nutshell. So each method returns the object reference it's called from in the builder pattern. The build method, which is usually the end of the chain, returns a fully constructed object based on all the intermediate calls…

Contents