Reputation: 146
What is difference between a service Layer and Business Layer in N layered architecture
I am building N layered application, so I have gone through many resources on N layered architectures which contain layers such as a service layer egs https://prodinner.codeplex.com/
a service class in the above project
public class UserService : CrudService<User>, IUserService
{
private readonly IHasher hasher;
public UserService(IRepo<User> repo, IHasher hasher)
: base(repo)
{
this.hasher = hasher;
hasher.SaltSize = 10;
}
public override int Create(User user)
{
user.Password = hasher.Encrypt(user.Password);
return base.Create(user);
}
public bool IsUnique(string login)
{
return !repo.Where(o => o.Login == login, true).Any();
}
}
So is the traditional business layer same as service layer ?
Upvotes: 0
Views: 1961
Reputation: 4464
The basic difference is Business Layer is to define business logic ( data transformation ) and Service Layer is to access data from different client's. In our projects we often have the following structure:
Service layer:
Publishes the Service Endpoint (this could be your MVC web page, or a WCF endpoint) Does a security check Maps data from contract data transfer objects to business objects Calls functionality in the business layer
Business layer
Contains business logic Accesses the data layer (this could be your entity framework data model)
Upvotes: 1