terça-feira, 29 de abril de 2014

What if I develop a new library?


There are some days in which I'm searching for a new thing to develop for fun. I was starting up in JavaFX, and I took a liking to it's features.
It seems to me JavaFX is a nice tool for developing rich interfaces. It's Java, so there are a lot of OO things we can do with it.
So, the first thought that came up to my mind was a way to create interfaces faster and automatically bind POJO's or JavaBean's properties to the view, in a programmatic way. This idea was first concepted by Clécius Martinkoski (his blog http://pedreirosdosoftware-pedreiros.rhcloud.com/author/clecius/) in an informal conversation, he is a Java Architect.

What I want is a way to get a class (POJO or JavaBean) and define annotations at it's fields. The annotations would define a label and a type of JavaFx field, for example. Something like this:

class Person{

   @AnnotationName(label = "Name", type = TextJavaFxField.class, width=50)
   private String name;


And a handler object, that could get these features by reflection, would create and bind, at runtime, the components at the interface of JavaFX to the object to which the annotations refer.

I looked for some already developed solutions for this problem, but I didn't find a tool that could satisfy what I was hoping for, or maybe I didn't get what the point of their solution was.

What I found was DSL (Domain Specifc Language) and JavaFx interface creation at this post:

Subsequently I'm gonna study and report here if DSL can solve my problem, or if cannot, and why. I'm gonna post my development parts here, comment them and share at GitHub.

If you read this post and think it's interesting, or if you've already worked in a similar problem, or if you know a nice tool that already does what I proposed; please, Share and comment so that I can write posts about them!

Thank you!