DEV Community

loading...

Discussion on: The Builder Pattern .net core

Collapse
banarualexandru profile image
banarualexandru

Hi Gray

Thank you for the article.
I have a small remark for the last example. If we want to 'lock' the builder in order to force using the 'Create' method, I think we should implement a private constructor, for the builder, and make 'Create' method static. In this way, we will be sure that we will have at any moment an instance of Person. Because right now, if I will call 'new PersonBuilder().Occupation(_something).Build()' it will fail because there's no instance for the '_person' yet created.

Thanks
Good luck.

Collapse
gary_woodfine profile image
Gary Woodfine Author

Thanks for the feedback.

I will attempt to update the article to incorporate your input.

Thanks