Domain Model and Service Layer



Hello!

I'm working on a domain model (accorting to DDD) where I represent a
user as an entity.
Creation of a user is handled by a factory i.e.:
UserFactory uf = GetFactory();
User user = uf.CreateUser("name", "login", "email");

What I want to achieve is to be able to send new users an email, when
their account is created.
Where should I put that kind of logic? I understand that sending an
email i.e.: interaction with an external service should be done via
some kind of a service layer object. Where should I use this object?
Possible solutions include the application layer where the create user
call originates from. There I could easily add a call to a service
right after a user is created.
I could put a dependency in the factory class so that it would call
the service.
I could put the dependency in the repository so it calls the service
when object is saved.

What do you think?

--
Michal

.



Relevant Pages

  • Re: why a factory class?
    ... >> The creation of objects is actually a secondary point of the Factory ... "Uncle Bob" sycophant terms for using abstract interfaces to concrete ... dependency - compilation and linking - on lower levels STILL certain ... all MANDATE higher levels eve depending upon abstract interfaces to ...
    (comp.object)
  • Re: graph of behavior - was Re: State vs. Data (was Re: Fans of Template Method with protected varia
    ... >>factory is dependent on the implementation of the classes ... to concrete classes to reduce dependency] while higher levels minimize ... static dependency - compilation and linking - on lower levels STILL ...
    (comp.object)
  • Re: Access subclass attributes from base
    ... factory object with the interface described earlier that implements more than a few lines in the actual factory method and needs to be applied to every one of our factories. ... The subclasses only responsibility is to tell the base class to which interface Instance must conform and which concrete class will be used in the creation, so this is the only point in the creation process in which BusinessObject matters at all. ... Since WidgetFactory only uses the concrete Widget type in its method, not its type signature, there is no dependency between the clients of WidgetFactory and the Widget. ...
    (microsoft.public.dotnet.framework.clr)
  • Re: Association and depency
    ... >> Dependency are represented correctly in code? ... >Here the Car class must exist in order for the Factory class to work, ... >howver the Factory objects send no messages to Car objects, ... The folks behind UML have done a very poor job of explaining UML, ...
    (comp.object)
  • Re: Stiff Records on BBC4
    ... A great record label for sure but a bit before my time. ... I'm more a Creation, Rough Trade, Heavenly or Factory ...
    (uk.media.tv.misc)