I was watching a video regarding design patterns and the youtuber made an example of the builder pattern… I didn’t know about the pattern(there is a reason why I was watching the videos); But I had encounter the same type of problems so what I usually did was to return null to the fields I didn’t had their data.

Is it wrong what I was doing?

At the end the builder will make the object with a null data and realistically it takes the same amount of code…

  • glad_cat@lemmy.sdf.org
    link
    fedilink
    English
    arrow-up
    4
    ·
    1 year ago

    You remind me that I suck at design patterns. IMHO, the patterns are only theoretical, and it doesn’t cover all the details of every language. Sometimes it will be null, empty, or can throw an exception if your team decides that it’s better.