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
- [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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
The Factory pattern4m 39s
-
(Locked)
Factory pattern in action5m 38s
-
(Locked)
The Builder pattern2m 55s
-
(Locked)
Builder pattern in action6m 1s
-
(Locked)
The Singleton pattern4m 1s
-
(Locked)
Singleton pattern in action4m 55s
-
(Locked)
The Prototype pattern4m 36s
-
(Locked)
Prototype pattern in action4m 59s
-
-
-
-
-