Using Web Services in a 3-tier architecture
During the age of the Windows DNA, most of us developers used COM/COM+ and a 3-tier architecture. Where we separate concerns by placing the views to present data into a layer called PL (Presentation Layer), we add all business logic into one single layer called BLL (Business Logic Layer), all code that handle data access was also placed into its own layer called DAL (Data Access Layer). During this time when Windows DNA was a hot topic, most application used this architecture.
By using DCOM it was easy to distribute the different components in the layers into distinct tiers. DCOM had its advantage and also disadvantage (DCOM hides the "distribution" and distribution could be done after application was written without the developers awareness, most applications wasn't designed for distribution purpose.). There was few application I was involved with that used DCOM, and I will in this article focus on the application that didn't use DCOM. The 3-tier architecture was well defined and common used. Several applications today used this architecture. When .Net arrived several developers was scratching their heads, it was a whole new platform for most of them and a difficult and confused time began, "how should this 3-tier architecture be applied on the .Net platform?". Web Services was introduced somewhere around this time and that was a bright light for some solution architects and developers, now they understand how to apply the 3-tier architecture on the .Net platform, the answer was to replace COM/COM+ components with Web Services. So instead of using a binary standard for the communication, XML and HTTP was used.
Even today several applications uses the 3-tier architecture with Web Services as a replacements for COM/COM+ and even a replacements for DCOM and that is understandable. But replacing COM/COM+ with Web Services for applications on a single machine, with no reuse or integrations with other applications in mind, is something that make me sad. Now when we have WCF (Windows Communication Foundation), developers start to replace Web Services with WCF. There are several applications running on a single machine with no attention of integration with other systems that uses different WCF Services for the Business Logic and the Data Access. I will not say that this is totally wrong decision made by architects, but it will affect performance and scalability, and can affect it badly. There is absolutely no reason to use WCF Services if the application is running locally or on a single machine where no integration with other systems are of interest. Even if there are integration in mind, there is no reason to have the Data Access Layer as a WCF Service, because most applications will reuse the business logic, so the layer top of the Business layer should be a WCF Service not the underlying layers. There are some exceptions, if we have moved the Data Access Layer into a distinct tier, and several applications should reuse or have access to the same data source; but can't or aren't allowed for a direct connection to the data source, the Data Access could be implemented as a WCF service. In that case all communication will go via the WCF Service.
If there is no reason of using Web Services or WCF Services as a replacement for COM/COM+ in applications with not interest in integration, what is the solution? A simple Class Library! Best performance, easy to add, easy to implement. Since .Net arrived I toke the advantage of the platform and use Object Oriented Programming. Now during the past few years I have adopt Domain Driven Design. How about you, do you still use the 3-tier architecture and using Web Services of WCF, or something else?