Hey,

I have a design question for you. In StreamFlow I want to have a 
stateful application layer, which will record the state of the client 
application. When I switch views this should be recorded in a property 
somewhere, for example. The logged in user should also be in a property. 
The UI layer calls methods in the application layer to change this state.

I have so far been doing this by mostly implementing the application 
layer as Entities. Each part in the application has therefore been 
mapped to an Entity, that has state, so that when the application state 
is updated this could potentially be saved to disk, so that the next 
time I open up the application it will be in the same state as when I 
closed it.

The downside of this is that it's a bit tricky to find the various 
entities. Right now I have a root entity, called NavigatorEntity, which 
then aggregates the other parts. The downside of this is that pretty 
much all usecases has to get the Navigator, and then traverse the state 
of it to get where they want, and then call a method. This seems to 
violate Law of Demeter quite badly.

Another way to do it would be to have all of that be Services instead, 
and then store the application state as the ConfigurationComposite for 
that Service. Client usecase code can then more easily get access to 
whatever service they need by using @Service to inject it.

So, instead of:
@Service NavigatorRepository nr;
..
nr.navigator().search().search(someString);

the client code could do:
@Service Search search;
...
search.search(someString);

which in turn updates the ConfigurationComposite of the service. Would 
work too, and does not violate LoD.

Whaddya think? How would you do a stateful application layer?

/Rickard

_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to