Can someone guide me in how the WCF, DAO and DTO layers communicate with each other? I would appreciate if someone can specify which layer comes first and then how it interacts with the next layer and so on.
Asked
Active
Viewed 2,529 times
1 Answers
4
Looks like you have no idea what do these terms mean. First of all non of them is a "layer".
- WCF - Windows communication foundation - MS technology for building service oriented applications
- DAO - Data access object - object exposing operations to interact with database (load object, save object, etc.) but internally hiding details about database.
- DTO - Data transfer object - special type of object used to tranport data from one layer/tier to other layer/tier.
So example usage of these terms in real architecture can be:
Data Tier (Db server)
- Running database
Business Tier (Application server)
- Data access layer using DAO to access DB and to hide DB details from higher layer.
- Business layer using data access layer to access and persist data. Running all domain logic, workflows, business rules, etc.
- Service layer implemented in WCF exposing business operations from business layer. Service layer exposes web services which use DTO to transfer data. Domain / business objects are converted to and from DTOs.
Presentation Tier (Web server)
- Presentation layer - ASP.NET application using service layer to communicate with business tier. Service layer and presentation layer exchange only DTOs.
This architecture is only for big projects. Usually you don't need to separate presentation and business tiers and so you don't need WCF service layer. In such case your presentation layer can access business layer directly without using DTO.
Edit:
Based on your comments I'm adding these informatios.
- NHibernate's
Session
can be called DAO because it provides operations to interact with DB but it also hides DB's details. - When using NHibernate you have set of classes which can be persisted to DB based on defined mapping. NHibernate stores and loads these objects. You can add some logic (methods) to these classes and call them Domain/Business objects.
- DTO is special type of object which doesn't have any logic. It is juse crate for data. It is usually designed to transfer only data the operation actually needs (for example you will not transfer whole customer objects if you only need names and emails). DTO should be also designed to transfer data from multiple business objects to reduce roundtrips between client and service.

Ladislav Mrnka
- 360,892
- 59
- 660
- 670
-
Thanks a lot for replying. Can you just briefly explain that how will the Business/Domain Objects, DTO and DAO interact, as we have to use all of them in our design? And which of these objects actually correspond to the Tables in the database such that manipulation of these objects causes a change in the database table as well? Also we are going to use NHibernate, so will this be used in the DAO? – Huzefa Kagdi Feb 26 '11 at 07:11
-
2This is wrong way to do architecture. Build your architecture and use patterns when you need them. Do not build architecture just to use patterns - it always result in overcomplicated design. – Ladislav Mrnka Feb 26 '11 at 10:19
-
The problem that we have is that the application has been partially (1 Functional part of it) built by a third party vendor and now the client has asked us to build the second functional part carrying of where the earlier developers have left. But we are not getting a code walkthrough for the previously built part of the application. But anyways would like to sincerely thank you for the effort that you have put into answer my basic question. – Huzefa Kagdi Feb 26 '11 at 13:05