I am creating simple desktop application in javaFX 8 and I would like to be able to save the state of the model and load it next time the application starts. Therefore I am implementing the Serializable interface with all my custom model classes. First they were pure POJOs.But in javaFX application when I want to bind the model to UI, I need to have for example StringProperty variables instead of simple String.I realized that these property variables does not implement the interface for serialization. I am thinking aboutseparate the clean POJO-s and than create wrappers with ObesrvableProperty variables for the UIduplicate the variables in the same class and somehow mark the property variables as transient for serializationadopt other/manual serialization techniqueWhat is the best/general practice here?
Designing the model layer to be serializable
serialization;model;javafx
One common approach is to design your application model in a way that is entirely independent of your user interface framework, and then implement an adaptor between the two. This allows your application to treat its UI as a plugin, which can be beneficial (both for testing and for later addition of features that may benefit from a different UI, e.g. mobile). You can also do the same thing for persistence, and any other dependencies you have.This approach has been given various names (e.g. clean architecture by Robert Martin, hexagonal architecture by Alistair Cockburn).The downside is, of course, increased complexity. 