Advantages of Using .NET Framework 2.0

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 9

Advantages of using .NET Framework 2.

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

Other New Features


• Web pages can be configured not only through web.config, like in .NET 1.1, but also
through web access and MMC snap-in module available in IIS console.
• Application might be monitored on production environment (also on web farms) and
health-monitoring events can be created and recipients can be mentioned about them.
• URL mapping provides redirecting of one URL to another by definition in XML
format in web.config file.
• Profiles serve as persistent storage of user data. Unlike session state variables profile
values are strongly-typed and they have unlimited lifetime. They are defined in
web.config file.

Visual Studio 2005


Code Definition Window
It is a read-only editor view that displays the definition of a symbol in a code file stored in, or
referenced by, the active project.

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.

Edit and Continue


It is a time-saving feature that enables you to make changes to your source code while your
program is in break mode. This feature has been implemented in Visual Studio 6.0 already,
but has been refused in VS 2002 and VS 2003.

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.

Visual Studio 2005 Team System


This highest edition of Visual Studio 2005 divides individual members of development team
to several categories and provides appropriate tools for each of them. The categories are:
• architect
• developer
• tester

System Definition Model


Visual Studio Team System edition introduces a new vision named System Definition Model
(SDM). SDM is formal description of entire system. It contains (among others) the following
information:
• system topology
• developers requirements
• IT policies
• installation instructions
It also contains description and requirements of separate application and the same information
for a system that represents a group of related applications. SDM also holds information about
relationships among applications.

Distributed System Designers


These tools decrease complexity of design and development of distributed system. They allow
automatic synchronization between model and code. Another advantage is better
communication and comprehension between developers and administrators. There is a
possibility to validate system design against production environment. It means that the
environment meet the application requirements, e.g. operational system, communication
protocols, 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.

Code Analysis – Static


Static analysis analyses existing compiled code via reflection. Idea of static analysis rises
from two existing products – FxCop and PREFast. It checks code against various rules from
naming conventions to potential security holes. It is implemented in Team Foundation Server
(see below).
Code Analysis – Dynamic
It is also known as a profiling. Profiling analyses running code and collect data such as stack
information, time, memory allocation, etc. There are two ways of measurement:
• Sampling – it collects information in regular intervals
• Instrumentation – it collects information about every call of code block
Profiling results can be visualized direct in Visual Studio environment.

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.

Web Application Testing


New testing tool of Visual Studio 2005 is a successor of previous tool named Application
Center Test (ACT). Unlike ACT the new tool is oriented to test the functionality of
application as well as to load test. With the assistance of this tool is possible to test any HTTP
communication and web service.

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.

Team Foundation Server


Team Foundation Server (TFS) is a server part of Visual Studio Team System. There are two
primary goals that TFS brings:
• improvement of work productivity in the team
• improvement of predictability of project development
TFS is built on base pillars:
• productivity – easy, comfortable, accessible and naturally integrated tools
• integration – individual tools used in different project phases are tightly integrated
• extensibility
• innovation – this is a new approach to project development
• long-term approach – Microsoft has a clear vision for further pointing of this product

Microsoft Solution Framework


TFS affords methodologies for project management packaged in Microsoft Solution
Framework (MSF). There are two methodologies by default:
• MSF for Agile Software Development
• MSF for CMMI Process Improvement
The first of them is an easier implementation of the second one. Particular principles and
content of each methodology is not a subject of this document. There is a possibility to
implement the own methodology or the other one provided by a third-party.

Source Code Management


The new tool integrated in TFS extends and replaces Visual Source Safe product. Microsoft
develops a MSSCCI client that will be providing access to the new code management tool for
older versions of Visual Studio.
Basic data about the new source code management tool:
• it uses SQL 2005 as a storage
• stored files are accessible via HTTP or SOAP
• Windows accounts are used for users authentication
• there are a few innovative features:
o atomic check-in (changeset); it allows all-or-nothing check-in
o integrated check-in; it allows attaching of other (mandatory) data, like
comments, metadata, policies, etc. with each check-in
o parallel development of an application
o shelving; it’s a kind of branching of source code
• there is a tool for data migration from Visual Source Safe
Source code management is integrated with Visual Studio 2005 as well as with TFS.

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

You might also like