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.
Builder pattern in action
- [Instructor] So now, it's time to actually see the builder pattern in action. I'd like you to go ahead and jump into your IDE, and open up source, main, java, and our base package, and we're going to create a new package and we're going to call this one builder. Now, in the builder package, we're going to start with a simple Java Class and we're going to call that Contact. Now, to our Contact class, we're going to create a couple attributes, so firstName, lastName, and emailAddress. And obviously, you can imagine that a contact would have a lot more, but for the purpose of this, this will work just fine. Now, I'm going to generate a few methods here, first thing I'm going to do is create a no-args constructor, and I like to throw a super in there. And then, I'm going to create an all-args constructor, and finally, I'm going to do Getters and Setters. And once again, your IDE should have some way to generate all of this. If it doesn't, you can just type it in, but I used a speed key…
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
-
-
-
-
-