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

Builder pattern in action

From the course: Spring: Design Patterns

Start my 1-month free trial

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…

Contents