Monday, March 18, 2013

Follow Best Practises On WCF Services

If we organize the creation of WCF Services into this way , it will be efficient and can be changed in future without much efford.

1.  Create ServiceContract
     - Create Interface
2.  Create OperationContract under that ServiceContract
     - 
3.  Create Business Object (eg : employee)
     It has all required business parameters

4.  Return Data Transfer Objects (DTO) (eg : employeeDto)
     it has only the required parameters for that service. every services can have it's own Dto objects.

5.  Create Data Access Objects (DAO) (eg : employeeDao)  
     It is the object directly involve with data layer to get required data then process the data and map  it to business objects.

6. Create Object Mapper class (eg : ObjectMapper) and Mapper functions (eg : EmployeeDaoToDto) between DTO and DAO.
    Before send the objects to client side browser , services must convert the business objects to Data transfer objects. So mapping functions map the Data transfer object with business object.