Sam
Sam

Reputation: 15771

Onion Architecture questions?

I have a few questions regarding the Onion Architecture and MVC.

1) What are the differences between Domain Services and Application Services?
2) How does the Service/Repository/UnitOfWork pattern fit into this architecture?
3) Do you think this architecture is a good plan for an MVC application?

Any thoughts on this would be greatly appreciated.

Upvotes: 1

Views: 592

Answers (2)

Boa Hancock
Boa Hancock

Reputation: 1

The main difference between them is that domain services hold domain logic whereas application services don't

The unit of work provides the ability to save the changes to the storage (whatever this storage is). The IUnitOfWork interface has a method for saving which is often called Complete and every concrete repository as property.

Yes!It provides better maintainability as all the codes depend on layers or the center. It provides better testability as the unit test can be created for separate layers without an effect of other modules of the application

Upvotes: 0

Stephan Schinkel
Stephan Schinkel

Reputation: 5530

  1. A DomainService is a service you use inside your domain. A ApplicationService is a service you expose in your domain to other layers.

  2. What Service? A repository is usually defined as interface in your domain model. your domain model is working only with the interface. the concrete repository is loaded via dependency injection and lies in an infrastructure or persistence layer.

for example

public class RegistrationService : IRegistrationService
{
    private IUserRepository mUserRepository;

    public RegistrationService(IUserRepository userRepository)
    {
        mUserRepository = userRepository;
    }

    public void Register(string name, string password)
    {
        var user = new User(name, password);
        mUserRepository.Add(user);
    }
}

(hopefully syntax correct)

the RegistrationService in this example is an DomainService. On the other hand an WCF Service is an ApplicationService.

Upvotes: 3

Related Questions