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 <strong>Customer</strong> via a web form. This will fire the Customer.Create() method.
An API consumer / user can add a <strong>Customer</strong> 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.
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?
Have a look at this question and answers given (one mine):
<a href="https://stackoverflow.com/questions/3867978/wcf-and-n-tier-architecture-and-serialization-performance" rel="nofollow">WCF and n-tier architecture and serialization performance</a>
I think your tiers are fine if they are all <strong>logical</strong> 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.Answer2:
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.