Introduction
This article is an attempt to show how to implement distributed application in .NET Framework from scratch. Indeed I can share my experience which I hope will be useful for architects (obviously beginners in architecture design) or a lead developer wants to become an architect to start with. The application will contain a simple web client CustomerOrderManagement
System with our own distributed application platform.
The application will cover the following parts:
- Part 1 (Distributed Application Layers with project details): Learn about what is layered design in distributed environment and how we are going to name it while implementing the actual app.
- Part 2 (Database and Library Design): Learn about database design and implementing library which interacts with Edmx container.
- Part 3 (Engine and Service Managers design): Learn how to implement the engine which has core business logic and implementing the actual WCF service with service contracts, and also how to test the service using test client.
- Part 4 (Client implementation): Learn how to implement the actual client with MVVM pattern which invokes services.
I will try to post the remaining parts ASAP.
Prerequisites
In order to run WCF service, Database design and Silverlight application, you need the .NET Framework version 3.0, or greater. Windows Vista has the .NET Framework v3.0 installed by default, so you only need to install it if you have Windows XP SP2. To develop distributed enterprise applications, you should have Visual Studio 2008 or a later version of Visual Studio, SQL Server Management Studio Express 2005 and also the Windows SDK. Article source uses VS2010 and SQL Server Management Studio Express 2005.
Why Should I Read This Article?
You can ask this question when you read the title of the this article. If you are an architect or a lead developer who aspires to architect solutions, spend some time on this (sorry to take your valuable time). When you complete this article, you will feel that you can design any complex application very easily. I am pretty sure about this. However I am not going to talk about design principles in depth. If you want, you can learn it from Microsoft site which describes everything very clearly. In my view, describing the concepts theoretically again and again without practical implementation doesn’t make sense. So I will describe directly what, why and how to do that in real time. I always like action instead of reading action story:). Designing complex application is not an easy task. As everyone knows, many decisions need to be taken at the architecture, design, and implementation levels. These decisions will have an impact on the abilities of the application security, scalability, maintainability, and availability. This article will help you to design your application with clear separation between the layers such as Data Layer, Business Layer, Service Layer and Presentation Layer from scratch. Let’s start with action.
What Are These Layers and What Should They Provide?
Let's start by visiting each of these layers and discuss what these layers should provide and what they should not. Figure 1 shows the simplified logical component layers that this article uses to design the architecture. I am not going to include many components here again. Just see figure 1 and understand the purpose of this article right away.
(Figure 1 – Enterprise Application Layers)
- Presentation Layer - Contains user related functionality for managing user interaction with the system, and generally consists of service calls for communicating with business logic through service layer.
- Service Layer - Consists of service contracts and message types to communicate with the business logic to separate the business layer as an independent layer. Also this layer can be located on different tiers, or they may reside on the same tier.
- Business Layer - This layer implements the core functionality of the system, and encapsulates the relevant business logic. It generally consists of components, some of which may expose service interfaces that other callers can use.
- Data Access Layer – This layer communicate with database to retrieve and save the data in database using its own context. This data access layer exposes generic interfaces that the components in the business layer can consume.
- Data Layer – This layer contains the actual business raw data. DBA can design and maintain this layer.
How Do We Implement and By Using What Technologies?
Let’s take figure 1 and add another figure along with that to describe how to implement customer order management enterprise application from scratch. Before I start discussing, I will consider some component from the layers as platform. Because this platform can be hosted anywhere and client can consume whatever they need through network. This is called distributed environment. Here we will consider our business layer, service layer and data access layer as a single platform. So those multiple client platforms (Mobile, Web, etc) can utilize our COMS(CustomerOrderManagement
System). This is the major advantage of our COMS. See figure 2 and get an idea about how we are going to implement our COMS platform with technology details.
Note: Please note that COMS refers to the CustomerOrderManagement
System throughout the article.
(Figure 2 – Enterprise Application Layers With Project Details)
- Service Libraries (Data Access Layer) - This interacts with entity framework through edmx entity container and also provides data to the service engines. We will talk more about this when we come to the library implementation.
- Service Engines (Business Layer) – This contains core business logic implementation and it interacts with service library to get the actual database without contacting database directly. All the business validation should be implemented here for extensibility. We will talk more about this when we come to the engine implementation.
- Service Managers (Service Layer) - This layer exposes all the COMS system functionality as WCF service which can be accessed by client from any platform. Manager never interacts with database or library directly. Because business layer contains all the validation which needs to be invoked before sending the response to the client. We will talk more about this when we come to the service manager’s implementation.
- Client (Presentation layer) – The actual user interface which calls services. This can be any rich client, web client or mobile client or another service call. I am going to use Silverlight for implementing web client in this article. If it’s possible, I will try to post some mobile UI implementation also for testing our COMS platform as part of this article.
To be frank, I don’t know about Mobile app implementation, so I will learn and explain in one part how to make use of our COMS platform services in mobile platform. But you have to trust me and wait for a couple of weeks:).
History
- Initial version of this article created on 09/20/2010
- Published on 09/21/2010
- Part-II link updated on 09/27/2010