Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF Service and Business Logic

I am unsure where to place my business logic. I have a WCF service which exposes its methods to my client.

Should my business logic go in the service method

public User GetUser(int id)
{  
     //Retrieve the user from a repository and perform business logic
     return user;
}

or should it be in a separate class where each WCF service method will in turn call the business layer methods.

public User GetUser(int id)
{  
     return _userLogic.GetUser(id);
}
like image 604
ministrymason Avatar asked Dec 05 '11 16:12

ministrymason


1 Answers

My personal preference is to have WCF as a very thin layer on top of a separate business layer. The WCF layer does nothing more than make calls to the business layer, similar to what you have shown in option 2. This gives you some flexibility in the event that you want to have your business layer consumed by something other than WCF clients (for example, a WPF application calling your business layer directly rather than via WCF).

like image 130
chris.house.00 Avatar answered Oct 20 '22 04:10

chris.house.00