+ 1

Code review [solved]

If there're senior/middle developers among you please review my code. Does it correspond to "builder pattern"? https://code.sololearn.com/w4GHOpdJ5hHO/?ref=app

11th May 2022, 5:52 AM
Timur Myngbay
Timur Myngbay - avatar
6 Réponses
+ 1
Not quite. The builder, to be precise, a concrete implementation of a builder interface, is responsible for creating the object. That is the idea behind the builder pattern, to insert a creation mechanism that is flexible and can create many different kinds of object representations. So, you should do no more than to create a concrete builder, but not the object that is being build. This would be my approach, using an abstract CarBuilder class as common interface. The StandardCarBuilder is one possible concrete implementation. The example does not allow for much flexibility, so it may all look a little over the top :) But, I am sure you get the idea. https://code.sololearn.com/wHUwqgwo4vxE
11th May 2022, 7:26 AM
Ani Jona 🕊
Ani Jona 🕊 - avatar
+ 2
I improved it
11th May 2022, 12:05 PM
Timur Myngbay
Timur Myngbay - avatar
+ 2
Great 👍 Enabled method chaining 🙂
11th May 2022, 12:10 PM
Ani Jona 🕊
Ani Jona 🕊 - avatar
+ 1
You're welcome :)
11th May 2022, 10:11 AM
Ani Jona 🕊
Ani Jona 🕊 - avatar
+ 1
Now it looks much better Ani Jona 🕊
11th May 2022, 12:05 PM
Timur Myngbay
Timur Myngbay - avatar
0
Ani Jona 🕊 thank you
11th May 2022, 9:56 AM
Timur Myngbay
Timur Myngbay - avatar