Skip Navigation
InitialsDiceBearhttps://github.com/dicebear/dicebearhttps://creativecommons.org/publicdomain/zero/1.0/„Initials” (https://github.com/dicebear/dicebear) by „DiceBear”, licensed under „CC0 1.0” (https://creativecommons.org/publicdomain/zero/1.0/)PR
premavansmuuf @lemmy.world
Posts 0
Comments 7
Design Patterns in PHP 8: Builder
  • Sadly, no explanation whatsoever of why this approach might be better than just building the object yourself. The example provided is fairly trivial and doesn't seem to justify using a builder.

    Also, how would you do validation of properties (or even detect incompatibility of some of them)? Surely, because Product can be created directly, the Product class itself should validate its values. But it also makes sense for the ProductBuilder to have its own validation, right? Would that mean doing the validation twice?

    The article tries to sell the pattern as being your best friend, but at the same time doesn't say how that's gonna happen.