is it okay for a service to consume a model

itsmylifesoham's Avatar

itsmylifesoham

13 Feb, 2012 06:53 AM

Hi,

I know that a service can update a model directly , which is possible by injecting the model into the service.
but i have a basic question :

Can a service consume a model, as in the get the configuration details?
or is it like the command which is calling the service should be injected with the configuration model and the config values thus fetched should be passed into the service method call form the command.

thanks :)

  1. Support Staff 1 Posted by creynders on 13 Feb, 2012 09:50 AM

    creynders's Avatar

    The most flexible setup is if a command configures the service, either by passing the necessary data to the method it's calling, or by configuring the service upfront (this is my preferred method).
    Injecting a config model isn't such a good idea, since it limits the reusability of your service.

  2. 2 Posted by bulupe on 13 Feb, 2012 11:30 AM

    bulupe's Avatar

    It also limits the services' testability I too prefer configuring service with a command upfront.

  3. 3 Posted by itsmylifesoham on 13 Feb, 2012 02:09 PM

    itsmylifesoham's Avatar

    thanks, that helped :)

  4. Ondina D.F. closed this discussion on 13 Feb, 2012 06:16 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