Best practice for moving data between services and models?

Dave's Avatar

Dave

03 Sep, 2010 09:24 AM

Right now I've got a couple of services loading external data (this is only done once at startup, it's not an ongoing thing). The services then process that data from it's native format (XML or whatever) into a more app appropriate format. From here I'm putting it all into a model which will provide central access to the rest of the app. What's the best way to get the data loaded by the services into the model?

a) Inject the model into each of the services and use setters directly on the model.

b) Use commands that listen for services.LOAD_COMPLETE and then shove the accompanying data into the model via setters.

They both accomplish the same thing as far as I can tell, except (b) is another layer of abstraction - slightly more code and less coupling (at least in the services). Right now I am leaning towards (b). Does this pass the "RL way" test or is there another way I haven't considered?

  1. Support Staff 1 Posted by Shaun Smith on 03 Sep, 2010 09:37 AM

    Shaun Smith's Avatar

    Do you need the de-coupling provided by option b? Is it worth the extra code and abstraction? The goal is appropriate coupling, not zero coupling.

  2. Stray closed this discussion on 16 Feb, 2011 09:06 PM.

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

Keyboard shortcuts

Generic

? 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