Adopting the .NET Framework for Web Development

Page created by Jeffrey Salinas
 
CONTINUE READING
Adopting the .NET Framework for Web Development

                                    David Dietrich
                                     Peter Lorimer
                                      Greg Burlet
                                    Mitchell Bosecke
                                     Robin Miller

1     .NET
Microsoft .NET was first released in February 2002 and is currently at version 4.0. Generally,
when people talk about .NET they are specifically talking about the .NET Framework. This
framework is a collection of libraries that permit easy development. However, another part
of .NET is the Common Language Runtime (CLR). This is a virtual machine similar to the
Java Virtual Machine. Code written in C# is compiled into an intermediate bytecode by
the C# compiler, then when it is ran it is compiled into native code by the CLR.

1.1    The .NET Framework
The .NET Framework is a collection of libraries that can be used for developing software
on Microsoft platforms. It supports not only operating systems such as Windows 7, but
also can be used for development for the XBox (by using XNA) and the Windows 7 phone.
These libraries range from libraries for Web Services and Communication to Project Build
and Compilation libraries.
.NET also supports interoperability of languages. One developer could write their code in
C#, and another developer could write their code in VB.NET. Both languages are compiled
into the same intermediate code, allowing complete interoperability. Anything written in
VB.NET could be accessed in C# and vice versa.
The two most common languages used with .NET are C# and Visual Basic (VB) .NET. C#
is an object oriented language whose syntax is very similar to that of Java and C. VB.NET
is also object oriented, however the syntax of the language is unique to the Visual Basic
(VB) family of languages. The syntax of VB is similar to natural language. This similarity
to natural language makes VB relatively simple to learn compared to other programming
languages.
Many people who have developed programs for Microsoft Windows in the past 8 or 9 years
have likely had contact with either C or VB. This would make finding new developers with
the required experience relatively easy compared to using a new language or niche language.

                                              1
2     ASP.NET
2.1    Overview
ASP.NET is a web application framework that supports dynamic websites, web applications,
and web services. It’s primary benefit is the ability to use a full featured programming
language to build a website. A developer can use any language supported by the .NET
framework including VB.NET, C#, Delphi.NET, Chrome, etc.

2.2    How it Works
ASP.NET works in a very similar manner to other web technologies. Initially a user’s web
browser will request an ASP.NET page from the web server. The web server itself will be
running IIS (Internet Information Services), which is a web server application developed by
Microsoft for the Windows platform. The IIS then passes the request to the ASP.NET engine
running on the server. The ASP.NET engine reads the file line by line, executing the scripts
within the file. The file is then returned back to the user’s web browser as plain HTML.

2.3    Pros
There are several benefits of using ASP.NET in comparison to other web technologies. First
of all, as previously mentioned, one can use a multitude of programming languages. Even
within one web application, developers can use a multitude of languages. This can be a
huge benefit if a development team requires the need for multiple languages or simply wants
the freedom to choose the best language for the job. Another benefit to ASP.NET is that
it uses an object oriented approach. Developers with OOP experience can now use all the
benefits of OOP within their web application such as polymorphism, abstraction, modularity,
inheritance, etc. A third significant benefit to using ASP.NET is the included support for
web services and xml parsing. Very little effort from the developer is needed in either of
these two fields. Finally, one of the most significant benefits, is the ease of which a Windows
desktop developer can migrate to web development.

2.4    Cons
Alongside the benefits of using ASP.NET there are also the downfalls which must be men-
tioned. First of all, a Windows platform is needed for deployment. If a company does not
already use Windows, this can pose a significant problem. There is also potential for a steep
learning curve with ASP.NET if the developer is not already familiar with Windows related
development. Finally, if a company is looking for an open source technology, ASP.NET is
not a viable solution.

2.5    ASP.NET vs. PHP
PHP is one of the industry leading technologies when it comes to web development and there
are some significant differences between it and ASP.NET. The first thing to mention is the

                                              2
difference between how they work. ASP.NET is a compiled language whereas PHP is scripted.
The consequence of this is that ASP.NET can potentially provide better performance. When
a user first visits an ASP.NET webpage it is compiled by the ASP.NET engine, however with
every subsequent visit, if the page doesn’t change it does not need to be recompiled. If done
properly, ASP.NET can perform much better than PHP. Another difference between the two
technologies is that the updates to ASP.NET are much more drastic than the updates to
PHP. This means that a company, or developer, using ASP.NET will have to put in more
effort to keep up with these updates. In conclusion, if a company was in a position to decide
between using PHP and ASP.NET it comes down to how much experience that company
already has using the .NET framework. If they are familiar with Windows development then
using ASP.NET would be the way to go.

