This Issue Sponsored By
SQL Server Magazine Connections Conference
In This Issue
1. Developer .NET Perspectives
3. New and Improved
Sponsor: APPDEV TRAINING
FREE SQL SERVER 2000 TRAINING! Become a more efficient, effective developer with AppDev's award-winning self-study SQL Server training! See AppDev quality for yourself--download 3 hours of training immediately or request a CD-ROM by mail (each a $95 value) FREE! Click the link below for your FREE SQL 2000 Training!
1. Developer .NET Perspectives
Visual Studio 2005 beta 1 brings with it the opportunity to start looking at some of the new features. Visual Studio 2005 isn't just a maintenance release. It contains a ton of new features. I don't just mean features that are new in the Windows .NET Framework and its languages, but also features that are new to the IDE, deployment, and project management. And that list isn't even including Team Services, which is yet another set of new features.
There are so many new features that I can't cover them all in one column. So, I'll discuss the various features over a series of columns. In this column, I'm going to discuss three language-related features: generic collections (aka generics), the "My" namespace, and anonymous methods.
Generics have been creating a lot of buzz among developers. They offer big improvements when you're working with collections. (Generics actually apply to more than just collections, but improving collections is their main role.)
When developing .NET applications, you constantly work with collections (i.e., arrays). Array variables have a data type of Object, and all Object variables are reference-type variables (aka reference types). In case you're unfamiliar with the .NET Framework, it classifies data types into two categories: reference types, which contain a pointer to the data, and value types, which contain the actual data. For example, the String data type is a reference type and the Integer data type is a value type.
Although an array is a reference type, the items in the array can be reference types or value types. When you use the .NET Framework 1.x to develop applications, you're responsible for correctly casting the array's items to the correct data type when you use those items in variables outside the array. Because the compiler (i.e., the Common Language Runtime--CLR) has no way of knowing whether the type you've assigned the variables is valid for the values in the array, errors can occur.
That situation changes with generics. When you use the .NET Framework 2.0 to develop applications, you simply declare the type of objects that the array will store, and the CLR does the rest. It ensures that any object assigned as an item in your array is the correct type. It also makes sure the variables to which you assign items are the correct type.
Not only does generics reduce errors, but it also makes .NET applications run faster. Although Microsoft didn't introduce generics explicitly for that reason, this side effect is a nice bonus.
Why does generics make applications run faster? Like all reference types, arrays are stored on the heap (i.e., memory reserved for temporary storage of unanticipated data or data whose size can't be anticipated). However, value types are stored on the stack (i.e., memory reserved for anticipated data, such as data that has a fixed memory size). When an array stores value types, it must undergo a process called boxing so that not only the array but also its contents are on the heap. In boxing, the CLR transforms an item's true type into the base class of Object, places the value in a box (hence the term "boxing"), then moves the boxed value from the stack to the heap. Not surprisingly, this process takes time.
With generics, the CLR no longer has to transform the items in your array from their true type into the Object base type. The result is a significant performance improvement when you run running applications that contain arrays of value types. However, to put this improvement in perspective, the CLR can probably transfer as many as 100,000 items in and out of a .NET collection in under a second. (This figure isn't a hard performance measurement but rather one to give you an idea of the scale.) With generics, there will probably be about a 50 percent improvement in that performance. However, for your array of say 5000 items, this equates to a 50 percent reduction of what will take only a fraction of a second, so don't think that generics are going to have a large impact on your application's perceived performance.
If you'd like more information about generics, check out these Web sites:
The My Namespace
The My namespace is built into the .NET Framework 2.0 under the Visual Basic namespace. As a result, although the My namespace is in the .NET Framework 2.0, developers using the other .NET languages will probably avoid using it because they would have to first recognize they were working with a Visual Basic .NET feature. However, for those developers leveraging the power of Visual Basic .NET, the My namespace provides a helpful shortcut.
Let's face it, the .NET Framework is huge. There are literally thousands of classes and tens of thousands of methods within it. The sheer volume of classes and methods can be a problem when you need a specific class or method for your application. You know that it exists, but you're not sure where in the .NET Framework to access it. The My namespace can help you quickly get this information.
Using the My namespace brings up a subset of namespaces from the .NET Framework that are available in the current context of your application. Thus, the My namespace isn't as much a new set of classes as an interface to access the existing classes in the .NET Framework. Any .NET language can leverage this interface, but to do so, you need to first associate your code with the Visual Basic namespace.
If you'd like more information about the My namespace, check out this Web site:
One of my favorite new features is anonymous methods. Anonymous methods are based on the delegate type, which lets you declare a variable that will contain code. You can pass this variable as a parameter or store it in a collection; when needed, you can then execute the code. The key is that you don't have to provide a name for this block of code. You simply have to provide the block of code.
This incredibly powerful feature lets you create logic that's based on a specific situation. For example, at one time or another, most developers have needed to put together custom validation logic to accompany a form. Often there are several different conditions under which this form will run, so you end up with validation code that's unusually complex because it needs to account for these various conditions. With anonymous methods, you can literally have the validation passed into the form. Instead of needing validation logic that accounts for all the ways a form will be called, the validation logic is passed into the form as part of the activation process. The result is that each path or object that calls this common form can pass in custom logic and the form itself can remain generic.
In addition to letting you build logic that adapts to your needs at runtime, anonymous methods let you create delegates based on static code. To do so, you have to essentially declare each delegate with the code associated as static text. You can set the appropriate return type for your delegate and can accept parameters, so I don't want you to think that you can't pass information in and out. However, what I would like to be able to do is append the various statements that I want to execute to a String Builder or similar object. When ready, I would then like to transform the contents of my dynamic string into an anonymous method and execute that code.
This type of indirect execution would let me build the elements of a method from scratch at runtime. It's a powerful capability, but based on my experience and repeated attempts with Visual Studio 2005 beta 1, it's a capability that's not currently available with anonymous methods. Admittedly, there are risks in dynamically creating source code that's compiled and executed as part of a running application. But I'm hopeful that at some point in the future, Visual Studio will offer this capability.
Sponsor: SQL Server Magazine Connections Conference
SQL Server Magazine Connections is coming to Las Vegas, NV,
November 7 – 10. With over 45 sessions covering Data Warehousing and Business Intelligence, Database Development, Database Administration, and more, this is the premier SQL Server event! Registration includes an exclusive day of presentations on SQL Server 2005 by the Microsoft SQL Server 2005 product team and all attendees receive the latest build of SQL Server 2005 Beta and Visual Studio 2005. Call 800-438-6720 or 203-268-3204.
(brought to you by SQL Server Magazine)
If you're a SQL Server developer, SQL Server Magazine is a must-read. Each issue offers a treasury of relevant articles, savvy tips, endless code listings, and expertise that will give you the answers you're looking for. Chose from a library of hot topic discussions relating to reporting services, security, high availability, and much more. Order now:
The Windows & .NET Magazine Network VIP Web site/Super CD subscription has it all. This all-inclusive package not only provides online article access to all network publications, a print subscription to Windows & .NET Magazine, and exclusive access to our banner-free VIP Web site, but it also now includes SQL Server Magazine content. Subscribe today!
Novice forum member Craig needs to feed records one at a time from Microsoft SQL Server to a vendor's Simple Object Access Protocol (SOAP) API. He also needs to receive a record back as a separate process through SOAP and place that record into a different SQL table. The vendor transmits an account number that becomes part of the filter for what information the vendor needs to receive. Craig is looking to use only T-SQL and C# and is wondering whether a Web service is the right solution. If you have any ideas, go to the following URL:
(A complete Web and live events directory brought to you by Windows & .NET Magazine: http://www.winnetmag.com/events )
Discover solutions that minimize the likelihood of downtime in your SQL Server implementation and help to ensure continuous SQL Server application availability. SQL Server Magazine invites you to attend a free, interactive Web seminar designed specifically for SQL Server professionals. This live, online event will be presented on August 19, 2004. Register today--it’s free!
3. New and Improved
9Rays.Net released Spices.Net Visual Studio Integration Pack (Spices.VSIP.Net) for Windows, a new product in the Spices.NET family. Spices.VSIP.Net fully integrates Spices.Net (a platform environment that's also a class browser, analyzer, and disassembler) into the Microsoft Visual Studio .NET 2003 development environment. With Spices.VSIP.Net, developers can develop, build, obfuscate, verify, debug, and deploy assemblies. Whenever developers change the configuration of their Visual Studio .NET 2003 project, the Spices.VSIP.NET project is automatically updated. Two versions are available: Spices.VSIP.Net Obfuscator (includes the Obfuscator, Investigator, Modeler, and Informer plug-ins) and Spices.VSIP.Net Suite (includes all components, plus the Decompiler module). Pricing for Spices.VSIP.Net Obfuscator and Spices.VSIP.Net Suite are $292.95 and $492.95, respectively. For more information, go to
This email newsletter is brought to you by Windows & .NET Magazine,
the leading publication for IT professionals deploying Windows and
related technologies. Subscribe today.
Windows & .NET Magazine, a division of Penton Media, Inc.
221 East 29th Street, Loveland, CO 80538
Attention: Customer Service Department
Copyright 2004, Penton Media, Inc. All Rights Reserved.