Decoupling model from the service

stephenadams1's Avatar


23 Sep, 2011 04:21 PM


I'm working on a service layer, and I noticed that I had a direct call into one of my model classes, which is ok for loading one type of file. Now I'm in the process of rewriting this service to load two separate files, the service is being called twice.
The second time the service is used is to load a different type of file, which I load into a different model. This makes me think that my service should be decoupled more from the model.

Looking at the RL diagram is shows that the service can make direct calls into the model, but now I don't like this approach. What other approaches are there to separate the mode from the service layer?



  1. 1 Posted by Stray on 23 Sep, 2011 04:27 PM

    Stray's Avatar

    Your service can dispatch events containing VOs with the loaded data, and then your model can be updated in a command. And, of course, the reverse - models can dispatch events with VOs, and the command can pass the VO to the service when it calls it.

  2. 2 Posted by stephenadams1 on 26 Sep, 2011 01:49 PM

    stephenadams1's Avatar

    Brilliant, thanks for the answer. Been implementing it today. The Robotlegs book should arrive in the post any day, looking forward to it.

  3. stephenadams1 closed this discussion on 29 Sep, 2011 08:49 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac