Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Best practices for JavaFX architecture and patterns?

cshJan 3 2012 — edited Feb 4 2012
Hi,

I want to write reusable, easy to maintain JavaFX code for a larger UI project and wonder what are the best practices doing so.

1) Are there preferred UI patterns? MVC, MVP, Presentation Model, ...?
2) Does it make sense to use FXML to separate View from Logic? Or should I use 2-3 Java classes instead (one for View, one for Logic, one for Domain Model, depending on the pattern)
3) How to organize all the views? Should I use Dependency Injection? Or Singletons for each view? Spring or Guice framework, if at all?

Currently I use singletons for most views, so that I can use them from anywhere in my application. If a window is closed and opened again, I use the same instance for that, which still resists in memory.

For patterns, I try to lean on Presentation Model, since this is what I know from Flex development: Having a View layer, which contains all the UI stuff and an abstract view layer, which holds properties, that describe the View, e.g. submitButtonDisabledProperty. The View knows the abstract layer (Presentation Model), but not vice versa and the UI elements are bound to its properties.
I am unsure if this is appropriate for JavaFX, too (for Flex or Silverlight it is).

What are your recommendations / experiences for large UI projects?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 3 2012
Added on Jan 3 2012
28 comments
5,603 views