Professional Documents
Culture Documents
Advantages of Using .NET Framework 2.0
Advantages of Using .NET Framework 2.0
Advantages of Using .NET Framework 2.0
0
There are two major areas of .NET Framework 2.0 where advantages can be found:
• C# 2.0
• ASP.NET 2.0
In addition, new version of Visual Studio brings plenty of new features. They might be
divided into three sections:
• Visual Studio 2005
• Visual Studio 2005 Team System
• Team Foundation Server
C# 2.0
Generics
Description
Generics allow you to define type-safe data structures, without committing to actual data
types. They improve performance, type safety and quality, reduce repetitive programming
tasks and simplify the overall programming model. This principle was formerly known as
class templates in some programming languages (e.g. C++). In addition, they add
implementation of constraints (class/interface, reference/value type, constructor). C# 2.0
allows creating generics methods and delegates as well.
Potential usability
This feature could be useful for creating collections. At this time there are classes
programmed in OskarMobil.UDS.BusinessEntities.Collections namespace which
create strongly-typed collections. Generics reduce an amount of the code as well as the effort.
Iterators
Description
Iterators help to enumerate a collection. Unlike C# 1.1 where was necessary explicitly define
code to enumerate collection, C# 2.0 provides simplified notation to do this. Based on the
notation compiler automatically can create a nested class for providing of enumeration.
Potential usability
There are many interface methods defined in
OskarMobil.UDS.BusinessEntities.Collections namespace providing functionality that
enumerate collection in different ways (for example see IAccountLevelNrcCollection).
Iterators with keyword yield simplify writing and subsequent using of collection
enumeration.
Partial Types
Description
C# 2.0 allows you to split the definition and implementation of a class or a struct across
multiple files. Partial type support is available for classes, structures, and interfaces. It is
useful in the following cases:
• big type implementation might be divided to some smaller files
• more developers can work on the same class implementation
• automatically generated code is separated from developer’s code
Potential usability
There sometimes happened the situations when two programmers had to write own part of
functionality over the one class. Partial types can handle this kind of situation. In addition,
this feature separates automatically generated code and developer’s code in order to reach
better code readiness and to avoid accidental deletion of developer’s code by automatically
generated code.
Anonymous Methods
Description
This feature lets you define an anonymous (that is, nameless) method called by a delegate.
This is useful when there is no need for multiple targets, and the code involved is often
relatively short and simple. The anonymous method is defined in-line and not as a member
method of any class.
Potential usability
This could be suitable in a situation when having to create a method might seem an
unnecessary overhead. A good example would be when launching a new thread or in case of
simple event handlers.
Static Classes
Description
The C# 2.0 compiler will not allow you to add a non-static member to a static class, and will
not allow you to create instances of the static class as if it were an abstract class. In addition,
you cannot derive from a static class.
Potential usability
Some classes are suitable to become static. For example ConfigurationSettings class from
OskarMobil.UDS.Configuration namespace, ResourceAccessor class located in
OskarMobil.UDS.BusinessEntities, etc.
Nullable Types
Description
It addresses problems with value types which did not have null value in C# 1.1 and caused
obstructions when worked with them. It provides possibility to set null value to a primitive
type.
Potential usability
The lack of nullable types in .NET 1.1 was solved by various work-around in UDS.
OskarMobil.UDS.Common namespace contains classes which might be removed by using
.NET 2.0.
ASP.NET 2.0
New version of ASP.NET offers important innovations mainly in user interface and
friendliness.
Master Pages
Description
Master pages concept presents a “visual inheritance” principle. The principle is based on two
kinds of pages - master and content. Master page defines a general appearance and reserves
position of content by way of place holders. It also can contain an invariable content. Content
page gives content for the place holders. Definitions of these pages are separated from each
other. This concept allows unlimited “recursions” of master pages; it means one master page
can be a content page for other master page and so on. The recursion usually ends with
content page.
Master pages remove redundancy in web pages definitions and direct to fewer files and
controls used in definition of particular web page.
Potential usability
Master pages will be useful for the migration of all UDS pages to ASP.NET 2.0. This
principle significantly helps to design and maintain pages consistently and easily.
New Controls
Description
ASP.NET 2.0 comes with bundle of new more than fifty ready-to-use controls. Mainly there
are GridView (improved DataGrid), DetailsView (for use in master-detail view), several
controls for user authentication, controls for easier navigation such as Menu and TreeView,
etc.
Potential usability
For example, menu control together with SiteMapPath control seems to be good replacement
of current menu implementation.
Cross-page Posting
Description
Unlike .NET 1.1 where postback could be done to the same page only, .NET 2.0 offers an
option to send post back to another web page. Page that receives postback have full and type-
safe access to the page that caused postback. In addition, different controls on the page can
cause postback to different pages.
Potential usability
This feature allows creating a multi-page form that collects different information on each
page. Appropriate part of sales process currently implemented by a few pages with huge of
hidden HTML tags could be simplified this way. However, there are some validation
problems when cross-page posting is used.
Client Callback
Description
Client callback is a form of postback when UI will not be repainted as a whole, only involved
part of UI will be refreshed and it will be done by client side. It works as following: Client’s
callback manager creates and sends an asynchronous XML-HTTP query to the server. Server
accepts and processes the query, but does not redraw the page. Callback manager receives a
response and notifies the client through registered callback function.
It is a good way to improve UI response. It requires Internet Explorer 5.0 or higher (this
condition is met at Oskar/Vodafone environments)
Potential usability
Due to UI performance improvement this facility could be used on such pages that use
IFrames to do some functionality on the background (e.g. MSISDNSettings.asp). This
functionality might be done through client callback and user can do something other during it.
Validation groups
Description
This feature removes a drawback of .NET 1.1 where all validators have to be valid when page
has been validated. In .NET 2.0 validations are invoked only on the controls enumerated in a
group.
Potential usability
This is very useful when there are page sections to have to be validated individually. For
example, there are three search buttons on product_sale.asp page. If user clicks first of them,
only first text box have to be validated as required field and other ones are out of validation
scope. If user clicks second button, only the second text box have to be validated, and so on.
Localization / Globalization
Description
Localization is improved in the new version of .NET. There is no need to use
ResourceManager class, e.g. for localized text, like in previous version of .NET Framework;
new tag attribute meta:resourcekey links particular value in local resources.
Globalization is extended by global resources storage that serves as a place for resources
accessible for all application pages.
Potential usability
This feature removes a need of ResourceManager class in ASP.NET web pages, so the effort
is lower.
Code-beside Model
Description
This new approach to web page definition takes an advantage of partial classes and divides
automatically generated code and code written by a programmer. The programmer’s code is
more clearly and understandable.
Potential usability
There are the same advantages like described in Partial Types chapter
Provider Model
Description
Provider model concept represents a logical layer between data storages and ASP.NET
services. It allows storing any state data (e.g. site map, user membership or role, etc.) on any
data store (Oracle, MS SQL, XML file, etc.). In the case of changing data store only few
things are needed:
• obtain a new provider and incorporate it in the solution
• configuration change in web.config file
Code outside the provider layer needn't be modified, and before mentioned changes connect
relevant services to the new provider.
Potential usability
TBD
Code Snippets
Code snippets are used to type a short alias, and then expand it into a common programming
construct. For example, the for code snippet creates an empty for loop. They can make writing
program code quicker, easier, and more reliable.
Refactoring
There were been added new functions to improve refactoring. Mainly they are:
• method extraction
• inheritance extraction
• renaming
• parameter extraction
All changes are done through all projects in the solution.
Debugging Visualizers
A visualizer creates a dialog box or other interface to displays a variable or object in a
meaningful way that is appropriate to its data type. For example, an HTML visualizer
interprets an HTML string and displays the result as it would appear in a browser window; a
bitmap visualizer interprets a bitmap structure and displays the graphic it represents, and so
on.
Class Design
There is a quasi UML diagram that provides a view on current code (or a part of code only)
and displays classes and relationships among them.
Visual Studio 2005 offers a tool named Test Bench that tests class at unit level without need
to create an application that hosts objects of the class. Testing of a class is done in Visual
Studio environment via user interface.
Unit Testing
Visual Studio 2005 provides the similar features of unit testing like NUnit. For example:
• initialization / cleanup code on the level of an assembly, a class or a method
• static class Assert for results output
• recall of the same test with different input parameters
It also affords more sophisticated approach to testing as a whole. There are features like
automatic generating of testing classes, administration and management of tests, etc. It also
provides information in graphical representation how the unit tests cover a code; it means
whether part of code is covered by the test or not and how deeply (in percentage) is the part
covered.
Test Manager
Test manager serves to creating and managing the tests. Individual tests are placed in
hierarchical lists (like files in folders). It sets configuration of test runs, also it sets parameters
that have an influence to the test run.
Daily Build
The solution has to have a daily build by Microsoft recommendation. It should be fully
automatic and brings a better transparency of project state. The project is continuously
measured via various key metrics. Performing of tests can be attached to daily build.
Project Portal
Project portal is based on SharePoint Services technology and is designated to facilitate
communication among team members as well as for information sharing. It is suitable for
managers and other non-technician users.
Reports
Reports are produced by SQL Reporting Services and provide information about project.
There is a possibility to create own reports with the assistance of Visual Studio.
Conclusion
New features of .NET Framework 2.0 contribute to better productivity of developers and
make code more type-safe and more readable. Code writing and mainly refactoring is faster,
easier and less error prone. They increase user friendliness of an application, speed-up the
development and make a debugging pleasant
There are more new features provided by .NET Framework 2.0 not currently relevant to UDS
or they have minor significance, but they might be useful in future development of UDS.
References
Information is gained from:
• http://msdn.microsoft.cz/webcasts/
o C# 2.0 (in Czech language)
o ASP.NET 2.0 (in Czech language)
o Visual Studio Team System (in Czech language)
• MSDN October 2005
o Create Elegant Code with Anonymous Methods, Iterators, and Partial Classes
o An Introduction to C# Generics
o description of individual mentioned classes