1
votes

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!

2
Note that WCF is the replacement for Remoting and what you are referring to as "web services" (by which, I suppose you mean ASMX web services). - John Saunders
John - The last project I worked on was a .NET remoting project. I interchange terms some times. This new project I am working on is a 3.5 web application. I have not settled the technology for the remote calls across the wire, but I need to expose an API that users can HTTP-POST to (first iteration) and I'd like to re-use the API for my presentation layer, since API and PRES has practically the same functionality. Should I be looking at WCF? I am looking around now.. Trying to get up to speed on what's available since 1.1's remoting (lol) - D-Sect

2 Answers

2
votes

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.

1
votes

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

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.