views:

54

answers:

2

Hello,

We are designing a system that has functionality that is essentially the same at the presentation layer and the exposed API layer. My question is what technique / strategy to use so we can get the most reuse out of our code with performance in mind?

Here's a simplified example:

A user can add a Customer via a web form. This will fire the Customer.Create() method.

An API consumer / user can add a Customer via a SOAP / HTTP-POST to a web service which will call the Customer.Create() method.

Imagine these layers:

PRESENTATION
|
|
WEB SERVICE API (Customer.Create() is available here
|
|
FACADE Business Object Interface - Customer.Create() signature is here
|
|
BUSINESS Business object - Customer.Create method() is fleshed out here
|
|
DATA ACCESS - Writes data

The presentation layer SOAP calls the Create() web method, which calls the facade's Create() method which calls the business object's Create() method which wires via the data access layer.

Questions:

Is there a concern about performance in using the API's web services in our presentation layer, or are there alternatives to connect the presentation layer directly to the facade? If so, what technology to use (WCF, Remoting, Web Services, etc)?

Please let me know if you need any more clarification. I am having trouble finding out if it is common to consume your API in a presentation layer, or do you "go around it" for performance reasons.

Any other concerns that I may not be seeing?

Thanks!

+1  A: 

Have a look at this question and answers given (one mine):

http://stackoverflow.com/questions/3867978/wcf-and-n-tier-architecture-and-serialization-performance

I think your tiers are fine if they are all logical although I would personally not use Facade and instead I would use an ORM for connecting to database.

Regarding technologies, WCF and ASP.NET MVC are so much better choices over web services which is old and ineffecient now. Remoting was superceded by WCF and should never be used now.

Aliostad
+2  A: 

Your Web Service API and the facade are redundant. I'm thinking if you implement the actual objects in each layer, I think you'll find that one or the other of those two layers's objects are just pass-through objects.

The business layer object for something as simple as a CreateCustomer() may seem redundant, also, but for more complex functions, you'll find the business layer brings several atomic calls under one transaction.

James B
+1 - I agree. @D-Sect, If you want to put separation anywhere it should be between the Business and Data Access layers.
Adrian K
That's what I was wondering. No need for an interface interface? Makes sense. Plus - I used "Create" as an example, but it would be base method from the BusinessObject's parent class. I was just demoinstrating a method, but a CRUD one wasn't a good example if taken literally.
D-Sect
I would keep the web service API, that serves multiple clients/presentation layers. Just drop the facade and have the API call into the Business layer. You have the right idea, you need a facade... but the API is the facade.
James B
Just to clarify: Let my pres. layer simply call webmethods - the same ones I use for the API?
D-Sect
Right. Just like you have in the picture.
James B