Lets look at the data layer. I generate really simple data classes, they have a getter, setter and field for the value/reference. For this example I don't care about change notification or null checking:

As an example I defined a data class Person in actifsource:

The template that generates the java class using some helper functions "toJavaType" to translate the actifsource types to java:

For the second layer I generate a simple viewer for each data structure. There is no need to define additional information in the model, I just use the same data. For simplicity I don't care about the type of the properties and create a text field for each one. In a real world example you might create components instead of frames and create specific controls for each attribute/relation type.
The following two screenshots show the viewer template and the output for person:


In the viewer template I also added a main-method and the createExampleValue-method with a protected region to create an example value to display. The running example looks like this:

Now I have two layers that will updated every time when I change the model. It is ensured that there is always both a text field in the view and a data field in the data class. Think about a third layer: a network layer with the serialization code is stored or different output format implementations. You even might have implementations or clients/servers in different programming languages (c++, c#, java). In all cases actifsource takes care about consistency, no more trouble due to missing fields or different order in the serialization/deserialization code between the different implementations.
No comments:
Post a Comment