[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 954
  • Last Modified:

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

- 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
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#)
  • 4
  • 3
2 Solutions
Vipul Patel.NET ExpertCommented:
Huh!! Lots of questions:)

Let me try to answer those questions.
1). is this correct?
A). Yes

2). Is a Service Layer the same as a business layer?
A). Nope.
In a business layer(BL), there might be lots of business logic/features. But requirement wants to expose a few features from the BL to third parties (customers of the client).
e.g. PlaceOrder, CancelOrder are features implemented in BL. But client wants to expose only PlaceOrder publicly. So customers of the client use "PlaceOrder" function in their application for placing an order. But an order can be cancelled by calling to client's Call center (which is opened 24x7).

Consider Paypal API, lots of people are using Paypal api/features. It does not mean that whatever features ,are publicly accessible, provided by Paypal are the only features available in the Paypal application.

3). when using the Repository Pattern, you do not create repository for every entity right?
A). No.
In some class/project, you might/will need to change only person's address.
So, do not expose unnecessary features of the class through an object. If we combine the entities, then in somewhere we will be going to expose unnecessary features. [Encapsulation broken]

4). Does it make sense to have a entity project and a business-logic-project?
A). Yes
If your team having more than one team member then BIG Yes.

Database designer might create column "FName" in the "User" table. And other developer create property "FirstName" in the "User" class.

5). I actually could merge them, couldn't I?
A). Yes
For team size one, BIG Yes.

ArikaelAuthor Commented:
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)


Vipul Patel.NET ExpertCommented:
Repository, Domain, Entity, Layers, Service and more terms will be added in software development process later on.

But fundamental should not be changed!

Hope below links might be helpful to find your answer.

Revert back me if you have any good links or references.
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

ArikaelAuthor Commented:
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?
Vipul Patel.NET ExpertCommented:
ArikaelAuthor Commented:
thanks for your help. I started implementing my application.
If I have any further questions I will open a new question :)
ArikaelAuthor Commented:
great help, thanks

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now