|
Replies:
1
-
Pages:
1
-
Last Post:
Sep 28, 2009 6:58 AM
by: simbo1905
|
|
|
Posts:
2
From:
Sri Lanka
Registered:
9/27/06
|
|
|
|
Introduction of Interfaces to Domain Objects
Posted:
Nov 16, 2007 5:41 AM
|
|
Hi All,
In my previous work place we worked on web application which uses "Exposed Domain Model" pattern and our customer wanted interfaces to be introduced to the Domain objects. For example, User Domain object is introduced with a IUser interface which has methods corresponding to getters and setters. And all the DAOs and Services, return IUser interface references to the presentation tier in lieu of User references. For example in UserService,
public List<IUser> retriveAllUsers() { ............. ............. } is used instead of
public List<User> retriveAllUsers() { ............. ............. }
From my point of view this is clearly waste of time and we won't actually expose domain objects to the presentation tier also I have a doubt that this breaks the original "Exposed Domain Model" pattern. I would like to know your opinion regarding this.
Best Regards, dmag
|
|
Posts:
30
From:
London
Registered:
6/13/06
|
|
|
|
Re: Introduction of Interfaces to Domain Objects
Posted:
Sep 28, 2009 6:58 AM
in response to:
dmag
|
|
@dmag "From my point of view this is clearly waste of time and we won't actually expose domain objects to the presentation tier also I have a doubt that this breaks the original Exposed Domain Model" pattern."
In general an interface insulates your clients from the concrete classes. There is a school of thought that you should only pass out DTOs that are a copy of your entities to hide them from your clients which is discussed here:
http://www.manning-sandbox.com/thread.jspa?messageID=91995#91995
Certainly I would say not to return interfaces from your Services (note the capital S the to mean the Domain Model service not the façades). I don't think that it is too much of a break of the approach to return interfaces from the façade. This sounds quite subtle - the differences between the Services and the Façades are discussed here:
http://www.manning-sandbox.com/thread.jspa?messageID=92006#92006
In a lot of applications however this seems like code duplication; just as copying to DTOs looks like code duplication. The sorts of applications where that is the case are those which have entities that are logical records in an system that does mainly database CRUD operations on the database. That distinction and how it seems to conflict with some schools of OO thought to expose the fields of your domain entities is discussed here:
http://www.manning-sandbox.com/thread.jspa?messageID=91995#91995
|
|
|
Legend
|
|
Gold: 300
+
pts
|
|
Silver: 100
- 299
pts
|
|
Bronze: 25
- 99
pts
|
|
Manning Author
|
|
Manning Staff
|
|