Re: Domain Model and Service Layer



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

.



Relevant Pages

  • Re: A REAL Debate
    ... One member from the Creation frame of mind, ... Evolution frame of mind, along with one moderator. ... I would point out that this is Usenet - anyone can post to usenet. ...
    (talk.origins)
  • Re: A REAL Debate
    ... REAL-PROPER-FORMAL-CIVIL debate? ... One member from the Creation frame of mind, ... Evolution frame of mind, along with one moderator. ...
    (talk.origins)
  • Re: A REAL Debate
    ... REAL-PROPER-FORMAL-CIVIL debate? ... One member from the Creation frame of mind, ... Evolution frame of mind, along with one moderator. ...
    (talk.origins)
  • Re: A REAL Debate
    ... One member from the Creation frame of mind, ... Evolution frame of mind, along with one moderator. ...
    (talk.origins)
  • Re: A REAL Debate
    ... REAL-PROPER-FORMAL-CIVIL debate? ... One member from the Creation frame of mind, ... We Need Fresh Creationists! ...
    (talk.origins)

Loading