Link to home
Start Free TrialLog in
Avatar of Arikael
ArikaelFlag for Switzerland

asked on

architecture, Layers and Repository Pattern

Hi experts

I know it's a broad spectrum, but I hope you can help.

I'm implementing an small application for learning purposes, but I'm not sure if I'm understanding all the terms/definitions correct.

let's see, I have the following Projects

the MVC-Project (UI)
the Entitiy-Project with all entities
the Data-Project consisting of the Entity-Framework Model and the repository
the Business-Project which handles business logic

so, if you would seperate into different layer, it would look like this:

Data Access Layer
- Data Project

Domain Layer/Business Logic Layer
- Entitiy Project
- Business Project

Ui-Layer
- MVC Project

is this correct?

Is a Service Layer the same as a business layer?
when using the Repository Pattern, you do not create repository for every entity right?
Instead you create aggregates, which handle multiple entities
example:
PersonRepository
handles Persons and PersonAddresses

Does it make sense to have a entity project and a business-logic-project?
I actually could merge them, couldn't I?

if I leave it in two projects entitiy-project would consist of simple DTO's and
I would have to create a Business-Class for every entity, right?

So, I know those are many questions :-)
Hope you can help.

I'm working with VS2010 and .NET 4.0 (C#)
ASKER CERTIFIED SOLUTION
Avatar of Vipul Patel
Vipul Patel
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Arikael

ASKER

hehe thanks for your help :)

it's very complex if you are new to all that stuff.

One last (or two ;-) ) question about repositories and Domain Services.
so, a repository should be responsible for aggregates (one or multiple entities).
and a domain service comes into play when it doesn't make sense to put domain logic into an entitiy.

let's say I have a Customer and Products (n-n, just to make it simple) and want to add Products to a Customer.

Should I use a CustomerService or should handle this stuff in the Customer-Class (which would lead to a rather tight coupling between Products and Customers)?

I assume I also would have a CustomerRepository, which leads to the following question.
Aren't the Service and the repository rather similar. Because all the service would do is calling the repository which then adds the data (neglecting the fact, that the service probably does some validation or checks)

thanks



SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Arikael

ASKER

thanks, very interesting.
I read your links (and others, like the DomainDrivenDesignQuicklyOnline e-Book)

just a question about repository and aggregates.
An aggregate is basically just an entity which has some child entities?
Avatar of Arikael

ASKER

thanks for your help. I started implementing my application.
If I have any further questions I will open a new question :)
Avatar of Arikael

ASKER

great help, thanks