tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/273-best-practice-for-moving-data-between-services-and-modelsRobotlegs: Discussion 2013-04-28T10:26:13Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/28019402010-09-03T09:24:52Z2010-09-03T09:25:02ZBest practice for moving data between services and models?<div><p>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?</p>
<p>a) Inject the model into each of the services and use setters directly on the model.</p>
<p>b) Use commands that listen for services.LOAD_COMPLETE and then shove the accompanying data into the model via setters.</p>
<p>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?</p></div>Davetag:robotlegs.tenderapp.com,2009-10-18:Comment/28019402010-09-03T09:37:37Z2010-09-03T09:37:37ZBest practice for moving data between services and models?<div><p>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.</p></div>Shaun Smith