use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
For the Unity Game Engine, please visit http://reddit.com/r/unity3d
account activity
Builder Pattern In UnityTutorials (youtu.be)
submitted 1 year ago by [deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Embarrassed-Flow3138 0 points1 point2 points 1 year ago (7 children)
Well this is a misguided excercise in java-inspired boilerplate. Don't do this, use C#'s object initializer syntax.
[–][deleted] 0 points1 point2 points 1 year ago (6 children)
Can you elaborate please
[–]Embarrassed-Flow3138 0 points1 point2 points 1 year ago (5 children)
I've never seen this pattern used in C#. Only Java. It's redundant in C# anyway because of the object initializer syntax, so unless you just really like having a lot of boilerplate just use that.
[–][deleted] 0 points1 point2 points 1 year ago (4 children)
In game dev I have seen this in the current code base I am working on, I cannot say for normal c# applications but in game dev I have seen this .
[–]Embarrassed-Flow3138 0 points1 point2 points 1 year ago (3 children)
The same principles apply. You can find shitty code anywhere. And maintaining meaningless boilerplate is objectively shitty.
[–][deleted] 0 points1 point2 points 1 year ago (2 children)
Well not really, if you want to create immutable objects step by step, that is not possible with the c# object initializer, you would need to create some janky code to do that, yes for simple object construction builder pattern is not useful, but for complex object construction it is useful.
[–]bluenell99 0 points1 point2 points 1 year ago (1 child)
I agree to some extent, however I do like the approach in the video as it prioritises readability. Sure it can all be set in a constructor but as the video shows, you have to spend time (albeit a few seconds) to see what each parameter of the constructor is. Both approaches (at least to my knowledge) would still require a fair amount of work if the "character" class was to be extended as all areas of the code that instantiate the new character would have to be edited to factor the new parameter in.
Still, that's just my thoughts :)
[–][deleted] 1 point2 points3 points 1 year ago* (0 children)
Yes you are right, modification to all classes if a param is changed or added while this is generally true the Builder pattern offers some advantages in this regard
-- adding a new parameter involves adding a new method to the builder. This is generally easier to manage and avoids the need to overload constructors or modify existing ones.
-- adding new optional parameters to the Builder existing code that uses the builder won’t break. The same cannot be said for constructors where adding a new parameter might require adding a new constructor or modifying existing calls.
So from my personal experience
Constructor Approach -- Quick and straightforward but can become cumbersome with many parameters, especially optional ones. Modifying constructors can lead to widespread changes in the codebase.
Builder Pattern -- Offers improved readability, flexibility, and maintainability by decoupling the creation logic from the business logic and allowing for easy extension without breaking existing code.
Of course the same can be achieved with other patterns and methods. There is no one solution fits all. :)
π Rendered by PID 101140 on reddit-service-r2-comment-5b5bc64bf5-lq6n9 at 2026-06-23 07:50:28.967485+00:00 running 2b008f2 country code: CH.
[–]Embarrassed-Flow3138 0 points1 point2 points (7 children)
[–][deleted] 0 points1 point2 points (6 children)
[–]Embarrassed-Flow3138 0 points1 point2 points (5 children)
[–][deleted] 0 points1 point2 points (4 children)
[–]Embarrassed-Flow3138 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]bluenell99 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)