13-11-2012, 01:28 PM
ASP.NET 3.5 Application Architecture and Design
aspnet-3-5-application-architecture-and-design-sample-chapter-chapter-5-model-view-controller.pdf (Size: 955.29 KB / Downloads: 128)
ASP.NET 3.5 Application Architecture and Design
The world of web development, as we see today, has undergone many dynamic changes
shaped by multiple new technologies and platforms. Over the last few years Microsoft
ASP.NET has quickly evolved to become one of the most famous platforms for
developing web-based solutions. Since early 2002, when the first version (1.0) of
ASP.NET was released, Microsoft has continuously added many out-of-the-box features
and components, making web development easier for the end developer. In a very short
time span, the ASP.NET platform has grown and matured into a stable object-oriented
framework, with a large set of useful tools and a huge class library, attracting widespread
interest in the developer communities around the world. With the introduction of LINQ,
MS AJAX, WCF, WPF, and a lot of exciting new tools, the .NET framework has not
only grown large but also flexible, in terms of the choices and options being offered to
the developers.
With all of these new technologies hogging the limelight, an ever-increasing gap was
created in the mindset of new developers, due to a shift in priorities. Developers,
especially beginners, were attracted by the buzz created by these new, cool tools, and
started interpreting them as a solution for better architecture and design, losing focus on
the core concepts in the process. A developer, who has just learnt the basics of ASP.NET,
was more eager to devote his or her time to technologies such as AJAX and LINQ instead
of learning and implementing design patterns.
What This Book Covers
will introduce you to architecture and design in ASP.NET, including tiers,
layers, and logical structuring.
discusses the advantages and disadvantages of using the simplest and easiest 1-
tier, 1-layer default architecture in ASP.NET. You will also understand when and why we
should use out-of-the-box data source controls, and how the 1-tier, 1-layer style is tightlycoupled
and is not flexible or scalable.
Chapter 3 discusses what an ER diagram is, the domain model, the basics of UML, and
what an n-layer design is, and how it increases the flexibility and maintainability of the
code when compared to a 1-layer architecture. A sample project is explained with code in
a 3-layer model. The drawbacks or limitations of this model are also discussed.
Chapter 4 talks about n-tier architecture in ASP.NET and how to implement it. It also
explains Data Transfer Objects and how to use them with 4-tier and 5-tier web solutions.
In Chapter 5, you will learn and understand what MVC design is, and how the ASP.NET
MVC framework helps us quickly implement MVC design in our web applications.
In Chapter 6, you will learn how and when to use the most common design patterns in
ASP.NET: Factory, Dependency Injection, Singleton, and others.
explains why we need SOA, explaining the advantages of SOA for a beginner.
A sample project using SOA architecture is discussed. The chapter also explains how the
Windows Communication Framework (WCF) compliments SOA.
Model View Controller
These days, Model View Controller (MVC) is a buzzword in the ASP.NET
community, thanks to the upcoming ASP.NET MVC framework that Microsoft
is expected to launch soon (at the time of writing of this book, only Preview 5
was available). This chapter is dedicated to MVC design and the ASP.NET
MVC framework.
In this chapter, we will learn about MVC design patterns, and how Microsoft
has made our lives easier by creating the ASP.NET MVC framework for easier
adoption of MVC patterns in our web applications. The following are some
highlights of this chapter:
Problems with Page Controller Design
In the page controller design we have a controller for each distinct page in our
application (a separate code-behind class having all of the logic that fi res sequentially
as each page loads according to the ASP.NET page life cycle). So for big projects,
there could potentially be a lot of code in the code-behind fi les, creating problems in
code maintenance and support.
GUI Unit Testing
Separating business logic and data access code from the GUI is one of the steps
leading towards a better design. In the previous chapters, we saw how to implement
a basic n-tier architecture using tiers and layers to achieve loose coupling. But testing
the application, especially the GUI and the code-behind classes in a page controller
based model, is very diffi cult because the only way to test something like a button
click's code-behind event handler is to click the button itself! This means that if we
put more and more code in code-behind classes (which inevitably becomes the case
in large web applications with lots of UI controls),