I'm trying to understand builder pattern usages and so to call to separate is usage types in groups. Here is what I discovered:
-
Builder can be used to provide immutability (avoiding telescoping) for an object he is building. So called Joshua Bloch's builder. So, we use builder to facilitate building of object with a lot of fields.
-
Builder can build some objects that need to be structured and follow some structure rools. For example XmlBuilder, that builds xml and can fail when wrong data is passed (e.g. not closing a tag, or so on). In this case builder validates inner object on each build step.
But what about GoF's builder? With Director, abstract Builder and different implementations.. I have never seen such implementation in production. Have you ever seen such examples?
Aucun commentaire:
Enregistrer un commentaire