3     Web Services and Communication
Because .NET is a framework that supports many languages, the primary benefit is the
availability of the libraries that a developer would normally have access to. Modern web
applications, however, also require the ability of communicate with each other in a standard-
ized way. The most commonly used solutions are the Simple Object Access Protocol (SOAP)
or the Representational State Transfer (REST) paradigm.

3.1    Existing Packages
There are several packages either currently in or as additions to the .NET framework that
can ease building Web Services. The Windows Communication Foundation (WCF) API
already comes with .NET and provides support for SOAP and to ease the resulting XML
parsing, there is the Chilkat XML Parser. There is also the WCF-REST Starter Kit to
enable REST-style communications.

3.2    External Services
With SOAP and REST support, we will have the ability to utilize services from other
companies like Google Maps or Amazon Fulfillment Web Service.

4     Visual Studio 2010
Visual Studio 2010 is Microsoft’s solution to development. It is a package of softwares for ev-
erything from design to deployment and testing. Microsoft packages Visual Studio in various
levels depending on the amount of services you wish to purchase. Visual Studio Ultimate in-
cludes everything needed to design (that is create UML diagrams), develop in the integrated
development environment and test. It also comes with everything needed to manage version
control on a Team Foundation Server. The lowest in the purchase product line is Visual
Studio Professional which just includes the IDE and debug environment. Microsoft also has

                                              3
available an express version of Visual Studio for free which only allows for development in
the XNA framework. Each of the suites which can be bought also comes with their own
subscription to Microsoft Developer Network (MSDN) which has varying levels of support
based on the package purchased.

4.1    Visual Studio 2010 Pros
Visual Studio 2010 is a great product and one of the best IDEs on the market today. Visual
Studio allows for easy project creation and management in a variety of languages, be it
a Windows desktop application in C++ to an ASP.NET web application. It also allows
for development on multiple platforms such as the PC, XBOX Live Arcade and Windows
7 phone. There are also many plugins and addons which makes Visual Studio completely
customizable to the work that you are doing. In terms of visual customizability Visual Studio
makes it extremely easy with a simple drag and drop window interface allowing you to move
any frame or window to anywhere on the screen. Visual Studio 2010 also featurs Microsoft’s
Intellisense which is advanced code completion, this makes development of large applications
much easier. With Intellisense there is no need to flip between files or look at APIs to find
function calls.

4.2    Visual Studio 2010 Cons
Although Visual Studio 2010 is a great product it does have it’s weaknesses. One major
drawback to Visual Studio is that it is extremely expensive for small scale development. The
Professional package which is also the cheapest is around $ 1100 and the most expensive
package Ultimate sits close to $ 16 000. This is a major deterent for small businesses looking
to lower costs and keep overhead low. Another caveat of Visual Studio is that it is quite
cumbersome, this means that for small projects you might spend more time configuring
Visual Studio than you do working on the project. So Visual Studio is geared towards mid
to large scale projects. Having amazing features and expandability is a great thing, but it
comes at a cost and in this situation it is the cost of resources. Visual Studio with add-ons
can use around 6GB of harddrive space and needs about 2GB of ram to function properly.
Again this is a major drawback for a company looking to cut costs.

4.3    Visual Studio and .NET
Visual Studio and .NET development make a great pair because they are both Microsoft
products. Products from the same vendor seem to work nicely together and this is no
exception. Visual Studio integrates .NET development seemlessly once you have installed
the .NET 4 SDK addon which allows you to create and deploy .NET web applications. If
you’re planning on doing .NET development it is recommended that Visual Studio be used
to program in. Also, with Visual Studio if you run into problems it is easy to get help from
the MSDN so problems can be solved more efficiently.

                                              4
5     Mono

5.1    Overview
Mono is a cross platform, open source implementation of the .NET development framework
based on standards for C# and Common Language Runtime (CLR). Mono is designed
to allow developers to easily create applications that target all operating systems. Mono
provides functionality which benefit both desktop and web applications. Focusing on web
applications, the main allure of Mono is the ability to create and serve ASP.NET web pages
on an Apache server which can be run in the Linux environment. In fact, once the .NET
code is compatible with Mono it can be run on any of the supported platforms. Further,
Mono permits writing and consuming web services under the .NET framework on any of the
platforms listed below.

5.2    Supported Platforms
Linux, Microsoft Windows, Mac OS X, BSD, Sun Solaris, Nintendo Wii, Sony Playstation
3, and Apple iPhone.

