A Compile Time Builder Pattern in Java

Veröffentlicht am: 07 August 2017
auf dem Kanal: World of Zero
376
2

The builder pattern allows you to avoid messy constructors that get out of hand as dozens of parameters get added to the objects you're building. It's a powerful tool for simplifying code and making it easier to read. However, it does introduce a few downsides, most notably you lose compile time error checking to validate that the constructors you are implementing via builders will result in valid objects. In this video we'll look at a potential solution to that problem that involves implementing something very close to a typed state machine to handle our object building.

This pattern works by creating interfaces that chain together one after another until a finalizer statement is reached that terminates the chain. This allows each interface to explicitly define what the next step in object construction is including support for branching arguments, optional arguments and more!

What do you think? Does it work? Does it add too much complexity for the minor added benefit?

The blog post detailing this style of Builder pattern. http://blog.crisp.se/2013/10/09/perlu...

Discord:   / discord  


Auf dieser Seite können Sie das Online-Video A Compile Time Builder Pattern in Java mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer World of Zero 07 August 2017 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 376 Mal angesehen und es wurde von 2 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!