Re: Domain Model and Service Layer
- From: "j.andersen" <j.andersen.lv@xxxxxxxxx>
- Date: 2 Feb 2007 02:16:44 -0800
mikeon@xxxxxxxxx wrote:
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
Hi Michael,
The thing I did was to model the user before and after the creation of
the user account, so:
- before, the user is just a visitor. The visitor class knows how to
register a user and to inform the user of the account creation. Also
the visitor class knows how to login a user, thus turning the user
into a member.
- after, the user is a member. The member class knows how to interact
with the whole site.
I am working in PHP and uses Dialog classes to simulate the UI
components, UseCaseControl classes to orchestrate the work, and other
classes to implement the domain.
Hope the above is useful.
John, Latvia
.
- Prev by Date: Specification Pattern vs Data Mapper
- Next by Date: Re: Domain Model and Service Layer
- Previous by thread: Re: Domain Model and Service Layer
- Next by thread: Re: Domain Model and Service Layer
- Index(es):
Relevant Pages
|
Loading