Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

JavaFX has provided a bunch of new Property objects, such as javafx.beans.property.DoubleProperty which allow you to define fields which can be automatically observed and synchronised.

In many JFX examples, the MVC model class has a number of these Property fields, which can then bind automatically to the view.

However, this seems to be encouraging us to put JFX properties into our Domain objects (if you assume that the Model class is going to be a domain object), which strikes me as a poor separation of concerns (i.e. putting GUI code in the Domain).

Has anyone seen this problem being solved in 'real life' and, if so, how was it done?

share|improve this question
    
Please correct me if I am wrong, but my understanding of JavaFX was that it was shelved by Sun in 2008 prior to Oracle purchase, and has only been refurbished to the market with the deprecation of Silverlight and Decline of Flash on apple devices. Maybe you are correct that it is tightly coupled to the view, and an original reason it was put on hold at sun. Just a thought. –  ClintNash Jul 7 '12 at 5:59
    
Sun and now Oracle have been working continuously on JavaFX for several years. The recent major shift was to discontinue the "JavaFX Script" programming language that was required to use JavaFX, and to switch to using ordinary Java. This shift was driven by poor adoption and expense of supporting an entirely new programming language. –  Stuart Marks Jul 17 '12 at 6:46
add comment

1 Answer 1

I have been playing around with JavaFX 2.0, which I assume your question is about. Not real production code, just a personal project, but I ran into the same problem that you mention above. The entire model tends to become dependent from the 2D framework, and I don't like it.

What I did that I split every single class in the model in two, the real model class, which has the capabilities to load its contents from database, knows how it alters its state etc etc... and the representation class that decides the appearance on screen. The latter would contain all the Property classes.

You'll find the same design in any MVC framework, like Swing. it's just that here there's no escape from doing it.

share|improve this answer
    
A framework that forces you to apply good design principles or blows up in your face if you don't. As a .NET guy, this is very familiar to me. –  MattDavey Jul 23 '12 at 12:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.