Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Update - Builders are Deprecated</strong></p> <p>Regarding Builders in general, the JavaFX project leader <a href="http://mail.openjdk.java.net/pipermail/openjfx-dev/2013-August/010024.html" rel="nofollow">writes</a>:</p> <blockquote> <p>Deprecated in 8 and removed from the JavaDoc, gone in 9 (will be available as a separately downloadable Jar so you can keep using them, but they won't be updated). We're removing them from samples.</p> <p>Best to cycle off the Builders.</p> </blockquote> <hr> <p>The <a href="http://docs.oracle.com/javafx/2/api/javafx/util/Builder.html" rel="nofollow">Builder classes</a> in JavaFX provide a <a href="http://en.m.wikipedia.org/wiki/Fluent_interface#section_1" rel="nofollow">fluent interface</a> to functionality. Such an API is often more easily readable than code which is imperative. </p> <p>Fluent APIs are <a href="http://en.m.wikipedia.org/wiki/Declarative_programming" rel="nofollow">declarative</a> by nature and it is often easier to write bug free declarative code than stateful <a href="http://en.m.wikipedia.org/wiki/Imperative_programming" rel="nofollow">imperative code</a>. </p> <p>A Builder instance can be created as a template and the same instance reused over and over as nicely demonstrated in the <a href="http://blog.netopyr.com/2012/01/24/advantages-of-javafx-builders/" rel="nofollow">Advantages of JavaFX Builders</a>.</p> <p>JavaFX Builders also define the attributes which may be used in an FXML document. See the Builders section of the <a href="http://docs.oracle.com/javafx/2/api/javafx/fxml/doc-files/introduction_to_fxml.html#instance_declaration_elements" rel="nofollow">Introduction to FXML</a> document for more information on this usage.</p> <p>Some areas where Builders may be insufficient in JavaFX 2.2 compared to the imperative API are:</p> <ol> <li>Builders don't facilitate property bindings.</li> <li>Builder APIs may not be complete for all functionalities.</li> <li>Builders can make use of generics which are hard to understand.</li> <li>Builders don't allow you to set static constraints on objects.</li> <li>For simple declarations, builders are more wordy than their counterparts.</li> </ol> <p>An example of point 4 would be that a Builder has no equivalent of a method such as <a href="http://docs.oracle.com/javafx/2/api/javafx/scene/layout/GridPane.html#getVgrow%28javafx.scene.Node%29" rel="nofollow">GridPane.setVgrow(priority)</a>.</p> <p>As to <a href="http://docs.oracle.com/javafx/2/api/javafx/scene/layout/GridPaneBuilder.html" rel="nofollow">GridPaneBuilder</a> specifically vs using the <a href="http://docs.oracle.com/javafx/2/api/javafx/scene/layout/GridPane.html" rel="nofollow">GridPane</a> class - it has the same advantages and drawbacks as other builder vs imperative API comparisons, however GridPaneBuilder is a bit more hamstrung than some other builders as it exposes only a subset of the GridPane interface's functionality - primarily because GridPane relies quite heavily on static methods to specify layout constraints and the equivalent functionality is not exposed in the Builder.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload