API Architecture

I am developing an API. I would like to know if what I came up with is a good solution:

I have a data warehouse data type that speaks to a database, converting business classes to entities (created from LLBL GEN, I didn’t want to use objects directly as my business objects, because I wanted to keep them simple and let me change places on the Entity Framework or some other mapper I need)

I have a WCF service layer that I use as a facade type. It invokes the repository layer and converts business objects to DTO and passes them through an API service call through a message to the client. The client can be an ASPX website, a Silverlight application, a WPF application, or even a WP7 application. The problem that I continue to work with is when I want to start the business logic, I have to send the DTO back to the WCF service, and then return to the client. This does not seem “right” to me. I cannot put business logic in the DTO because it defeats the goal. But if I want the business type code to work on the client, I have a lot of code duplication on my different clients.

My business layer does not know the data layer, my data layer knows about the business layer, and my facade layer knows the data layer, business layer and DTO. Is this a bad design for the API? And can anyone suggest me any suggestions? I just found out about enterprise-level applications by reading various articles on the Internet.

Thank!

+5
source share
2 answers

Relations between layers

If I understand your design well, the business layer does not know (= does not use) the data layer, and the facade actually connects them, converting the DAO to DTO and vice versa.

: , ( DAO DTO), Inversion-of-Control - . , -. , , , -.

- , IoC, , .

DTO

, DTO . DTO (1) (2) . DTO (1) (2) . , , back-end DTO, .

, back-end DTO , DTO, DTO. , , back-end, .

API Get/Update, :

CustomerDTO GetCustomer(int customerID);

CustomerDTO UpdateCustomerAddress(int customerID, AddressDTO address);

CustomerDTO UpdateCustomerPrimaryContact(int customerID, PersonDTO primaryContact);

DTO, , ​​( ). DTO , , . , , , , .

- : , AutoMapper (#), DTO DAO. , , , . , , DTO.


: , , .

+4

- , -, , - DTO. API?

.

WCF, . - DTO API . - ASPX, Silverlight, WPF WP7.

, You Aint Gonno Need It, , () .

, . , , , WCF.

WCF , .

, , WCF. ( IoC)

- (), . , interace, : http://martinfowler.com/eaaCatalog/separatedInterface.html

+3

All Articles