Library Zone Articles
External Articles
Byte Size

Discovery Zone Catalogue
Diary
Links
Bookstore
Interactive Zone Ask the Gurus
Discussion Groups
Newsletters
Feedback
Etc Cartoons
Humour
COMpetition
Advertising
Site Builder ASP Web Ring ASP Web Ring
Toast Forums - toastforums.com
The Developer's Resource & Community Site
COM XML ASP Java & Misc. NEW: VS.NET
International This Week Forums Author Central Find a Job
Microsoft .NET

An interesting intro to ASP.NET

Download article for printing

By Frank Rem

Introduction

What is .NET about and why should you care? In this article I will scratch the surface of .NET. and provide some context. Further articles will discuss .NET in more detail.

Breathe in...

Classical Engineering vs. Software Engineering

What differentiates engineering from craftsmanship? A craftsman primarily uses his experience to implement a solution. For example, a blacksmith has learned that when he heats the steel too long at the same place, the steel will loose its ability to mold and will break instead. However, when he heats the steel too short, it will be too rigid and he will have a hard time bending it into the desired shape. He may not understand why this is so, but he knows and applies this knowledge to heat the steel just long enough.

As opposed to craftsmanship, classical engineering is primarily about applying the laws of nature instead of experience. By ingeniously imposing physical constraints on a system and anticipating the laws of nature, a solution is implemented. A nice example of this is the Watt's Governor, see Figure 1. The purpose of the governor is to maintain the spin velocity at a desired level. When the spin velocity increases the balls are driven outward. Through a system of connected arms this chokes the valve of the steam engine. When the spin velocity decreases, an inverse mechanism applies. This solution follows from knowledge of gravity and centrifugal force. This step from craftsmanship to engineering unleashed the industrial revolution in the 18th century.


Figure 1: Watt's Governor

As opposed to classical engineering, in software engineering you simply state the solution. If you want a certain level to change at discrete steps from 1 to 10 you implement it as follows:

for ( int level = 1; level <= 10; level++ )
{
	// something
}

If you think of it, and compare it to Watt's Governor, this is amazing. This is exactly why software engineering is a step forward with at least the importance of the industrial revolution.

Good and Bad Programming Models

You may have read "The Art of Motorcycle Maintenance" of Robert Pirsig. This book is about a quest for quality. It contains a key reference to "La science et l'hypothиse" of Henri Poincarй. In this book Poincarй argues that in science there is no such thing as 'truth'. Instead, there are only hypotheses and one hypothesis is simply 'more elegant' than the other as opposed to 'more true'. For example, if you assume that the earth is the center of our planet system, you are not wrong but you will have a very hard time describing the trajectories of the other planets. The mathematical formulas become extremely convoluted and unnatural. If, however, you assume that the sun is the center, suddenly the formulas become much more simple.

The same holds for programming models. A high-quality programming model helps you implement a solution; it does not make you bend backwards. Looking back at the Watt's governor, the problem it solves is maintaining the speed of an engine. What we end up with, however, are a bunch of balls, arms and valves. Sometimes programming is like that, but it shouldn't be.

ASP.NET

Let me illustrate the quality of a programming model by comparing ASP with ASP.NET. Suppose I want to implement the following web application:

A simple web application
Figure 2: A simple web application

Using ASP I would have to code something like this:

<form action="./calculation.asp">
<input type="text" size="1" name="op1 value=<%Response.Write Request("op1")%>>
<input type="submit" name="operation value="plus">
<input type="text" size="1" name="op2 value=<%Response.Write Request("op2")%>>
equals
<%
   Dim result
   If Request("operation") = "plus" Then
      result = CLng(Request("op1")) + CLng(Request("op2"))
   Else
      result = "?"
   End If
   Response.Write result
%>	
</form>

Using ASP.NET I would code something like this:

<script language="VB" runat="server">
   Sub OnClick(sender As Object, e As EventArgs)
      result.InnerHtml = Clng(op1.Value) + CLng(op2.Value)
   End Sub
</script>

<form runat="server">
<input id="op1" type=text size=1 runat=server>
<input id="plus" type="button" value="plus" OnServerClick="OnClick" runat="server">
<input id="op2" type=text size=1 runat=server>
equals
<span id="result" runat="server"/>
</form>

Let's compare the two implementations.

The first implementation is parsing out the html request and generates a new response stream accordingly. In the first fragment the programmer needs to be aware of the physical separation of the client and the server. Did you also notice how I solved the problem of maintaining the content of the text boxes after clicking push?

The second implementation accesses the web elements as objects that have properties and fire events. There is a clean separation of application logic and presentation. I don't need to worry about the physical separation of client and server. And finally, state management across posts and gets are no longer my problem.

Breathe out...

Conclusion

Although it may sound a bit bombastic, .NET is about increasing the quality of your programming model and giving software engineering the position it should have with respect to classical engineering.


About the Author

To find out more about Frank Rem, catch up with him at his own site in 'Author Central'.


Power your site with idr newswire

Contribute to IDR:

To contribute an article to IDR, a click here.

To contact us at IDevResource.com, use our feedback form, or email us.

To comment on the site contact our webmaster.

Promoted by CyberSavvy UK - website promotion experts

All content © Copyright 2000 IDevResource.com, Disclaimer notice

Learn C#

Visit the IDR Forums

Join the Developers Webring



Java COM integration