Today, the builder pattern! Twitter: / panpit0 • 🧠 DESIGN PATTERNS 🧠 • 🎥 GO FOR IT! 🎥 • 📚 PUBLISHING YOUR LIBR... • 💥 ALL ABOUT GO 💥 --- Golang version: 1.16 IDE: Goland OS: Windows Accent: French
Пікірлер: 13
@rolandwarburton387 Жыл бұрын
Great beginner level intro, was easy to follow
@nicknick652 жыл бұрын
perfect, nicely explained
@pronoe2 жыл бұрын
"So `me`, I'm a `Human`"... Nice try reptilian lol. Nice video, I like the way you explain and show the code. A video about pointers (*, &, ...) would be really cool. I'm coming from python and I just let my IDE handle those things for me without really understanding what's going on.
@panteliskaramolegkos26932 жыл бұрын
Nice video! I see you are using value receivers. Would it make any practical difference had you used pointer receivers e.g. *human? Is there a convention / better way to go about it when using the Builder pattern?
@--husky_codes2099 Жыл бұрын
Pointer receivers and Value receivers are very similar almost the same, the only difference would be if you want to have an original copy of the human struct you shall use value receiver but if you want to modify the original human struct you may use *receiver.
@midewestmond944211 ай бұрын
You modifying then you should be using pointer I think
@abiodun68972 жыл бұрын
where can i learn about this pattern extensively
@sidikridwan Жыл бұрын
nice tutorial, im new in best practices of golang i read some articles that say no need to create builder pattern in golang since you can directly assign the value and if there is no logic inside the builder function, so my question when we use or not use the builder pattern and what is the best practice for assigning value to struct?
@panpit0 Жыл бұрын
this is my opinion: - use it if you have a lot of fields to build - it's fine if it's just assigning the value, but you might have some tricky cases where a builder pattern is invoking another builder pattern for complex construction - "best practice for assigning value to struct" > as long as you in control of your data structure lifecycle, it's okay to use raw instantiation, simple constructor or a builder pattern. I usually tend to have a functional programming style and avoid to mutate fields and getting out of control
@necroowl39532 жыл бұрын
This is missing a lot of points like having a separate HumanBuilder struct which is the one with all the methods (idiomatically named Age() and EyeColor(), not using the "with" prefix), and the Build() method that returns a Human and an error (you're not evaluating user input here. I have to say that if you are a senior dev in your company, then I should be a CEO lol
@panpit02 жыл бұрын
lol thanks for your kind words, I'm sure you're an excellent software engineer and an amazing team player! Kind regards
@rolandwarburton387 Жыл бұрын
where can i learn more about these more advanced builder pattern topics?