How to separate a model from a view?

I have a bunch of model objects.

These objects are ultimately displayed as views (for example, forms) in a rich client application.

I started annotating the fields in the model objects (Java annotations) to things that allow me to display them as forms on the fly (e.g. displayname, group, page, validvalues).

Now I understand that the view has crept into the model.

How to separate presentation logic from model objects?

TECH: Java, Java Annotations, Eclipse RCP

EDIT: My question is theoretical, but I would also like to get some specific recommendations (recommendations).

+3
source share
5 answers

, , , , - . - , , . .

, , , "". ; , . , "" , , .

+1

:

@DisplayName("My Fancy Name") 
@DisplayGroup("My Fancy Group") 
public String myProperty;

:

Descriptor desc = new Descriptor(MyClass.class, "myProperty");
desc.setDisplayName("My Fancy Name");
desc.setDisplayGroup("My Fancy Group");

, ( Java, Java ).

+1

MVC , .

, , ,

0

, () () ? - ( ) , - .

(, @Textfield), . (, ), . *.ui . ;)

... jface! MVC/MVP!

0

, .

.

, .

.

You should not have methods on the model that display the model as a representation.

0
source

Source: https://habr.com/ru/post/1747383/


All Articles