导 读:本文作者从一个WEB 开发者的角度谈了VISUAL STUDIO.NET 的一些优点,同时还为ASP程序员向.NET 编程转变提出了一些建议.
Web Enabling Visual Studio.NET
If we go back and reflect over recent years, we know Microsoft have been heavily promoting the Internet, often introducing somewhat confusing 'marketure' terms like ActiveX (which is basically just COM) to reflect the fact that their technologies have been internet-enabled and/or refocused/revised to take the internet into account. Microsoft have involved the internet in just about everything they've done since 1996. Although late to enter the internet game, their vision was, and is, still pretty simple: one day soon we won't think twice about developing web-enabled applications, the Web is the future of just about everything so why treat it as anything other than a function of an application? If we start treating the Web as just another deployment platform or feature of an application, and use the same tool set to develop both regular WIN32 applications and web applications, life would be a lot easier.
Microsoft are getting very close to achieving their vision with Visual Studio.NET. At the moment tools like Visual InterDev are web-specific, and tools like Visual Basic and Visual C/C+ are more focused on traditional WIN32 application development. This means to create a web application we have to think differently, and typically learn different object models, programming paradigms and use different toolsets. For example, today I typically use VBScript and/or JavaScript in ASP pages to create web applications. Furthermore I typically have to use Visual Interdev to create the HTML pages.
The fact that I have to use so many tools is a pain. I spend a lot of time developing non-web applications and web applications. Why can't I just use VB or C/++ in my ASP pages ? Why can't VB have the same features Visual Interdev uses so I can use it to design pages without using another app ? OK, I can use components to bridge some of these gaps, but I still have to use ASP script as the glue, and I'm still restricted in what I can do. For example, ASP pages have to use late binding (so COM's multiple interface paradigm is all but useless), and I can't use elementary COM features like events. This is a pain. The good news is that Visual Studio.NET and ASP.NET address these problems.
The release of the next version of Visual Studio (to be called Visual Studio.NET) has merged the development tools we use. For example, VB.NET has all of the features of Visual Interdev (which will probably be depreciated) and can now be used to create ASP applications. Along with these unifications come lots of improvements too: ASP pages can be written in VB or C/C++, ASP pages can use server side events, the new IDE has lots of nice features such as HTML auto tag completion, more MSDN integration, loads more XML support, precise HTML page layout that maps into HTML 3.2, specific browser targeting with fuzzy red underlining logic for HTML tags that won't work with your targeted browser.
Microsoft are making it easier for us to use the web, and the net effect should be more people will embrace it as a standard platform and/or feature. Whilst the Visual Studio.NET toolset are some months away from being released, ASP.NET is probably one of the most signifcant changes. As ASP developers you'll finally be able to use the full power of Visual Studio to aid your development.
Probably the most significant change in ASP.NET is the focus on web forms. The basic idea is you'll design your forms for ASP.NET just as you do for VB or any other language. You'll visually drag and drop UI elements (web controls) and hook up event handlers. The clever bit in ASP.NET is that once the form is rendered in the client browser, interaction with the client form is fired back to the server side form as events, where your code is then executed. ASP.NET provides all the management for the event passing between the client and server. With ASP today, you have to write this routing code yourself.
As part of web forms, ASP.NET also introduces the ability to separate visual HTML/Script elements from code. The model is implemented pretty much as per VB, and greatly improves code management and navigation. The code can still manipulate the HTML page, and in many ways is similar to DHTML in that respect.
Web controls are in many ways very much like ActiveX controls today, except they are client server based, and they output HTML rather than drawing to the screen. VB.NET ships with a large number of web controls, which you can extend or write yourself. The data list control is one of the controls provided. It allows you to point it at a data source, tell it what fields go where, what colours you want and ASP.NET will do the rest, outputting all the various table and row HTML elements. As the control could in theory be browser-aware, it can also take on the responsibility of generating output differently depending upon the client.
Now we've given you a feel for what's coming in Visual Studio.NET and ASP.NET, here are five tips that can get you preparing for it today.
Getting Ready for ASP+
Tip 1 - Learn VB and/or C/C++/C#
ASP.NET allows you to develop pages using VB or C/C++/C#. What basically happens is that pages are compiled and executed on the server. This leads to a signifcant increase in page performances, and also means you can take advantage of COM features such as early binding and true interface based programming. If you don't already know VB and/or C/C++/C# very well, run out to your nearest book shop and start learning it over the next few months.
Tip 2 - Learn COM(+) and Use Components
One of ASP's main strengths is also its main weakness: ASP Script. Whilst inline script code is quick to write and can result in fairly rapid development of a site, it is still script. Script is interpreted, it is for the most part typeless so you use variants everywhere, and scripting engines can't take advantage of early binding, so every method call you make results in an additional call to determine if the method you are calling actually exists. Those are serious overheads.
I strongly suggest you start using COM+ components today, primarily for your business logic. Components resolve all the problems of script, and also provide you with several additional benefits like improved debugging tools. Use ASP script to interact with your business components and generate the UI.
There is some overhead in creating COM objects that does have to be considered, but component creation in IIS5/ASP 3.0 and especially IIS5/ASP.NET is much much quicker so the overheads are reduced.
If you need a primer on ASP components check out Beginning ASP components from Wrox Press. We've got a sample chapter from the book here: http://www.idevresource.com/asp/library/articles/begcom.asp.
Tip 3 - Learn XML
Visual Studio.NET and ASP.NET make far greater use of XML. You at least need to make sure you've got a basic understanding of the differences of XML and HTML, and you should ideally be comfortable with creating and reading XML files.
For an introduction to XML check out 'Professional XML' from Wrox Press (Click here for more details).
Tip 4 - Learn About Processes, Threads and General Concurrency Issues
Whenever you talk about components and the ASP session object you hear nightmares about threads being locked down and scalability dropping. VB.NET allows you to create components that are free threaded. These are basically the same as free-threaded components in C/C++ which can safely be put into the session object. To make sure of this new feature of ASP.NET you need to have a solid understanding of Windows Threading.
Tip 5 - Make sure you have used Visual Interdev
If you've have not used Visual Interdev it is worth your while playing with it. A lot of the features of VI and the controls of things like WFC are likely to be present in Visual Studio.NET. The whole concept of visual development (web forms) is the way ASP.NET is heading.