Published at DZone with permission of Fabrizio Giudici, author and DZone MVB.
We are seeing quite a number of exciting JavaFX demos around, demonstrating the pretty features of the language and the capability of easily integrating cool graphics. But, as a software designer, I can't prevent myself from seeing that in most examples we see bloated code - no good separation of concerns and poor applications of the MVC pattern. This is reasonable, as JavaFX was a new language and people needed first to be taught about the syntax and features; but now that - I presume - many of us have been introduced with the new language, it's high time we started worrying about good practices, as well as writing self-commenting code. Let's remember that good practices and good design are always more important than the language!
So, let's introduce a very simple project - a Contact List whose specifications are:
- We have a list of "contacts", where each item is name, last name, email, phone, etc...
- The UI shows a list of contacts, that can be filtered by a text field; if you enter a value in it, only the contacts whose name starts with the entered text are shown. Selections are applied as you type.
- Selecting an item in the list of contacts, the details are shown in a form, where you can edit them.
- At any selection change, the form is animated (a rotation and a blur effect).
You can get the code from:
svn co -r 37 https://kenai.com/svn/javafxstuff~svn/trunk/ContactList/src/ContactList
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)