JRebirth Builders

17 views
Skip to first unread message

Rajmahendra R

unread,
Jul 17, 2013, 1:27:10 AM7/17/13
to jrebirth-...@googlegroups.com
Seb,

The Builders in JR all need new  operator ?

Why dont we use the same pattern of JavaFX ?

 ColorBuilder.create()..... .build();


Rajmahendra R

unread,
Jul 17, 2013, 1:35:53 AM7/17/13
to jrebirth-...@googlegroups.com
We can have a  ColorItemBuilder something like...

ColorItemBuilder .create().web().value("").opacity(0.4).build();

Sebastien Bordes

unread,
Jul 17, 2013, 3:59:08 AM7/17/13
to jrebirth-...@googlegroups.com
Raj,

JavaBuilders have 2 major drawbacks for the resource use cas:
  • they don't guarantee that the object instance is initialized with all required parameters.
  • they are too verbose

The first item imply to add default values, but I prefer that developer explicitly declare the value they want, ResourceParams object are quite simple ones

The second item can be discussed, we can add JavaBuilder for ResourceParams (WebColor, ... RealFont, ... LocalImage etc...) and let developers choose the way they want, because JBs provide 'named' parameter that easy to maintain.

For object with only which have 1 to 4 fields the gain is limited and I would prefer to write :

Resources.create(new WebColor("123ABC", 0.4));

instead of

Resources.create(ColorItemBuilder.create().web().value("123ABC").opacity(0.4).build());


Perhaps you want to manage all internal properties with the value method of the JavaBuilder like for the Forge plugin, but It will be less readable for coders and so less maintainable. It will be also less efficient becuase string parsing will be executed during resources initialization.

Resources.create(ColorItemBuilder.create().web().value("123ABC").opacity(0.4).build());
Resources.create(ColorItemBuilder.create().rgb01().value("0.99_0.23_0.89").opacity(0.5).build());
Resources.create(ColorItemBuilder.create().hsb().value("360.0_0.73_0.78").opacity(0.9).build());


But why have less when you can have more

We can add JavaBuilder with generic value method (and internal parser, code must be shared with forge), and custom methods red(double) red(int) ... or a builder per ResourceParams (a lot of classes).
The big problem will be to manage default values with JavaBuilder, we can keep existing constructors and add a default one (without parameter; used by JB)


Seb

rajma...@gmail.com

unread,
Jul 17, 2013, 4:06:24 AM7/17/13
to jrebirth-...@googlegroups.com
Seb

your point is valid :) 

My idea is to adopt the JavaBuilder so JR looks native to Java developers.


--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes JRebirth Developers.
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse jrebirth-develo...@googlegroups.com.
Pour plus d'options, visitez le site https://groups.google.com/groups/opt_out .
 
 



--
Thank you and regards,
Rajmahendra R Hegde (Raj)
Website:
http://www.twitter.com/rajonjava
http://www.jugchennai.in             
----------------------------------------------------------------------------------------------
"DREAM is not what you see in sleep;
is the thing which does not let you sleep" - APJ Abdul Kalam
Do the difficult things while they are easy and do the great things while they are small.
A journey of a thousand miles must begin with a single step. - Lao Tzu


image003.png

Sebastien Bordes

unread,
Jul 17, 2013, 4:34:50 AM7/17/13
to jrebirth-...@googlegroups.com
JRebirth already uses JavaBuilder !

To build WaveBean and Commands (used with waves)

Here you have the most noticeable builder used to display a UI view into another :

https://github.com/JRebirth/JRebirth/blob/0374871b5889ef77bf2c538b745755e5a0314ea5/org.jrebirth/core/src/main/java/org/jrebirth/core/command/basic/showmodel/ShowModelWaveBuilder.java

And here to manage other Stage (open close, command will call a JRebirth service) :

https://github.com/JRebirth/JRebirth/blob/0374871b5889ef77bf2c538b745755e5a0314ea5/org.jrebirth/core/src/main/java/org/jrebirth/core/command/basic/stage/StageWaveBuilder.java

The inheritance tree is ==> Builder(I) <|- - -  Wave Builder <|---- CommandBuilder <|---- ShowModelWaveBuilder

;D
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse jrebirth-developers+unsub...@googlegroups.com.

Pour plus d'options, visitez le site https://groups.google.com/groups/opt_out .
 
 
Reply all
Reply to author
Forward
0 new messages