Enterprise Application Architecture: Designing Applications and Services in .NET - Part I

A guided tour of the distributed enterprise application design in .NET

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:).

Share

About the Author

Venugopal works as a Senior Software Engineer in Logitech Engineering & Design (India) Pvt. Ltd. He hold a Masters in Computer Applications and has 4+ years experience in C#, XAML, Silverlight & WPF.

Venugopal firmly believes "technology is impermanent, change is not"!. While he has strong technical inclination towards MS technologies, he is deeply passionate about pursuing his career in Windows7-WPF and Silverlight Technology.

Venu engages in a wide gamut of temperamental hobbies ranging from making friends, traveling, helping his friends studies. To murmuring songs and watching movies in leisure time.

Sorry for not providing enough information on that your expectation. Could you please let me know what is your expectation and what information is missing thorugh out the article. i will try to cover in further.

In my experience over the last 10 years I have seen software over complicated and in other times, under designed. I have seen patterns upon patterns to accomplish the simplest of tasks. I have also read many articles on design layers and patterns, but very few seem to point out when they should be utilised. It's not all about size (enterprise solutions) as I was brought onto a large, 100's of million dollar, project that was very late and over budget. The first thing I noticed was that there were so many abstraction layers that identifying what the code was supposed to do was a nightmare and tracking down issues was just as difficult. The task was simple and could have been solved with a couple of simple classes but instead it had reading abstractions, observer patterns, factories and many other design layers. In this particular situation it became a nightmare to maintain. So I believe anyone reading this article as a "beginner" architect I hope before designing a solution with all these layers, steps back for a second and thinks about what I am accomplishing by adding these layers and are they needed. That is do I need a data abstraction layer? Will this software be ported to other data storages? Do I need the business layer? Is the business layer that complicated that I need to isolate it for testing? Do we have the man power to maintain and build it using so many layers? What's the time frame that we need to deliver in? Is it expected that the software will continue to grow into the future? That's my 2 cents anyway.

"Facts are meaningless. You could use facts to prove anything that's even remotely true!" Homer Simpsons3wareFamily Business

Really thanks for sharing your experience here. It will be really useful for readers. Even for me also, I will try to cover "when to use this architecture" with some practical scenario. If you have any practical scenario in your experience, please share with us.
I have posted my second part here.
http://www.codeproject.com/KB/architecture/EnterpriseAppArch_Part_II.aspx
You can just have a look into it and let me know if I missed anything.
Once again thanks for sharing your exp.

Thanks for your vote. I clearly mentioned this in article. i want to show how to implement step by step.

"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 have posted Part -II here and waiting for approval from members. You can see part-II to get idea about our journey

1) What is new in this article?
Enterprise architecture design basic in practical. You will feel this when you read further parts of this article. I am pretty sure on this.

2) Who do you think the audiance must be?
I clealry mentioned about this in begining of the 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"

3) Why dont you demonstrate with some source code?
Yes. As you know, this part is architecture basic. So there is no implementation code.Further parts will have complete implementation.