5.3    Components
    • C# Compiler

    • Mono Runtime
      Implements the Common Language Infrastructure (CLI) and includes a Just-in-Time
      (JIT) compiler and Ahead-of-Time (AOT) compiler, library loader, automatic garbage
      collector, threading system and code interoperability. An example of code interoper-
      ability would be writing a class in C# and then inheriting from that class in another
      language such as VB .NET.

    • Base Class Library
      A set of classes which include a large number of common functions which lead to easier
      programming and quicker development.

    • Mono Class Library
      An extension to the .NET Base Class Library providing additional functionality such
      as classes for OpenGL and POSIX to name a couple.

5.4    .NET Compatibility
The Mono implementation now supports everything in .NET 4.0 except Windows Presenta-
tion Foundation (WPF), Windows Communication Foundation (WCF) and Windows Forms
(WF). However, looking at the project roadmap these features are scheduled to be imple-
mented in Mono v3.0 Olive. As mentioned above, the Mono Class Library provides an
extension of the .NET framework for even more functionality and built in classes.

                                             5
5.5    Mono Tools for Visual Studio
Mono Tools for Visual Studio is a Microsoft Visual Studio plugin which allows developers to
write .NET applications within the Visual Studio IDE to deploy on Mono-enabled platforms
other than Windows. For example, developers can use Visual Studio to build, debug and
publish .NET applications on Linux. Although Mono is open source, Mono Tools for Visual
Studio is a commercial add on for the proprietary software Visual Studio. Consequently,
it costs $99-$2,499 USD depending on the type of license; this will clearly be something to
factor into the company budget.

5.6    Apache and Mono
Mod_Mono is a module that is embedded within an installation of Apache which passes
ASP.NET page requests to an external program mod-mono-server. This external application
handles the request instead of Apache. mod-mono-server has the ability to host multiple,
independent applications which yields several useful results. First, one can route specific
URL’s to different mod-mono-server processes running under the same Mono virtual ma-
chine. Consequently, one can have a testing application server specific for experimental code
apart from the live site. One can also set specific quotas such as CPU, disk, and memory to
different server processes, meaning resource caps can be placed on different user groups. This
sounds like a lot of text editing configuration files between Apache and Mono. You’re right.
But there is one saving factor: Mod_Mono Configuration Tool which automatically gener-
ates a conf.d file with default settings. However, anything more complex does necessitate
manual configuration.

5.7    Porting Applications across Platforms
Mono provides a tool called MoMa (Mono Migration Analyzer) that helps locate and iden-
tify possible platform specific calls to make porting easier. Although web applications are
generally easier to port than desktop applications, complications such as data access, au-
thentication, and database migration need to be considered. This tool could be useful for a
company with a large .NET code base, looking to see how much time will need to be invested
into making their applications Mono compatible.

6     Support
Support for .NET is extensive. As .NET is created by Microsoft there is an extensive array
of official documentation available. There is also a lot of community support for .NET in
the form of blogs, forums, and mailing lists. As well, you can also create the

6.1    Official Support
Microsoft has several forms of official support, they are located at http://msdn.microsoft.com/en-
us/netframework. There is the MSDN API Reference, the official forums, tutorials and a

                                              6
knowledge base. The MSDN API Reference has a listing of all classes in the .NET Frame-
work, with all their public and protected methods and variables. The official forums are
staffed by Microsoft employees whose job it is to answer developers questions about working
with .NET. In addition, there are tutorials available which provide a good starting point
when beginning work on an area in which you have no experience. And finally, there is
an extensive knowledge base that may provide an answer quickly to a commonly occurring
problem that you are experiencing.

6.2    Community Support
Just as there is community support for languages such as Java or PHP, .NET also has many
forms of community support. A few of these are blogs by members of the development
community, 3rd party forums, and mailing lists. Just typing a simple query into Google
relating to .NET can generate millions of hits (for instance: .NET using delegate). Given the
popularity of .NET there are many forms of community support from the large community
of developers working with it every day.
Given both the Official Support and Community Support there are several avenues available
when seeking answers to any questions you may have. This will speed up development by
quickly answering any programming problems you may have encountered. This easy access
to official support should also promote good code by learning from examples written by
people who actually have worked on the .NET Framework.

7     Conclusion
.NET is not a solution to every foreseeable problem that you may experience. However, it
does provide several tools that make development in Windows easier and relatively hassle
free compared to other languages.
Being proprietary may not make .NET a good fit for some companies. If cross-OS compati-
bility is necessary or may be in the near future .NET is also probably not a good fit.
However, if your company is going to be developing only under Windows then .NET should
definitely be on your list of technologies to look at. It supports several languages and
programming paradigms, can be ported to other OS’s using Mono and has an excellent IDE
in the form of Visual Studio.

                                             7
You can also read