Hi Jacob, this is a perfectly fine way to do this. However it's hiding the 
implementation away and braking the Single Responsibility Principle (SRP : 
http://en.wikipedia.org/wiki/Single_responsibility_principle). It would not 
be possible for another developer so see how this code is being changed 
from within the EmailService. However this is done all the bloody time in 
JavaScript :)

Another example would be to place the SRP into the EmailService and change 
the main method. The developer looking at the code would not know what 
function was currently being used but they would have an understanding that 
it could/does change...

There are multiple ways to get this pattern to work but here is a simple 
example: http://plnkr.co/edit/NYHgFy2hx5jeglm5zKir?p=preview
Some advanced ways is to use Closure to change the function whilst not 
allowing direct access to the other functions to be used. For example 
:setContentMethod(arg) and based on arg change the setContent function 
accordingly.

Regards,

Garry Taylor

On Monday, 19 May 2014 14:03:34 UTC+1, Jacob Rief wrote:
>
> Hi Garry,
> this Plunk could be a possible solution: 
> http://plnkr.co/edit/xcGJ8a3qmuNedg60tcpK?p=preview
>
> In your opinion, is this correct and is it the simplest possible way to 
> solve my problem?
>
> - Jacob
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to