Sie sind auf Seite 1von 52

BEGINNING .NET GAME PROGRAMMING p.

46
Presented by

THE WORLD’S LEADING .NET RESOURCE

2006 Volume 4 Issue2

An Approach to a Multi-Boot
Windows Solution
When virtualization just isn’t an option

Ajax and Atlas


An overview of two Ajax implementations

Rapid Module Development


for DotNetNuke
Instant DotNetNuke modules

Coming...
March 13, 2006
New York City
www.ajaxseminar.com SEE PAG
E 43
FOR DE
TAILS
Marriott Marquis
Times Square, NYC

Presorted
Standard
US Postage
PAID
St. Croix Press

W W W . D O T N E T D E V E L O P E R S J O U R N A L . C O M
SUPERCHARGE
YOUR APPS WITH
THE POWER OF

LOCATION
INTELLIGENCE Enable Location Intelligent web services
110

Single environment for deployment


to desktop or web
Full integration with VisualStudio .NET

Create applications for:


• Web-based store/asset location finders • Visualizing where your customers are
• Analyzing where revenue comes from – and where it doesn’t • Managing assets such as cell towers, vehicles and ATMs

Try it and see for yourself. Visit www.mapinfo.com/sdk


Learn more about the MapInfo Location Platform for .NET, 110

access whitepapers and download free SDKs. 001

Contact us at sales@mapinfo.com
DBA: “I suspect it’s your application server
code that’s causing the problem.”
App Dev: “It must be a database problem.”

Eliminate the finger pointing with WebLOAD Analyzer™.


11010001011010001011010010101010100010110100101010110100010110100011101001010101011

Want to accelerate resolution


of Web performance problems?
You can with WebLOAD Analyzer—the only load testing tool
with root cause analysis for .NET and Microsoft Web applications.
WebLOAD Analyzer employs unique “black box” software to
capture actual problems at multiple synchronized levels, enabling
users to drill down to the individual component. By pinpointing
the root cause of all kinds of application problems, WebLOAD
Analyzer reduces problem resolution time by 60%—significantly
improving application performance and eliminating finger pointing
once and for all.

Get a FREE “No more finger pointing” T-shirt. >> > > Learn more at www.radview.com/analyze

110100010110100010110100101010101000101101

00101010110100010110100011101001010101011

© RadView Software, Limited.All rights reserved. The Smart Choice in Web Application Testing
F e b r u a r y 2 0 0 6 Volume 4 Issue 2

����
Inside DNDJ 10
EDITORIAL

Let’s Face It, We’re All Screwed


By Derek Ferguson ................................................................... 7
An Approach to a Multi-Boot BOOK REVIEW

Amazon.com Top 10 .NET Books


Windows Solution
WHEN VIRTUALIZATION JUST ISN’T AN OPTION
Provided by Amazon.com........................................................ 8
SQL SERVER 2005
BY PAT PICCOLO
A Point of Order
By Jerry Dixon............................................................................ 18
ASP.NET

Rapid Module Development


24 for DotNetNuke
By Mark Hoskins ....................................................................... 28

Ajax and Atlas


THE TRAINING CORNER

SPBU.NET: Principles and Experience


AN OVERVIEW OF TWO AJAX IMPLEMENTATIONS
BY BEN REICHELT
of Teaching .NET, Compilers,
Software Engineering, and OS
By Vladimir Safonov .................................................................. 38
SOA

Enabled SOA Transformation


By Michael Kochanik ................................................................ 42
34 BOOK REVIEW

Beginning .NET Game Programming


Garbage Collection By Kevin Wittmer .......................................................................

BOOK REVIEW
46
HOW MANY MANAGED
OBJECTS IS YOUR Pro ADO.NET 2.0
APPLICATION REALLY By Dennis Hayes ....................................................................... 48
CREATING? MONO
BY STEVEN PRATSCHNER
Mono 1.1.12 Released
By Dennis Hayes ....................................................................... 50
4 February 2006 • dotnetdevelopersjournal.com
���������������������

���
��������������
��������������
��������
����������������
��������� ���������������������� �����������������������
����������������� � ����� ���������� � ���� ������ ��

���������� �������� ��������� ��������������� �

������������������������������� ������
��������������������������������������� ���� �������������������������������
��������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������������������������������������������
Editorial

EDITORIAL BOARD Let’s Face It,


We’re All Screwed
dotnetboard@sys-con.com
Editor-in-Chief
Derek Ferguson derekf@speakeasy.net
Executive Editor
Seta Papazian seta@sys-con.com
Group Publisher
Jeremy Geelan jeremy@sys-con.com BY DEREK FERGUSON
Mobility Editor EDITOR-IN-CHIEF
Jon Box jbox@psgi.net
Security Editor

w
Patrick Hynds phynds@criticalsites.com hen I was a kid, I Went to India (And All I Got Was
Open Source Editor remember someone say- This Lousy Book) in the mail. It is AUTHOR BIO:
Dennis Hayes dennisdotnet@yahoo.com
Product Reviews Editor ing, “If you like where written by Chad Fowler, is part of Derek Ferguson is an
Doug Holland doug.holland@precisionobjects.com
VB Editor you’re sitting, you had the Pragmatic Programmers series, associate director in the
Keith Franklin keithf@magenic.com better stay there!” They were refer- is subtitled “52 Ways To Save Your Information Technology
Smart Client Editor
Tim Huckaby timh@interknowlogy.com ring to a prediction that the Earth’s Job,” and is a must-read for anyone Group at Bear Stearns,
BizTalk Editor
Brian Loesgen brian.loesgen@neudesic.com population was going to increase interested in safeguarding his or a leading global investment
to the point that there wouldn’t be her career against the pervasive banking, securities, trading,
ADVISORY BOARD
dotnetadvisors@sys-con.com enough room for everyone to sit, so influence of our national economic and brokerage firm.
Derek Ferguson derekf@magenic.com we’d all have to stay standing for- decline.
Seta Papazian seta@sys-con.com
Jeremy Geelan jeremy@sys-con.com ever, or some such nonsense. One of the recurring themes 4derek@sys-con.com
Thom Robbins trobbins@microsoft.com
John Gomez John.Gomez@eclipsys.com As I got older, of course, I came of the book is that the job of soft-
Scott Hanselman scott@hanselman.com
Dean Guida deang@infragistics.com to realize that overpopulation was ware developer is rapidly chang-
John Sharp johns@contentmaster.com – or so I thought – strictly going ing in the West to be more of a
Jacob Cynamon jacobcy@microsoft.com
Chris Mayo cmayo@microsoft.com to be the problem of other, less management occupation. Those
Gary Cornell gary@thecornells.com
Joe Stagner joestag@microsoft.com “developed” parts of the world. of you who regularly read this
Peter DeBetta peter@debetta.com Since everyone couldn’t come here, magazine may recall that I liken-
Editor
Nancy Valentine nancy@sys-con.com they’d simply have to rot in whatev- ed this process (in DNDJ January,
Online Editor er god-forsaken holes in the ground 2005) to what has happened to
Roger Strukhoff roger@sys-con.com
they chose to call home. In the the nursing profession over the last
WRITERS IN THIS ISSUE
Jerry Dixon, Derek Ferguson, Dennis Hayes, Mark Hoskins,
Michael Kochanik, Pat Piccolo, Steven Pratschner, Ben Reichelt,
Vladimir Safonov, Kevin Wittmer

SUBSCRIPTIONS
“On the other hand, maybe it is the
end of life as we know it”
For subscriptions and requests for bulk orders,
please send your letters to Subscription Department
Subscription Hotline: subscribe@sys-con.com
Cover Price: $6.99/issue
Domestic: $69.99/yr. (12 issues)
Canada/Mexico: $99.99/yr. Overseas: $129.99/yr.
(U.S. banks or money orders). Back issues: $12/ea.,
plus shipping and handling. words of Ebenezer Scrooge, if they couple of decades. In the same
EDITORIAL OFFICES were going to die, they should do it way that hospitals employee fewer
SYS-CON Media 135 Chestnut Ridge Rd., speedily and decrease the surplus nurses and more low-cost “nurses
Montvale, NJ 07645
Telephone: 201 802-3000 Fax: 201 782-9638 population. aides” – which the nurses are
.NET Developer’s Journal (ISSN#1541-2849) is
published monthly (12 times a year) for $69.99 by Lately though, it seems as expected to manage – in the con-
SYS-CON Publications, Inc.,135 Chestnut Ridge Road,
Montvale, NJ 07645. though the rest of the world’s prob- tinuing battle to lower healthcare
Postmaster: Send address changes to: lems are coming closer and closer costs, so too will western software
.NET Developer’s Journal,
SYS-CON Publications, Inc., to home. September 11, of course companies continue to ship jobs
135 Chestnut Ridge Road
Montvale, NJ 07645 – like the sacking of Rome: bits of overseas.
Copyright © 2004 by SYS-CON Publications, Inc. trash from outside the empire’s The good news, of course, is that
All rights reserved. No part of this publication may be reproduced or
transmitted in any form or by any means, electronic or mechanical, borders finally managing to make for every three developers who are
including photocopy or any information storage and retrieval system,
without written permission. For promotional reprints, contact Reprint it across for a hugely symbolic half way around the world, there
Coordinator Dorothy Gil, dorothy@sys-con.com.
Worldwide Newsstand Distribution – if not, thankfully, hugely effec- will still need to be one developer
Curtis Circulation Company, New Milford, NJ
Newsstand Distribution Consultant: tive – attack on the empire’s heart. here at home to manage the inter-
Gregory Associates / W.R.D.S.
732 607-9941 - BJGAssociates@cs.com Consider the gas prices we see spi- face between software and busi-
For list rental information:
Kevin Collopy: 845 731-2684,
raling upwards as more hands com- ness needs. Almost every domestic
kevin.collopy@edithroman.com;
Frank Cipolla: 845 731-3832,
pete for slices of an ever-shrinking survey still indicates that good local
frank.cipolla@epostdirect.com
supply of pie; and, of course, the developers are in high demand, so
All brand and product names used on these pages are trade names,
service marks, or trademarks of their respective companies. SYS-CON
Publications, Inc., is not affiliated with the companies or products
threat of having all our jobs sent it could just be that the only thing
covered in .NET Developer’s Journal. .NET and .NET-based marks are
trademarks or registered trademarks of Microsoft Corporation in the United
to places where people have the we are losing in the process of glo-
States and other countries.
standards of living associated with balization is the excess baggage
SYS-CON Publications, Inc., reserves the right to revise,
republish and authorize its readers to use the articles gross overpopulation, i.e., “will that our industry picked up during
submitted for publication.
code for food.” the Roaring 90s.
It was against this backdrop that On the other hand, maybe it is
I recently received the book My Job the end of life as we know it.

dotnetdevelopersjournal.com • February 2006


7
Book Review

Amazon.com Top 10 .NET Books President and CEO


Fuat Kircaali fuat@sys-con.com
President, SYS-CON Events
Grisha Davida grisha@sys-con.com

10 4
Microsoft Excel 2003 for Group Publisher
Office Project Dummies Jeremy Geelan jeremy@sys-con.com
2003 Step by ADVERTISING
Step Senior Vice President, Sales and Marketing
Carmen Gonzalez carmen@sys-con.com
Vice President, Sales and Marketing
by Carl Chatfield by Greg Harvey Miles Silverman miles@sys-con.com
Advertising Director

9 3
Robyn Forma robyn@sys-con.com
Excel 2003 Gödel, Escher, Advertising Sales & Marketing Manager
Bible Bach: An Dennis Leavey dennis@sys-con.com
Eternal Golden Advertising Sales Manager
Braid Megan Mussa megan@sys-con.com
Associate Sales Managers
Dorothy Gil dorothy@sys-con.com
Kim Hughes kim@sys-con.com
by John Walkenbach by Douglas R. Hofstadter
PRODUCTION

8 2
Getting to HTML for the Production Consultant
Jim Morgan jim@sys-con.com
Know ArcGIS World Wide
Lead Designer
Desktop: Web with Tami Lima tami@sys-con.com
The Basics XHTML and Art Director
of ArcView, CSS: Visual Alex Botero alex@sys-con.com
ArcEditor, and QuickStart Associate Art Directors
Louis F. Cuffari louis@sys-con.com
ArcInfo Updated for ArcGIS 9 Guide, Fifth
Andrea Boden andrea@sys-con.com
(Getting to Know series) Edition Video Editor
by Robert Burke by Elizabeth Castro Ryan Palmieri ryan@sys-con.com

WEB SERVICES

7
UML Distilled: Information Systems Consultant
A Brief Robert Diamond robert@sys-con.com
Guide to the Web Designers
Standard Stephen Kilmurray stephen@sys-con.com
Wayne Uffleman wayne@sys-con.com
Object
Modeling ACCOUNTING
Language, Third Edition Financial Analyst
Joan LaRose joan@sys-con.com
by Martin Fowler
Accounts Payable

6
Betty White betty@sys-con.com
PROVIDED BY MCSE Accounts Receivable
Self-Paced Gail Naples gailn@sys-con.com

1
Training Kit: Design Patterns: SYS-CON EVENTS
Microsoft Elements of Reusable President, SYS-CON Events
Windows Object-Oriented Software Grisha Davida grisha@sys-con.com
Server 2003 Core (Addison-Wesley National Sales Manager
Jim Hanchrow jimh@sys-con.com
Requirements, Exams 70- Professional Computing
290, 70-291, 70-293, Series) SUBSCRIPTIONS
201 802-3012
70-294 by Erich Gamma
888 303-5282
by Dan Holme subscribe@sys-con.com
CUSTOMER RELATIONS

5 The Mythical
Man-Month:
Essays on
Software
Circulation Service Coordinators
Edna Earle Russell edna@sys-con.com
Linda Lipton linda@sys-con.com
JDJ Store Manager
Brunilda Staropoli bruni@sys-con.com
Engineering,
20th
Anniversary
Edition
by Frederick P. Brooks

8 February 2006 • dotnetdevelopersjournal.com


��������������������������������������

������������������������������������

�������������������������������������
�������������������������������������������

������������������������������������������������������������������
��������������������������������������������
������������������������������������������������������������������

���������������������������������� ������������������������������
����������������������������������������������������������������������
������������������������������������������������������������������������
�������������������������������������������

��������������������������������������
4 ��������������������������������������������������������
����������������������������������������
4 ����������������������������������������������������������������
�����������������������������������������������������
���������������������������
4 ����������������������������������������������������������
�������������������������������������������������������� ��������������������������������������������
���������������������
4 ������������������������������������������������

����������������������������������������������������������������
������������������������������������ ��������������
���������������������
�������������

�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
Best Practices

An Approach to a Multi-Boot Windows Solution


When virtualization just isn’t an option

i
’ve been a big fan of Note: The legality of this solution may would be a more powerful solution
boot loaders for the past depend on your licensing arrangements. than resorting to virtualization.
decade; whether its lilo This document in no way endorses So why don’t more people use
or grub or BootMagic, breaching your license contract and is multi-boot configurations? Quite
the ability to have multiple intended only for development, primarily simply, because it’s much less con-
bootable copies of Windows has within the realms of an MSDN subscription venient than just creating a new
always been a necessity to anyone or a VLE copy of Windows XP or Windows virtual machine. One way to set up
who works with beta software. The 2003. Your mileage may vary. a multi-boot configuration is to use
great thing is that with Windows XP a separate physical drive for each
Professional and Windows 2003, the instance. Another option would be
NTLDR has finally come of age and additional logging. In some cases, to split a single drive into multiple
can hold its own against the Linux beta software is more timing sensi- partitions, with an instance of
boot loaders. tive too. You don’t dare run beta Windows on each partition. Either
Why bother though? With virtu- software side by side with your way, it’s something that requires
alization software such as VMWare bread-and-butter development forethought and planning before
and Microsoft Virtual Server, you environment. At times though, you set up your workstation.
can just create a virtual machine to running it in a virtual machine Most seasoned IT professionals,
isolate different copies of Windows. makes it run far too slowly or not however, will tell you that setting
While this is true, virtualization at all. I have seen some beta soft- up multiple instances of Windows
comes at a cost: you can’t use your ware that slows down so much can be fraught with problems.
processor(s)’s full potential, and when run on a virtual machine It’s not that the process is difficult:
you can’t use all of your system’s that it appeared to be hung. This the Windows installer is perfectly
available RAM. By definition, you common scenario for beta software happy with configuring multiple
are sharing the system’s resources would be a good candidate for a instances of Windows on the
with the host operating system, multi-boot configuration. same workstation. The problem
BY PAT PICCOLO which also will impact perfor- Another scenario that doesn’t is that when the installation of
mance. In some cases, you may not fit perfectly into the virtualization Windows is done, the drive let-
be able to use your video or sound world is performance testing and ters of each instance of Windows
card’s full potential either. When analysis, or benchmarking. Here (other than the one on the first
these limitations are not an option, also, since the virtualized guest partition of the first drive) is some-
you may find setting up your work- must share resources with the host, thing other than drive C. So while
station with multiple bootable par- it’s difficult, if not impossible, to they will boot and run fine, many
titions is a better alternative. determine what bottlenecks really programs will not install prop-
It’s a given nowadays that beta exist in your code. Again, being able erly, or will cross-corrupt other
software runs slower than the to boot into a custom configured installations of Windows. This is
release version. This is often due Windows environment specifically because they make the assump-
to the overhead of debug code and set up for performance testing tion that drive C is the drive with

“The
great thing is that with Windows XP Professional
and Windows 2003, the NTLDR has finally come of age
and can hold its own against the Linux boot loaders”

10 February 2006 • dotnetdevelopersjournal.com


WE HELP YOU DELIVER
THE WHOLE PACKAGE
V E R I O S U P P L I E S T H E B E S T T E C H N O L O G Y, R E S O U R C E S ,
AND EXPERTISE TO SUPPORT YOUR .NET SOLUTIONS

When you partner with Verio, you can


deliver complete solutions for your
customers’ business needs. As your
trusted expert advisor for managed
hosting, we support your application
development with our managed
services and infrastructure from
state-of-the-art Verio data centers.

As a viaVerio® partner, you’ll enhance


your solutions portfolio and add value
to your business by gaining access
to our suite of global products and
services, including managed storage
and security. You’ll also gain peace
of mind in knowing that Verio
is backed by the financial and
operational excellence of NTT
Communications, the world's largest
telecommunications company.

BUILD YOUR BUSINESS BY


PARTNERING WITH THE MANAGED
HOSTING INFRASTRUCTURE EXPERTS.
Nothing turns on the power of
the Internet like Verio products
and services.

CALL 866.237.4121 today to find


out more about how a viaVerio
partnership can complete your
business offering. Or visit:
www.verio.com/partners

Power. Performance. Results.

Verio, viaVerio and the Verio logo are trademarks and/or


service marks of Verio Inc. in the United States and other
countries. All other names are trademarks or registered
marks of their respective owners. ©2005 Verio Inc.
All rights reserved.
Best Practices
137GB, and you will not be able to allocate to each. For me, I wanted
Physical Drive have an infinite number of operat- 30GB for each of the six instances
ing systems in your boot.ini [see of Windows, and whatever space
this link http://support.microsoft. was left over on my 250GB drive
com/?kbid=141707].) would be for the data partition.
Extended To pull off this feat you will need: 4. Each drive will be a partition, but
Partition • A blank hard drive, unformatted, remember, there really is a limit
Logical Partition 6 unused, and devoid of critical of four primary partitions on a
important data drive. What we want to do is have
Logical Partition 5 • Your Windows XP or 2003 Install one primary partition, and one
Logical Partition 4 CD and all necessary drivers to extended partition that contains
make your workstation happy several logical partitions. So my
Logical Partition 3 • A partition backup tool such primary partition would be for
Logical Partition 2
as Ghost (www.symantec.com/ running Visual Studio 2005. The
home_homeoffice/products/back- rest of my instances of Windows,
Logical Partition 1 up_recovery/ghost10/index.html) and my data drive, would all be
• About 10 minutes to read the fol- logical partitions (see figure 1).
lowing two links: 5. Create your first partition on
Primary - www.dewassoc.com/kbase/ your drive. If you like to do this
Partition multi-boot/boot_ini.htm with a third-party partitioning
- http://support.microsoft.com/ tool, that’s up to you, but make
default.aspx?scid=kb;en-us; sure that you only create one
f1 Figure 1: A drive partitioned with one primary and 223188 primary partition that is just big
six logical partitions enough for your first Windows
So, on to the fun: Installation. Or, when you install
the \Windows and \Program Files 1. Start with a blank hard drive – not Windows onto a hard drive with
directories. the one on which you have all of no partitions, let it do the work
The funny thing is that since the your critical programs and data! by only specifying a partition size
release of Windows NT, all of these If you don’t have a hard drive to big enough for your first instance
drive letter problems were supposed spare, or you’re not willing to back of Windows.
to be fixed. The operating system up everything important to you and 6. Install Windows XP or 2003 on
no longer sits on top of DOS, so the start over, you won’t want to do this the primary partition. Load all
whole idea of a drive letter is nothing process! of your network drivers, sound,
but a mutually agreed upon figment 2. Think about how many separate video, etc., service packs, and
of the operating system’s imagination. instances of Windows you want and patches. Go ahead and install any
Therefore, to whet your appetite list them on a piece of paper. For me, other tools that you want on all of
for what follows, let me say out- I just made a quick list of which appli- the partitions anyway. (For me, I
right that you can have AS MANY cations I needed to keep separate: waited to install Microsoft Office,
DIFFERENT WINDOWS INSTANCES (a) Visual Studio 2005 for normal since I needed different versions
on a single workstation as you have day-to-day development of it on different partitions, and
space and patience to create, and (b) BizTalk 2004 for normal day-to- BizTalk is woefully picky about
all of them boot as drive C. That’s day development (this uses the the order in which things are
right... all of you naysayers who say older Visual Studio 2003) installed). If you are going the
you’re limited to four per drive, and (c) BizTalk 2006 (it’s a beta, so I don’t Windows 2003 route but want it
that you can’t change the drive let- put it anywhere near the things I to have the look and feel of XP,
ters of the system, get a load of the use daily) you may also want to apply some
power of NTLDR and Windows XP (d) Windows Workflow Foundation of the suggestions found here:
and 2003. Beta www.msfn.org/win2k3/index.
Final disclaimer: the following (e) Windows Communication htm.)
process is not for the squeamish. I Foundation Beta 7. Start the Windows Disk
take no responsibility if you wipe out (f) Windows Presentation Management GUI in the
critical data. Foundation Beta Computer Management MMC
This process has been tested with snap-in. This can be done by
Windows XP professional 32bit and 3. Then think about if you want a selecting the Administrative Tools
Windows 2003 32bit. If you want to “data” drive… just for data, not for menu, then select Computer
try this process with other operating an OS or programs. I knew I wanted Management, and finally select
systems, you are on your own. I can a drive set aside just for writing Disk Management from the tree
tell you that I have tried this with Ghost images to. view. From here you should cre-
Windows 2000, and while it does So total up the number of drives ate an extended partition that
work, you will need to have the lat- you want, and come up with the consumes the remainder of your
est service packs to handle drives > amount of disk space you want to available drive space.

12 February 2006 • dotnetdevelopersjournal.com


Best Practices
drive-letter scurvy, if I attempt to
boot from partitions 2-n, those
Windows instances will have the
f2 Figure 2: Windows Disk Management GUI with one primary and six logical partitions wrong drive letters for the System
Volume. What’s worse is that no
fiddling with drive letter assign-
ments in the Disk Management
GUI will correct the problem.
Here is the secret fix. On a
completely unrelated knowledge-
base article, Microsoft explains
how Windows maps drive let-
ters to each partition, and how
to change them, even when the
Disk Management GUI won’t let
you (see http://support.micro-
soft.com/default.aspx?scid=
kb;en-us;223188).

12. For each instance of Windows


running from the logical parti-
tions, we need to swap the system
volume and the bootvolume.
Here’s how (repeat these steps for
all instances of Windows on a logi-
cal partition):
f3 Figure 3: Using RegEdit to swap the System Volume and the Boot Volume (a) Boot to the logical partition
in SAFE mode by pressing
8. Still using the Windows Disk 10. Boot your primary partition. You F8 when the workstation
Management GUI, create may want to change its wallpaper starts and then selecting SAFE
and format a logical partition to make it easier to identify. mode. Then select the logical
inside the extended partition for 11. Edit your C:\Boot.Ini. You may partition from the boot menu.
each remaining drive that you need to unhide it in order to edit (b) Run cmd.exe from the
decided you needed in steps 2 it. You’ll need one operating run box. Make a note of the
and 3. system entry for each instance drive letter of the prompt,
Figure 2 shows what my drive of Windows you wanted. then type SET and press
looked like with one primary The first logical partition in the ENTER. Make note of the
partition (dark blue) and the extended partition will be parti- SystemDrive. This should be
six logical partitions (light blue) tion #2 and they go up from there. the same as the drive letter of
inside the extended partition If you have SCSI drives, your the prompt. This is your
(green). boot.ini will look different from SystemVolume. For the pur-
9. Copy your primary partition to the one below, but you’ll get pose of example let’s say this is
each of the logical partitions. I the idea of what we’re doing. drive H.
highly recommend Ghost (www. See the link www.dewassoc.
symantec.com/home_homeoffice/ com/kbase/multiboot/boot_ini. Listing 3 shows an example of my
products/backup_recovery/ htm for a review of the differ- environment variables after booting
ghost10/index.html) for making ent ways partitions are numbered from one of my logical partitions.
the copies. Not only can it copy between logical and primary Notice that the HOMEDRIVE is H,
from partition to partition, but also partitions. even though the ProgramFiles drive
it’s just as easy to back up the parti- Listing 1 shows my original is C. It’s completely confused.
tion to CD-R. I recommend mak- boot.ini (watch for word-wrap!), (c) Run RegEdit and go down
ing a real Ghost backup so that you and Listing 2 shows my revised to HKLM\System/Mounted-
can restore it to any of the parti- version. Devices. This is the mapping
tions when you want to start it table that Windows uses for
fresh (I do this a lot when I get OK, so you’re thinking: What’s assigning drive letters to parti-
new beta bits for an app... it’s the big deal? I’ve done this type tions (see Figure 3).
quicker and cleaner than uninstall- of partitioning and editing of (d) Rename the \DosDevices\
ing because the uninstallers for the boot.ini before… and I ended C: key to something else,
beta applications usually aren’t up with drive-letter problems like \DosDevices\Cx: This
good at completely removing the just as you described at the top is the BootVolume. It’s the
application). of the article. Like some sort of primary partition (your first

14 February 2006 • dotnetdevelopersjournal.com


Best Practices
AUTHOR BIO: partition) and actually is the tion you selected from the same partition after making
Pat Piccolo is a consultant partition from which NTLDR boot menu will get the drive C the registry changes and
with Magenic Technologies. He booted. The problem is, once assignment). rebooting. Now both my
has over 20 years of experience NTLDR jumps to the partition (f) Now we need to fix up the HOMEDRIVE and Program-
in the software industry. that you select from the boot botching of the original C drive. Files point to Drive C.
Pat lives in Atlanta, GA with menu, you really want the Rename the BootVolume (i) Repeat all steps for the remain-
his wife and daughter. assignment of drive C to follow key from step (d) to the name ing partitions
the partition you selected. you make a note of in step (e) of
4patp@magenic.com (e) Find the entry corresponding your SystemVolume. Therefore 13. Install all of the apps you want
to the drive letter from step (b) if your system drive is H, you on each partition. You may
(the SystemVolume) and make would rename \DosDevices\Cx: want to change the wall
a note of it (you’ll use it in step to \DosDevices\H. paper on each to make them
(f)). Rename the key so that the (g) Close RegEdit easy to identify.
name of the key is \DosDevices (h) Reboot and select the same
C: For example, if your System- partition. Once it boots, run Thus with some forethought and
Volume is H according to step cmd.exe from the run box. planning you can configure your
(b), then rename the \ Type SET and press ENTER. workstation with multiple bootable
DosDevices\H: key to \ The SystemDrive should now partitions, and have an alternative to
DosDevices\C: (Now the parti- be C. Listing 4 shows the using virtualization.

Listing 1: Original boot.ini multi(0)disk(0)rdisk(0)partition(6)


[boot loader] \WINDOWS=”Windows Presentation Foundation
timeout=30 Beta” /noexecute=optin /fastdetect
default=multi(0)disk(0)rdisk(0)
partition(1)\WINDOWS Listing 3: Environment variables after booting
[operating systems] from a logical partition
multi(0)disk(0)rdisk(0) H:\Documents and Settings\Administrator>set
partition(1)\WINDOWS=”Microsoft HOMEDRIVE=H:
Windows XP Professional” OS=Windows_NT
/noexecute=optin /fastdetect ProgramFiles=C:\Program Files
PROMPT=$P$G
Listing 2: Revised boot.ini QTJAVA=C:\WINDOWS\system32\QTJava.zip
[boot loader] SystemRoot=H:\WINDOWS
timeout=30 USERPROFILE=H:\Documents and Settings
default=multi(0)disk(0)rdisk(0)partition(1) \Administrator
\WINDOWS VS80COMNTOOLS=C:\Program Files\Microsoft
[operating systems] Visual Studio 8\Common7\Tools\
multi(0)disk(0)rdisk(0)partition(1) windir=H:\WINDOWS
\WINDOWS=”VS2005 Development” /noexecute=optin
/fastdetect Listing 4: Environment variables after making the
registry key changes and rebooting
multi(0)disk(0)rdisk(0)partition(2)
C:\Documents and Settings\Administrator>set
\WINDOWS=”BizTalk 2004” /noexecute=optin
HOMEDRIVE=C:
/fastdetect
OS=Windows_NT
multi(0)disk(0)rdisk(0)partition(3)
ProgramFiles=C:\Program Files
\WINDOWS=”BizTalk 2006 Beta”
PROMPT=$P$G
/noexecute=optin /fastdetect
QTJAVA=C:\WINDOWS\system32\QTJava.zip
multi(0)disk(0)rdisk(0)partition(4)
SystemRoot=C:\WINDOWS
\WINDOWS=”Windows Workflow Foundation
USERPROFILE=C:\Documents and Settings
Beta” /noexecute=optin /fastdetect \Administrator
multi(0)disk(0)rdisk(0)partition(5) VS80COMNTOOLS=C:\Program Files\Microsoft
\WINDOWS=”Windows Communication Foundation Visual Studio 8\Common7\Tools\
Beta” /noexecute=optin /fastdetect windir=C:\WINDOWS

16 February 2006 • dotnetdevelopersjournal.com


XML’s Endless Possibilities,

None of the Risk.

Forum XWall™ Web Services Firewall - Reinventing Security

Security should never be an inhibitor to new opportunity: Forum XWall™ Web Services
Firewall has been enabling Fortune 1000 companies to move forward with XML Web
services confidently. Forum XWall regulates the flow of XML data, prevents unwanted
intrusions and controls access to critical Web services.

Visit us at www.forumsys.com to learn more about how you can take your next leap
forward without increasing the risks to your business.

fo r u m syst e m s ™ – t h e l e a d e r i n we b s e rv i c e s s ec u r i t y ™
SQL Server 2005

A Point of Order
Organize your data with SQL ranking functions

s
equential numbers. Sooner ates a table-valued variable called The PARTITION clause provides
or later, you’ll find a process @OrderedRows that has three columns us with a very interesting capability.
that requires you to generate of actual data. The fourth column is an Without it, the ranking functions will
a series of sequential num- IDENTITY column, which is used to create sequential numbers across an
bers. As a matter of fact, most database assign an order to that data. An exam- entire result set. With it, however, we
engines provide at least one method ple of the output from such a table- can specify groups or categories that
of producing such numbers. Microsoft valued variable can be seen in Figure should be numbered. The number-
Access, for example, has AutoNumber 1. Each row receives a number, starting ing will then restart with each group.
columns, while SQL Server has with the seed number and increasing In addition, when the PARTITION
IDENTITY columns. However, these are each time by the specified increment. clause is used to create these groups,
features of tables. There are times when the ORDER BY clause applies to each.
you need some sequential numbers, In order words, each resulting group
but creating a table is inconvenient or will be individually sorted. Using these
inefficient. So how does one proceed? two clauses together, we can devise
How does one obtain a list of sequential numbering schemes that are far more
numbers without creating tables? complex than the IDENTITY clause
SQL Server 2000 has always pro- could ever produce. So, what does each
vided one answer. SQL Server 2005 individual ranking function do?
provides more. This month’s article will The RANK function assigns a rank
explain these capabilities in detail. We number to each row of the result set
will first discuss the SQL Server 2000 This technique has been available or group. The DENSE_RANK function
solution and then move on to SQL for years, and is still available in SQL does this too. The difference is how the
Server 2005. A total of four new func- Server 2005. Now however, we have two functions handle ties. Remember
tions will be introduced. These func- more options available. that the rows of the result set or group
tions, known collectively as ranking are sorted according to the specified
functions, provide a high level of control Ranking Functions ORDER BY clause. It is quite possible
over exactly how the sequential num- The four ranking functions, RANK, for multiple rows to have identical
bers are produced. As we will see, this DENSE_RANK, ROW_NUMBER, and values in the sort column(s). When this
eases the work on the part of the SQL NTILE, are very similar to each other. occurs, the tied rows will receive equal
developer. I will wrap up the discussion In fact, their syntax is almost identical. rank numbers – but how does the num-
by showing how sequential numbers As you can see in Listing 2, each func- bering continue afterward?
form the basis of a result set paging tion is followed by an OVER clause. This In Listing 3 I’ve created a query that
solution, and will demonstrate the solu- clause serves as a container for two lists some products and their associ-
tion in both SQL Server 2000 and 2005. subordinate clauses that do the actual ated categories. The rows inside each
work: the PARTITION clause and the category are sorted by ascending list
BY JERRY DIXON IDENTITY Columns ORDER BY clause. The PARTITION price. The rows are also assigned a rank
As mentioned earlier, SQL Server clause, which is optional, specifies the via the RANK function. This can be
2000 provides IDENTITY columns. field(s) or expression(s) that is used to seen in Figure 2. Notice that there are
Tables that use these columns will divide the result set into groups. The three products with the lowest price,
contain a list of automatically gener- ORDER BY clause, which is required, therefore there are three rows with a
ated sequential numbers. Because the specifies the sort order for each group. rank of one. The next row has a rank
IDENTITY seed and increment can be
specified, the developer has a mea-
sure of control over the resulting list
of numbers. However, in order to use
IDENTITY columns, you have to use
tables, which is not always desirable or
efficient. So, how do you get around this
requirement?
The answer is: you don’t. You use a
table-valued variable instead. Variables
are almost always faster and more
efficient than actual tables. Refer to
the code in Listing 1. This code cre- f1 Figure 1: IDENTITY f2 Figure 2: RANK

18 February 2006 • dotnetdevelopersjournal.com


� �������������� ���������������������
SQL Server 2005
AUTHOR BIO: of four, not two. Sometimes this is not
Jerry Dixon is a senior devel- what we want. We might prefer that the
oper and architect for ACH numbering resume with the next rank,
Food Companies in Memphis, which in this case would be two. The
Tennessee. Over the past 16 years code in Listing 4 does just this. It uses
he has led development projects the DENSE_RANK function, which pro-
for a number of enterprise, mid- duces the results shown in Figure 3.
level, and small business organiza- The ROW_NUMBER function can
tions. While he has fulfilled multiple be used when we want consecutive
roles as an infrastructure designer, numbers and we don’t care about ties.
database administrator, and soft- In these cases, no numbers should be
ware developer, he specializes in
XML, SQL and ASP.NET. He is a
repeated, and no numbers should be
skipped. Listing 5 shows an example f3 Figure 3: DENSE_RANK f5 Figure 5: NTILE

co-leader and frequent presenter query, with the results shown in Figure
at the Memphis .NET User Group. 4. You can see that, within each category,
Jerry holds the following Microsoft the numbering is consecutive with no
certifications: MCSD (VB 6.0 repeating values. The number does start
and .NET), MCDBA (SQL 2000), over when a new category is reached,
MCSA (Windows 2000 and 2003), which is one of the main reasons
MCSE (Windows 2000), MCAD that this function is different from an
(.NET), MCT. He resides in Olive IDENTITY column. Remember that the
Branch, MS with his wife and son. PARTITION clause is optional, though,
so we can use the ROW_NUMBER func-
4 jdixon@achfood.com tion to mimic an IDENTITY column. We
would simply leave out the PARTITION
clause. The advantage of this function f4 Figure 4: ROW_NUMBER f6 Figure 6: Paging, page 1
is that you don’t have to have a table in
order to obtain your sequential num- the number of rows in a group is not an
bers. The disadvantage is that the num- exact multiple of the NTILE parameter.
bering will always be consecutive – the
numbers will always start with one and Paging a Result Set
will always increment by one. IDENTITY Let’s see how a ranking function can
columns can have an increment greater be used to solve a real-world problem.
than one and can start with a number Many applications need to display large
other than one. (Pay special attention to lists of data. These lists are often far too
this ranking function though, because large to display all at once, so a small
we will use it in a real-world example page of data is shown instead. The pro-
later on.) gram typically provides some method of
The final ranking function, NTILE, is retrieving the next page, a prior page, the
a special case. The other three ranking first page, the last page, etc. This makes f7 Figure 7: Paging, page 2
functions produce sequential numbers the application seem more responsive
across the entire result set or group. and user-friendly. specified page, the ending row number
This function creates a specific number The key to this paging solution is the for the specified page, and the total
of subgroups, giving each row in the assignment of sequential numbers to number of rows in the Product table.
subgroup the same rank number. This the rows of the result set. These numbers The application can use this informa-
can best be seen with an example. The can then be used to calculate which rows tion to determine if it is displaying
query in Listing 6 produces the same need to be included on a specific page. the first page, the last page, or a page
product list that we’ve been using all With SQL Server 2000, these numbers somewhere in the middle. Next, notice
along. This time, however, a parameter are typically created via an IDENTITY that I’ve used a nonrecursive Common
of 3 has been passed to the ranking column. With SQL Server 2005, I prefer Table Expression (CTE) to simplify the
function. The parameter specifies the to use the ROW_NUMBER ranking func- code. (Take special note of the semico-
number of subgroups that should be tion. This allows me to create sequential lon at the end of the previous SELECT
created. Examine the results in Figure 5. numbers without having to resort to the statement. When a CTE is used in a
Notice that each product category has use of a table-valued variable. statement that is part of a batch, the
been divided into three subgroups and Refer to Listing 7. I’ve created a statement before it must be followed by
that each row of a subgroup has been stored procedure that accepts two a semicolon. For more on CTEs, refer to
given the same rank. Also notice that not parameters: a page number and a page the December edition of this column in
all subgroups have the same number size. This information will be used later DNDJ Vol. 3, iss. 10.) This CTE returns
of rows. The NTILE function will divide to filter the rows that get sent back to a couple of columns from the Product
the result set or group as evenly as pos- the caller. The first SELECT statement table, along with a row number created
sible, but some variance will occur when returns the starting row number for the by the ROW_NUMBER ranking func-

20 February 2006 • dotnetdevelopersjournal.com



� ����� � �� �
� �� ��
� ����� � �

� �� � � ��
� �� �
� �


� �� � � �� � ���� �� �� � �� � �� �� �� ���� �� ������ �� � �� � �� �� �� ��� ��� ���� �� �
� �� � � � � � � �� � � � � � �� � � � � � � � � � � � � � �
� �� �� �� �� �
� �� �� �� �� ���� �� �
� �� �� ��� � ���� �� �� ��� � �� �� �� ���� �� �� ���� �� ��� � �� �� �� ��� � �� ���� �� �

���������������������������������������
��������������������������������������������
��������������������������������������������

�������������������������������������������������������
������������������������������������������������������������
��������� � ����������������������������������������������������������������������������������������������������������������������
���������������������������������������������������������������������������������������������������������������������� ������ �
���������� ������������ �����������������������������������������������������������������������������������������������������
���������������������������������������������������������������������������������������������������������������������������������
������������������������������������� ����������������������������������������������������������������������������������������
�������������������������������������������� ����������������������������������������������������������������������������������

��������������������������������
������������������������������������������������������������������������������������������������������������������������ ���������������������������������������������������������������������� ���������������������������������������������������� ������������������������������������������������������������������������������

� � � � � � � � � � � � � � � � � � � �
� � � � � � � � � � � � � � � � � � � �
SQL Server 2005
tion. I have omitted the PARTITION clause, because ond page, while Figure 7 shows that output. Finally,
I want a single set of numbers to be created across just to prove that the paging works as expected, the
the entire Product table. The next SELECT statement code in Listing 10 returns a 20-row page that contains
returns the Product information from this CTE, but the data from the previous two examples. Examine
filters out those rows that do not correspond to the the results in Figure 8, and you can see that the pag-
requested page. This ensures that only the desired ing is working properly.
number of rows is returned to the caller.
This solution returns two result sets: one that Summary
contains paging information and one that contains We’ve seen how the four ranking functions in SQL
one page of actual data. Programmers using ADO. Server 2005 can be used to create lists of sequential
NET can access the second result set via a call to the numbers. The numbering scheme can apply to an
NEXTRESULT method. If you don’t wish to return the entire result set, or it can restart each time a new
paging information, you can simply eliminate the grouping is encountered. In the case of ties, we can
first SELECT statement. In that case, the only result allow some numbers to be “skipped,” or we can
set that will be returned will be the one containing require that they be strictly consecutive. We can also
the Product data rows. cause rows to be segregated into a specific number
Now, we should test the stored procedure and of groups, assigning identical numbers to the mem-
verify the results. Listing 8 shows how to obtain the bers of each group. These new capabilities provide
first page with a page size of 10. Figure 6 shows the much-needed flexibility to the T-SQL language, which
f8 Figure 8: Paging, larger page output. Similarly, Listing 9 shows how to pull the sec- makes things easier for the SQL Server developer.

Listing 1: IDENTITY Listing 3: RANK


DECLARE @OrderedRows TABLE SELECT
( p.Name AS ʻProductʼ
Product VARCHAR(50) ,sc.Name AS ʻCategoryʼ
,Category VARCHAR(50) ,p.ListPrice AS ʻPriceʼ
,Price MONEY ,RANK()
,RowNum INT IDENTITY(1,1) OVER(
) PARTITION BY sc.Name
ORDER BY p.ListPrice
Listing 2: Ranking Function Syntax ) AS ʻRankʼ
RANK() FROM Production.ProductSubCategory sc
OVER ( INNER JOIN Production.Product p
[PARTITION BY expr, ... [n]]
ON sc.ProductSubCategoryID =
ORDER BY {
p.ProductSubCategoryID
order_by_expression
WHERE sc.ProductSubCategoryID IN (4,20)
[COLLATE collation_name]
[ASC | DESC]
} [,...n]] Listing 4: DENSE_RANK
) SELECT
p.Name AS ʻProductʼ
DENSE_RANK() ,sc.Name AS ʻCategoryʼ
OVER ( ,p.ListPrice AS ʻPriceʼ
[PARTITION BY expr, ... [n]] ,DENSE_RANK()
ORDER BY { OVER(
order_by_expression PARTITION BY sc.Name
[COLLATE collation_name] ORDER BY p.ListPrice
[ASC | DESC] ) AS ʻRankʼ
} [,...n]] FROM Production.ProductSubCategory sc
) INNER JOIN Production.Product p
ON sc.ProductSubCategoryID =
ROW_NUMBER() p.ProductSubCategoryID
OVER ( WHERE sc.ProductSubCategoryID IN (4,20)
[PARTITION BY expr, ... [n]]
ORDER BY { Listing 5: ROW_NUMBER
order_by_expression SELECT
[COLLATE collation_name] p.Name AS ʻProductʼ
[ASC | DESC] ,sc.Name AS ʻCategoryʼ
} [,...n]] ,p.ListPrice AS ʻPriceʼ
) ,ROW_NUMBER()
OVER(
NTILE(integer expression)
PARTITION BY sc.Name
OVER (
ORDER BY p.ListPrice
[PARTITION BY expr, ... [n]]
) AS ʻRowʼ
ORDER BY {
FROM Production.ProductSubCategory sc
order_by_expression
INNER JOIN Production.Product p
[COLLATE collation_name]
[ASC | DESC] ON sc.ProductSubCategoryID =
} [,...n]] p.ProductSubCategoryID
) WHERE sc.ProductSubCategoryID IN (4,20)

22 February 2006 • dotnetdevelopersjournal.com


Listing 6: NTILE WITH OrderedRows AS
SELECT (
p.Name AS ʻProductʼ SELECT
,sc.Name AS ʻCategoryʼ ROW_NUMBER()
,p.ListPrice AS ʻPriceʼ OVER(
,NTILE(3) ORDER BY ProductID
OVER( ) AS ʻRowNumʼ
PARTITION BY sc.Name ,ProductNumber
ORDER BY p.ListPrice ,[Name] AS ʻProductʼ
) AS ʻGroupʼ ,ListPrice
FROM Production.ProductSubCategory sc FROM Production.Product
INNER JOIN Production.Product p )
ON sc.ProductSubCategoryID = SELECT
p.ProductSubCategoryID ProductNumber
WHERE sc.ProductSubCategoryID IN (4,20) ,Product
,ListPrice
Listing 7: Paging with ROW_NUMBER FROM OrderedRows
CREATE PROCEDURE uspProductList WHERE RowNum BETWEEN
( ((@Page - 1) * @PageSize + 1)
@Page INT = 1 AND
,@PageSize INT = 10 (@Page * @PageSize)
)
Listing 8: Page 1, 10 Rows
AS
SET NOCOUNT ON EXEC [dbo].[uspProductList]
@Page = 1,
-- return paging info @PageSize = 10
SELECT
(@Page - 1) * Listing 9: Page 2, 10 Rows
@PageSize + 1 AS ʻStartʼ EXEC [dbo].[uspProductList]
,@Page * @PageSize AS ʻEndʼ @Page = 2,
,(SELECT COUNT(*) @PageSize = 10
FROM Production.Product
) AS ʻTotalʼ; Listing 10: Page 1, 20 Rows
EXEC [dbo].[uspProductList]
-- select only those rows
-- belonging to the proper page @Page = 1,
@PageSize = 20

dotnetdevelopersjournal.com • February 2006


23
ASP.NET

Ajax and Atlas An overview of two Ajax implementations

o
ne of the big buzz- for ASP.NET and show the differ- bly to the GAC if you are going to
words that rose to ences and similarities of them. I be using it in many projects.
fame in 2005 was will compare one of the earliest The way that Ajax.NET works
“Ajax.” The term “Ajax” libraries available: Ajax.NET and is also rather simple. There are
was first coined by Jesse James Microsoft’s ASP.NET 2.0 product, classes in the assembly that
Garrett in his essay “Ajax: A New code-named Atlas. are Attributes designed to be
Approach to Web Applications” As I started doing my research placed on your server-side
(www.adaptivepath.com/publi- for this article, I wanted to make methods in ASP.NET, of which
cations/essays/archives/000385. a grid in Excel that would com- the most important Attribute
php), and it refers to the use of pare these two products side is the “AjaxMethod.” When you
asynchronous JavaScript and by side, to see where they were apply this Attribute to your
XML to drive Web applications. similar and where the differed. methods, the Ajax.NET library
Rather than reloading the entire I found out rather quickly (and will then mirror that method in
Web page every time data needs against my assumptions) that your resulting JavaScript code
to be transmitted, only small, they were really not as similar on the client side. For instance,
necessary chunks are sent and as I had thought. I had tinkered if you have a method with this
received, with JavaScript manip- around with Ajax.NET last sum- signature “int Add(int x, int y),”
ulating the UI in response to the mer when it wasn’t quite as and you decorate that with the
data received. This gives the look mature as it has become, and I AjaxMethod attribute, there
and feel of a regular client appli- thought it was awesome. It made will be a resulting JavaScript
cation while still being hosted our Ajax development so much method on the client side called
inside of your Web browser. easier by hiding many of the “Add(x, y).” This is really all you
While Ajax methodologies have tedious details involved. Since need to know in order to use
been used for years – most nota- Ajax.NET worked so easily, I had this library to start making
bly in Microsoft’s Outlook Web assumed that Atlas would be Ajax-enabled Web applica-
Access – they have just recently implemented in much the same tions. The library contains the
BY BEN REICHELT become incredibly popular via way, but boy was I wrong! JavaScript necessary to commu-
services such Google’s Gmail and Ajax.NET is a simple instal- nicate to the server to call
Google Maps. lation. When you download the the appropriate method on the
Since Ajax has taken off library, you get a .NET assem- server, and then when the call
among Web developers, there bly and a Word document that returns to the client-side page,
have undoubtedly been many describes how it works, known it will execute a JavaScript call-
frameworks, APIs, and libraries issues, etc. In order to use Ajax. back method of your choice
to allow people to leverage Ajax NET you include a reference to the that contains the return value
with ease. I’d like to take a look assembly, aptly named Ajax.dll, from the server-side method
at two of these Ajax packages for each project or add the assem- call. Getting up and running

“Ajax.NET
and Atlas are both viable solutions for
adding Ajax functionality to your Web applications –
you just need to pick the right tool for the job”

24 February 2006 • dotnetdevelopersjournal.com


�������������
��������������� ������� ��������������
�������������������������
��
����������������
������������������������������
� �����������������
��������������������������������

�� ���������������������������
�������������������������

� �������������������������
� �������������������
� ������������ �
���������������������������������2�3���� ���������������
�� ��������������������������������������������
��������������������������� ��
��
�����������������������
���������������������������
�� ��������������������������������������������
�� ������������
���������������������� ��
��
�������������������������������������������������
����������������������������
������������������������������������������������� �� ��������������������
���������������������������������������������������������������� �� ������������
�� �������������
�������������������������������������������������������������������������������������������������������� �� ����������������������������������
�������������������������������������������������������������������������������������������������������� �� ���������������������������
������������������������������������������������������������������������������������������������� �� �����������������������
��������������������������������������������������������������������������������� �� �����������������
�� �� ����������������������������������
��������������������������������������������������������������������������������������������������������� �� �������������������������������������
������������������������������������������������������������������������������������������������� �� �������������������������������
���������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������
���������������������������������������������������������� �������� ����������������������������������
ALL RIGHTS RESERVED

� ��������������������������
�����������������������������������������������������������������
�������� ����������������������������������
���������������������������������������������������������������������� � ����������������������������
��������������������������������
�� �������� ����������������������������������
COPYRIGHT ©2006 SYS-CON MEDIA

������������������������������������������������������������������ � ���������������������������
�������������
������������������������������������������������������������������������� �������� �����������������������������������������������
����������������������������
������������������������������������������������������������������ � ����������������������������������������������
������������������
������������������������������������������ �� ����������������������������������������������
����������� � ����������������������������������������������
ASP.NET
AUTHOR BIO: with the Ajax.NET library is to ints and strings, you can return ASP.NET 1 or 2, because of its
Ben Reichelt is a software incredibly easy – you can practi- built-in classes to the .NET frame- simplicity.
developer for Magenic cally get it working by mistake. work like DataSets and Arrays, Atlas consists of server- and
Technologies Inc., a software An interesting side note about or even your own custom object client-side components to en-
consulting company based in Ajax.NET is that it actually uses types. This makes it extremely able Web developers to add Ajax
Minneapolis that specializes very little XML to work. Instead of easy to transfer data to the to their projects. These pieces
in Microsoft solutions. He has returning XML to the client and client and leave the burden of all work together to make Atlas
been working in software for then converting the XML into the rendering up to the browser. To feel very much at home in ASP.
three years and lives in Saint appropriate object form, Ajax. change the filtering or paging NET. Since Atlas was introduced
Paul, MN with his wife Erin. NET uses the JavaScript Object of a list on your Web page, for at this year’s PDC conference
You can catch up with Ben by Notation ( JSON) to send the instance, all you need to do is in September it has already
reading his blog at http://code- results to the browser. JSON is return an array of list items to undergone significant improve-
better.com/blogs/ben.reichelt. kind of like shorthand JavaScript the browser and it can loop ment. I tried to use one of the
– it’s a syntax of JavaScript that over the items and write the starter kits soon after Atlas
4ben.reichelt@hotmail.com allows you to dynamically define appropriate HTML code. By hav- was announced, but I could not
objects in your code. Ajax.NET ing your custom objects on the get it to work (this could certainly
simply returns a string as JSON client side, it allows you to pro- be a case of developer ignorance
code that gets run as a script on gram your JavaScript in a more as well). More recently, I found
the client side, and presto! – you object-oriented fashion, and it a great sample Atlas application
have your objects. The benefit also allows you to leverage the at Scott Guthrie’s blog (http://
of using JSON is that it needs no code you’ve already written on weblogs.asp.net/scottgu/archive/
parsing or serializing on the client the server side. 2005/12/26/433997.aspx).
side because it’s already in code Therefore what the Ajax.NET The sample application that
form, and it can also be less cum- library boils down to is that it Scott has created is a simple to-
bersome than XML, meaning the exposes your server-side meth- do list application that tracks
requests/responses can be that ods and objects to the browser your tasks. The sample is actually
much more efficient. The only so that you can use them in pretty full featured with paged,
downside that I can see is that it your JavaScript, and use them sorted lists and inline item edit-
makes your requests locked into asynchronously to give your ing, with no page postbacks.
a JavaScript implementation; that users a quicker, richer experi- What’s even more impressive
is, you can’t easily call a Web ser- ence on your Web sites. It is a is that Scott claims to have
vice that returns JavaScript code lightweight library with little written the app in 15 minutes
from a C# windows application, barrier to entry, and as I’ve on a plane! I highly recommend
but that’s a small price to pay for described above it’s easy to downloading Scott’s sample if
practicality. install and integrate it into your you are interested in playing
The Ajax.NET library was applications. around with Atlas – it’s simple
under some hot-and-heavy Microsoft’s Ajax product, enough to comprehend and it
development late last summer code-named Atlas, is currently shows the different kinds of
and early fall. It was created by in pre-beta stages and the most functionality in Atlas.
Michael Schwarz and he contin- recent release is the December The client-side component of
ued to improve it as the year CTP. Atlas is more than just a Atlas has several JavaScript files
went on, eventually adding library that makes Ajax Web that get included that provide
support for special controls applications easier – it’s really base functionality for Atlas to
that would make use of Ajax, a framework that sits on top of run in your browser. There is
JavaScript namespaces, and a ASP.NET 2.0 to provide built-in a browser-compatibility layer
whole JavaScript client library support for Ajax applications in to abstract the differences in
that gives you much more power ASP.NET. This is a key difference browsers’ JavaScript implemen-
on the client side. One of the between Ajax.NET and Atlas: tations. This ensures that Atlas
key features of Ajax.NET is its Atlas will only work in ASP.NET users aren’t restricted to Internet
ability to return complex types 2.0 because it leverages many of Explorer. Atlas currently works
from the server to the client-side the changes that have been made, in IE, Firefox, and Safari. Another
code; rather than being limited while Ajax.NET can be used in client script mimics the .NET

“Getting up and running with the Ajax.NET library


is incredibly easy – you can practically get it working
by mistake”

26 February 2006 • dotnetdevelopersjournal.com


Framework base class library The ScriptManager con-
with classes like “WebRequest” trol is a pretty smart control.
and “WebResponse,” Atlas It will detect that a page is
also comes with built-in UI using Atlas and will override
functionality such as data-bind- the page’s HTML rendering.
ing support, so you can bind Instead of rendering the entire
the results of server calls to page in response to an Atlas
client side controls in much call, the ScriptManager will
the same way you would in send only the HTML that cor-
your ASP.NET codebehind. The responds to what needs to
goal of Atlas is to allow you to change on the page. This leads
write your code in the same us to the UpdatePanel control.
way, except that it will now UpdatePanels are used in the
run on the client instead of the HTML markup to separate
browser. areas of the page that can be
Due to the tight integra- dynamically updated in isola-
tion with ASP.NET, you really tion. The ScriptManager knows
won’t need to type that much which UpdatePanel of the page
JavaScript code. Because should be updated and only
Microsoft has built special gets that HTML, rather than the
server controls that you can whole page. When that HTML
drag and drop in the designer, is received on the client side,
a whole lot of the monotonous the HTML is inserted into the
script code has been taken care UpdatePanel using JavaScript.
of, and is usually abstracted So instead of passing complex
even in the resulting HTML. If data types to the client for
you download the sample app processing, as Ajax.NET does,
mentioned above and take a Atlas does all of the processing
look at the HTML source of on the server side and still ren-
some of the pages, you’ll see ders HTML – just not complete
that there’s really not much HTML pages – and then lets the
JavaScript code at all, save client code determine where to
some typical __doPostbacks; put the partial HTML.
still, Scott has managed to have Ajax.NET and Atlas are both
Ajax-paging, Ajax-editing, and viable solutions for adding
Ajax-filtering on his lists! The Ajax functionality to your Web
beauty of this is in the server applications – you just need
controls working together with to pick the right tool for the
the client-side Atlas run time. job. If you are creating a new
If you do some digging (and Web application using ASP.
it can be a lot of digging) you NET 2.0 and it’s not going to be
can locate a piece of Atlas code released for a while, maybe you
that does what many of us have can use Atlas and the seamless
done before, except that we integration with ASP.NET 2.0.
always thought it was a hack; Suppose you have an exist-
Atlas hijacks the __doPostBack ing ASP.NET Web site and you
JavaScript method. By overwrit- want to incorporate some little
ing the __doPostBack method, Ajax widgets here and there. In
Atlas can intercept any control that case you would certainly
that would normally do a page want to consider using Ajax.
post and instead posts the page NET because it is lightweight
asynchronously using Ajax; and works with .NET 1.1. I per-
however, it can also retain all sonally like the fact that I can
of the good stuff that ASP.NET bolt Ajax.NET onto just about
needs to run on the server side, anything very quickly and with
such as event targets and event little fuss, whereas with Atlas
arguments. you get the feeling that once
A key ingredient to Atlas you start using it you’re kind
working so well is the addi- of locked into the Atlas world
tion of the ScriptManager and because of how it takes over
UpdatePanel server controls. the client-side code.

dotnetdevelopersjournal.com • February 2006


ASP.NET

Rapid Module Development


for DotNetNuke
Instant DotNetNuke modules

efore there were Web ity. The relationship exists as a type

b parts, DotNetNuke cre-


ated installable private
assemblies nicknamed
of contract that is held between the
two parties and enforced by the
methods, their parameters, and
modules to encapsulate the func- return types. When something is
tionality desired within a modular changed in the DataProvider, those
environment. It doesn’t take much changes must be reflected in the
experience developing modules for SqlDataProvider and vice versa.
DotNetNuke before you start asking Because the SqlDataProvider, as a
the age-old questions: I know that it’s separate project, contains a reference
powerful, but where do I start? I know to the module project that houses the
this is handled in DNN, but how? How DataProvider class, any changes to the
do I structure the module and create DataProvider will show up as errors
the installable package? At this point in the SqlDataProvider, because the
you are most likely starting to think signature of the methods, parameters,
instinctively about how to utilize a or return types does not constitute a
combination of existing tools and using CodeSmith to generate the match for the MustOverride meth-
reusable code or templates to stream- CRUD. ods provided by the DataProvider.
line development time. The DAL Builder Pro tool by Likewise, those same changes in the
In the DotNetNuke commu- BonoSoft enhanced this functionality DataProvider will show as errors in
nity, one of the most commonly by generating a fairly complete mod- any code that invokes those methods
asked questions is how to integrate ule from the tables of a database, but until the contract is restored. It is very
CodeSmith or MyGeneration tem- still the actual coding and creation helpful to complete these changes in
plates to create the Data Abstraction of the user interfaces and the con- a common fashion tailored to your
Layer (DAL). This article will hopefully struction of the project itself remains development tastes, so that when
open new paths of development by entirely manual. With the release of changes occur it is fairly transpar-
discussing a complete set of methods the ATGen SDK from AppTheory, all ent to the developer which code was
and tools to rapidly create modules this has changed. changed, and which is showing errors
for DotNetNuke. Although creating because it requires changes – or you
a series of templates that will cover Understanding Custom Business could find yourself undoing neces-
BY MARK HOSKINS the variety of elements required for Objects sary work to attempt to restore that
even the simplest module seems like When DotNetNuke adopted the contract. As always, it is best to have
a daunting task in itself that requires provider pattern for its data layer, a prescribed development protocol to
learning a new variety of languages, many developers who were familiar follow.
there are a few packages that have with creating methods using hard One of the nicest features of the
been circulated that consist of all coded SQL queries, SQL helper ATGen SDK is how you can regenerate
of the rudimentary elements to use functions, or DotNetNuke’s own specific parts of your module code to
CodeSmith to autogenerate the data SqlCommandGenerator class were update only what is necessary after
access methods and database scripts. left with a new process that was changes to the database, which saves
The actual coding and creation of the shrouded in mystery. A very common all that hassle but leaves your sensitive
business objects, the user interfaces, question is how the DataProvider business logic intact. In other cases
and the construction of the project and SqlDataProvider combine to you need to regenerate vast portions of
itself remains entirely manual when supply the data access functional- the module, possibly adding new con-

“Now just kick back and click the Generate button


to watch the magic happen”

28 February 2006 • dotnetdevelopersjournal.com


AUTHOR BIO:
“By
storing these property classes in their own Mark Hoskins is the founder of
KodHedZ Software Development,
assembly you guarantee the utilization of these classes Inc. (www.KodHedZ.net) based
out of Victoria, BC, Canada,
without requiring a reference to the business or where he has been developing

presentation classes”
ASP.NET Business Management,
eCommerce, and Dynamic
Internet Applications for over four
years, primarily using DotNetNuke
trols to handle the data entry for a new level by adding not only complete gen- components correctly, so a single as the development platform
table or columns, but you still need to eration of the stored procedures, DAL, primary key should be considered a since its conception in December
leave the business logic intact. This too CBO, and info classes, but also creates requirement when designing these 2002. In addition to desktop,
is handled by using an inherited stub the module project in its entirety. In tables for code generation. mobile and Web applications,
class as the generated business layer, fact, the module itself can be compiled • Foreign Key Constraints should Mark Hoskins has authored
so all of your custom changes can exist with the open source tool NAnt using be enforced between the related many articles and tutorials for
side by side without fear of losing the the accompanying build file included tables that directly correspond to developers on implementing
code when regenerating. in any ATGen SDK–generated module your module. These foreign keys and developing solutions using
The way that DotNetNuke uses package. are essential to the generation of a DotNetNuke and provides a
a Custom Business Object (CBO) to To those who are already familiar complete module that follows the wealth of resources at his flagship
supply a strongly typed class for each with code autogeneration tools, this rules set forth in your database. With domain, www.KodHedZ.net.
object is central to understanding the may not seem to be a revolutionary foreign keys fields, there is autogen-
DataProvider pattern. This class exists accomplishment, but the best part eration of the stored procedures that 4 kodhedz@shaw.ca
solely to house the public properties about the ATGen SDK is that it is filter the results to the foreign keys,
and the private variables that repre- completely free, and it is tightly inte- which saves considerably on coding
sent the results of the DataReader. grated with MyGeneration (which is later. For example, if you have a table
These types of classes are called info also free). Overall, the ease of use and named Pages with the three columns
classes, and for best results in a wide the lack of a learning curve to use the PageID (primary), PageName, and
variety of use cases they should be tool could allow someone without ChapterID (foreign key from the
stored in a separate assembly or any technical or development skills to table Chapters), the ATGen SDK
project than the rest of the module. quickly generate a complete, ready- will automatically create the stored
By storing these property classes in to-install module in under 10 minutes procedures and business methods
their own assembly you guarantee the from any existing database tables! to return the results by PageID or
utilization of these classes without Although this article is not ChapterID.
requiring a reference to the business intended to be a tutorial on how to
or presentation classes. In the ATGen use any of these tools, it is essential Understanding the DotNetNuke
SDK module structure, the info class- to understand the available products Module Structure
es are actually contained within the that can dramatically increase your There are many articles that can
central project for simplicity, which is productivity (for a complete tutorial be found at popular resource Web
suitable for most modules. on the AppTheory ATGen SDK, see the sites that are devoted to explain-
The CBO serializes these info References section). The remainder of ing the “why” of the Module File
classes into their respective types, the article will show the steps required Structure, and that explain the
passing the classes through the to plan, create, and implement a mod- necessary dependencies with
DataProvider to the selected ule for DotNetNuke, and demonstrate other assemblies in order to maxi- f1 Figure 1: Click on the
SqlDataProvider, or Access/Oracle/ how incredibly easy these tools can mize your module’s integration with AppTheory Icon to launch
MySQL provider. Until recently make your development cycle. DotNetNuke. Therefore in this part the ATGen SDK program
there was no definitive tool to aid
in the creation of these info classes, Designing the Database Tables
their accompanying logic classes, or Because the database is such a
their DataProvider methods, which central point of code generation, the
remained a cumbersome and time- tables must be created with a few
consuming burden for developers things in mind to produce the most
who were sure there was a better way effective, complete result when the
to spend their time. module is generated:
The DAL Builder from BonoSoft • Each table that will be used in the
is a popular application that takes a generation process must have a
defined data structure and produces single primary key field, which is
the data layer for you, and has become set to Auto-Increment. The ATGen
a popular and timesaving utility with SDK has a few problems with tables
a low price tag. The ATGen SDK from with multiple primary keys in that it
AppTheory takes all of this to a new does not generate the corresponding f2 Figure 2: MyGeneration running the ATGen SDK

dotnetdevelopersjournal.com • February 2006


29
ASP.NET
the Project Name field, which corre-
sponds to the naming convention of
your other modules.
Now you are ready to save the set-
tings you have defined, so you can
regenerate the DAL for this module
later if something changes in the
database design down the road. I
generally just name the template
the same as my project name, like
Initials_ProjectName_DAL. Once
the template is saved, click on the
Generate button to create the SQL
scripts and add the stored procedures
to your database.
There are some quirks in the data-
base script creation that still need
some fleshing out, but overall this
works extremely well.
Now that the CRUD is created,
you are ready to create the rest of the
module. On the Module Code tab,
you need to define a few properties
to define this module. The Project
Name should be the same as the one
you defined when creating the CRUD
template, and is case sensitive. Select
the database to use for this module,
generally the same one as you used in
the CRUD generation, then click View
Objects to confirm that the generated
objects are what you desire. This will
f3 Figure 3: CRUD screen in ATGen SDK show a list of the Stored Procedures
and Tables in your database that were
of the article I will focus only on the The CRUD tab contains the ele- created using the CRUD template.
structure that is produced by ATGen ments for configuring the Data Fill in the Company Name, which
SDK so that you have a complete Abstraction Layer for your mod- generally consists of the initials
understanding of the pattern. ule, including the CRUD Stored of your company. Then fill in the
Procedures. After selecting a data- Schema Prefix, which is usually the
Using the ATGen SDK to Create base to use, select the related tables same as the project name. In most
Your Module pertaining to this module. It is cases, I suggest that you leave the
First, we will open the ATGen SDK essential to follow the steps defined Object Qualifier field empty.
Master Template in MyGeneration by in “Designing the Database Tables” Now for the final settings, and
clicking on the desktop icon, or the for complete CRUD generation dur- your module will be ready to gener-
start menu. ing this step. In most cases you can ate. There are two types of project ref-
Now we need to run the template leave the defaults for the prefixes of erences that you can choose for your
within MyGeneration by clicking on the different CRUD actions, but it private assembly, which determines
the Play button. This loads the ATGen is very important to properly name if the reference to the DotNetNuke
SDK program and begins the setup of your module project now by choos- assembly is a Class Project or a Web
your custom module. ing a unique, case-sensitive name for Project. I suggest using a Class Project

“Overall, the ease of use and the lack of a learning curve


to use the tool could allow someone without any
technical or development skills to quickly generate a
complete, ready-to-install module in under 10 minutes
from any existing database tables!”

30 February 2006 • dotnetdevelopersjournal.com


u c to r!y
introipd offer
cr tion
subs

A TRULY INDEPENDENT Here’s what you’ll find in


VOICE IN THE WORLD OF .NET every issue of .netdj:
.NET Developer’s Journal is the leading

independent monthly publication targeted at .NET Security Watch


Mobile .NET
developers, particularly advanced developers. It brings
.NET Trends
.NET developers everything they need to know in order
Tech Tips
to create great software.
Standards Watch
Published
Business Alerts
monthly, .NET
.NET News
Developer’s
Book and Software
Journal covers Announcements

everything of interest to .NET Developer’s Journal is for .NET


developers of all levels, especially those “in
developers working with the trenches” creating .NET code on a daily
basis:
Microsoft .NET technolo- • For beginners:
Each issue contains step-by-step tutorials.
gies – all from a • For intermediate developers:
There are more advanced articles.
completely independ-
• For advanced .NET developers:
In-depth technical articles and columns
ent and nonbiased per-
written by acknowledged .NET experts.
spective. Articles are care-

SUBSCRIBE ONLINE!
Regardless of their experience level, .NET
fully selected for their prime Developer’s Journal assumes that everyone
reading it shares a common desire to under-
technical content – technical www.sys-con.com/dotnet/ stand as much about .NET – and the busi-
ness forces shaping it – as possible. Our aim
details aren’t watered down with or Call is to help bring our reader-developers closer

lots of needless opinion and com-

mentary. Apart from the technical content, expert ana-


1 888 303-5282 and closer to that goal with each and every
new issue!

lysts and software industry commentators keep devel-

opers and their managers abreast of the business

forces influencing .NET’s rapid development. SAVE16% ANNUAL


COVER PRICE:

OFF $83.88
Wholly independent of both Microsoft Corporation

and the other main players now shaping the course of


YOU PAY

6999
.NET and Web services, .NET Developer’s Journal

represents a constant, neutral, expert voice on the $


THE ANNUAL COVER PRICE
state of .NET today – the good, the bad, and the
YOU SAVE
ugly…no exceptions. Get 12 issues of .NETDJ
for only $6999! $13.89
OFF THE ANNUAL
COVER PRICE
OFFER SUBJECT TO CHANGE WITHOUT NOTICE
ASP.NET
produce a complete, compiled, and
packaged module for you with the
source and install packages placed
into the same folder as your module
code.

Designing the View and Edit


Controls
DotNetNuke modules consist
of a View screen that represents the
public or outward-facing UI element
of your module. All privately acces-
sible edit screens or administrative
screens are accessible by a variety of
ways. The first and most common is
through the admin menu within the
module container, which appears
once you are logged into a role within
your portal that has edit access for
this module. This is called the mod-
ule actions menu. When you gener-
ate the module using the ATGen SDK,
these screens are determined by the
tables that you’ve selected during the
CRUD creation phase. The Create,
retrieve, update, and delete function-
ality is visibly displayed through the
use of a generic yet quite powerful
series of screens for each table in the
schema.
The Add screen is shown in the
module actions menu as well as at
the bottom of the container. Some
containers may not expose this
f4 Figure 4: Module creation screen in ATGen SDK control; therefore if this functional-
ity is desired, then ensure that your
as the reference type for your mod- Find the line: selected container for the module
ules, because this choice allows for admin container includes the links
easier project management later, and <businesscontrollerclass>Compan token.
decreases the build time. yName.ProjectName.ProjectName. The list screens show a datagrid
The GUIDs that are generated for BusinessController, CompanyName. of the entries for that particular
your module must be unique to this ProjectName</businesscontroller- table, with the ability to edit, delete,
project, and are preset – you should class> or add to the table. A few really
not need to change these settings. handy features of this screen are that
Now select “Everything” in the Code and change it to read: you can select numerous items and
Generation drop-down list to create delete them, and this list includes
the complete module project. As in <businesscontrollerclass>CompanyNam full integration of the DotNetNuke
the CRUD step, you should save these e.ProjectName.ProjectNameBusinessCo pager control for simplified paging
settings prior to code generation so ntroller, CompanyName.ProjectName</ and sorting of the results.
that you can regenerate the module businesscontrollerclass> The links on the listed items in
code later if anything changes in the each table can be selected and can
database. Now just kick back and (and remove the extra period before display a detailed edit screen, there-
click the Generate button to watch BusinessController). Now you can by allowing you to alter the selected
the magic happen. go to the command prompt in item. The edit and add screens are
Now we can run NAnt to build the Windows and type “Nant -buildfile:” actually composed from the same
module and package it for installation and then open up a new window, user control, so the bulk of your
into your portal. There is one quirk browse to the folder that you just development work for the adminis-
that must be dealt with prior to build- generated, and drag the file named tration screens lies within this area.
ing in NAnt. First, open up the DNN CompanyName.ProjectName.build Although this module can be
manifest file, which was created in into the command prompt window. installed and placed onto a page
the module folder using notepad. Just click enter and NAnt should out of the box, there are several

32 February 2006 • dotnetdevelopersjournal.com


areas that need further customization. your module. This screen could be an trols, as well as the interfaces that this
The admin screens are created using advanced calendar as the central part module implements. If you are making
only textboxes for the corresponding of a detailed booking system, or a com- changes to the DNN file, it is impera-
data entry areas for each table. You plete human resources system – this tive to preserve the integrity of the
will need to define some of these as is really where you, as the developer, XML Schema. You can find an explana-
drop-down lists if they represent a become empowered. tion of this schema in the DNN source
foreign key or a series of values, or as a or install packages.
checkbox for Boolean fields. This part Deploying the Module As you can see from the aforemen-
will generally consume a fair amount If you have NAnt installed and tioned steps, the creation and deploy-
of the development time required to you’ve created your module using the ment of the fabric of your new custom
create your module. ATGen SDK, you can easily build a module can be dramatically improved
You will notice that the default View deployment package for your module by utilizing ATGen SDK, thus leaving
screen that is visible when you first by using the build scripts provided. your precious development time better
place the module on a page is blank. If not, the other method is a bit more spent doing more productive things like
You will need to specify what to show laborious, but it is important to playing games on your Xbox.
to viewers of this module. Because the understand. The folder structure of Happy coding.
entire administration, data, and busi- DotNetNuke is designed to place all
ness layers are already created, you can installed modules in their own folder Resources
leverage these elements to substantially under the DesktopModules folder in • MyGeneration Code Generator: www.
create the View screen that is present- your Web site root. Your deployment mygenerationsoftware.com
ed. Other than customizing the admin package requires a DNN manifest file • CodeSmith Code Generator: www.code-
screens, this is essentially the only to be included so that the module smithtools.com
major part of the module that will need installer can determine what to do • AppTheory ATGen SDK: projects.
to be created by a developer. In this with the package. The DNN manifest apptheory.com
screen there is no definitive example file defines the folder name for the • BonoSoft DAL Builder Pro: www.bono-
because the display essentially com- module, the files, the control defini- soft.com?tabid=55
prises the outward-facing elements of tions for view, settings and edit con- • DotNetNuke: www.dotnetnuke.com

dotnetdevelopersjournal.com • February 2006


33
Managed Space

Garbage Collection
How many managed objects is your application really creating?

p erhaps the most commonly


asked questions regarding
memory management in
.NET are: “How long does
outnumber the objects you explicitly
create. Furthermore, it’s not always
obvious to ascertain when objects
are being implicitly created simply by
Boxed Value Types
As you likely know, the .NET-type
system defines two different kinds
of types: value types and reference
a garbage collection take,” and “How looking at source code. types. Value types provide an efficient
can I control when the garbage collec- This article helps you understand means to create and work with simple,
tor runs?” Apprehensive that “pauses” how the garbage collector will affect frequently used types. Many of .NET’s
caused by garbage collections will your application’s performance by built-in types such as Int32, as well
be perceived by users, application pointing out the “not so obvious” situ- as enums and any type defined with
developers often search for ways to ations where managed objects are the struct keyword in C# (Structure
control when garbage collections created on your behalf. In particular in Visual Basic.NET) are value types.
occur. Not surprisingly, the standard we’ll look at the effects of boxing and Reference types are those types that
answer from Microsoft on these issues string manipulations on the number are created with the new keyword. The
is to leave the collector to do its thing of objects created as your application most significant difference between
instead of trying to control it manually. runs. Although this article is written value types and reference types as far
Nevertheless, concern over garbage specifically with the .Net Compact as memory management is concerned
collection timing and performance Framework in mind, many of the con- is that value types are allocated on the
remains. cepts discussed apply to the full .Net stack while reference types are allo-
The single biggest factor in deter- Framework as well. cated on the garbage collector’s heap.
mining when a garbage collection
occurs and how long it will take is
90
the number of managed objects that
your application allocates. Therefore 80
understanding how many objects
BY STEVEN you allocate is the best way to deter- 70
PRATSCHNER mine how your application will be
affected by garbage collection perfor- 60
GC latency (ms)

mance. As shown in Figure 1, the GC


latency, or the time spent in garbage 50
collection, is directly related to the
40
number of live objects allocated by
the application.
30
At first glance, determining how
many objects your application creates 20
appears easy: because you create the
objects yourself using the new opera- 10
tor, it’s obvious when new objects are
created, right? Unfortunately, tracking 0
the number of newly created objects 0 1 00000 300000 500 000
isn’t nearly that straightforward
Number of Live Objects
because objects are created “under
the covers” on your behalf in response
to certain operations. In many cases, f1 Figure 1: The time spent in garbage collection is a function of the number of
the objects created implicitly vastly objects that the application creates

34 February 2006 • dotnetdevelopersjournal.com


There are many convenience types run more frequently than it would have our example, the hash code is simply AUTHOR BIO:
defined in the .NET class libraries that to. Not only may the collector run more the Account number. The symme- Steven Pratschner is the
are designed to work with both value often, but the time spent in each collec- try between the hash code and the program manager for the .Net
types and reference types. Examples tion may increase due to the length of Account number makes for a perfect Compact Framework Common
of such types include collections such time it takes for the garbage collector to hash function. Language Runtime at Microsoft.
as array lists and hashtables. In order examine the entire object graph. • AccountData: Each Account has both Before working on the Compact
to work well with any type, collections Let’s take a look at an example that an Account identifier and an Account Framework team, Steven spent
like these often include methods that demonstrates the potential affects of balance. The Account balance is held several years working on the
take instances of System.Object as a boxing on performance and garbage col- in the AccountData value type. full .Net Framework. Steven has
parameter. As an example, consider the lection frequency. Credit for this sample • Accounts: The Accounts reference written articles and presented
definition of the Add method on System. goes to Roman Batoukov from the .Net type holds a collection of 10,000 at numerous conferences on a
Collections.ArrayList: Compact Framework team. Roman AccountData records. Accounts also variety of topics related to .Net-
developed this sample while preparing provides an index operator that allows based programming. He is the
public virtual int Add(object value); for breakout sessions at conferences, a consumer to access the AccountData author of the book Customizing
including the Mobile and Embedded for a given AccountId. the Common Language Runtime
Because Object sits at the top of the Developers Conference (MEDC) and from Microsoft Press.
.NET inheritance hierarchy, any type, the Professional Developers Conference Listings 1 and 2 show the two imple-
regardless of whether it is a value type (PDC). Roman’s sample consists of three mentations of our simple banking sys- 4 stevenpr@microsoft.com
or a reference type, can be passed at run types that form a rudimentary banking tem. The differences between the two
time. system. Two implementations of these implementations are shown in boldface.
Loosely typed collections such as types are provided: a strongly typed The differences between the implemen-
these are great for programmer produc- implementation that involves almost no tations shown in Listings 1 and 2 are:
tivity, but have surprising performance boxing, and a loosely typed implementa- • The base type of AccountData: The
implications in some scenarios. When tion that provides more flexibility, but code in Listing 1 allows alternative
a value type is passed as a parameter incurs the cost of several boxing opera- implementations of AccountData to be
to a method defined to take a reference tions at run time. The types involved in provided in the future. This flexibility
type, the CLR will automatically convert the sample are: is provided by defining an interface
the value type to a reference type at run • AccountId: Account identifiers are rep- of type IAccountData from which the
time. This conversion, termed boxing, resented by the AccountId value type. AccountData value type derives. The
involves two steps: memory is allocated AccountId contains an integer to hold implementation of AccountData in
on the GC heap for the new “reference the Account number and provides an Listing 2 does not derive from such an
type,” and the contents of the value implementation of GetHashCode. In interface.
type are copied into the newly allo-
cated space. In Microsoft Intermediate .NET Compact Framework Performance Statistics
Language (IL), boxing operations can
be identified by the box instruction. For The .Net Compact Framework can be configured to report a number of run-time statistics that
example, the following C# code: describe the performance characteristics of your application. These statistics are enabled by set-
ting the following registry value (a DWORD) to 1:
ArrayList a = new ArrayList();
a.Add(200); HKEY_LOCAL_MACHINE\Software\Microsoft\.NetCompactFramework\PerfMonitor\
Counters
generates the following IL for the call to
ArrayList.Add: When the Counters key is set, the .Net Compact Framework creates a file in your application’s
directory called <application name>.stat. These .stat files contain performance statistics from the
ldc.i4 0xc8 various subsystems within the CLR, including the class loader, JIT compiler, and garbage collector.
box [mscorlib]System.Int32 Throughout this article I’ll use performance statistics to highlight the performance differences
callvirt instance int32 between the various code examples. In particular, I’ll refer to the following statistics:
[mscorlib]System. • Garbage Collections: The number of times the garbage collector ran.
Collections.ArrayList:: • GC Latency Time (ms): The amount of time spent performing collections. In addition to the total time
Add(object) spent collecting, the GC Latency Time counter also reports the minimum, maximum, and average col-
lection latencies.
As you see, this code boxes an • Boxed Value Types: The number of value types that were boxed during the lifetime of the application.
instance of System.Int32 before calling • Managed String Objects Allocated: The number of instances of System.String that were created
Add. while the application ran.
In applications where boxing occurs • Bytes Collected By GC: The number of bytes collected while the garbage collector ran. Like the
infrequently, its affect on performance Latency Time counter, the Bytes Collected counter reports total, minimum, maximum, and average
is negligible. However, because the .Net number of bytes collected across all runs of the garbage collector.
Compact Framework’s garbage collector
initiates a collection whenever 1MB of More information on the .Net Compact Framework performance statistics, including a full
objects have been allocated, scenarios description of all data values, can be found in the .Net Framework SDK documentation or on David
in which a significant amount of boxing Kline’s blog (http://blogs.msdn.com/davidklinems/archive/2005/12/09/502125.aspx ).
occurs can cause the garbage collector to

dotnetdevelopersjournal.com • February 2006


35
Managed Space
• The type of the accounts array: Finally, the modified instance of the garbage collector never ran.
Because the implementation AccountData value type must be boxed The Accounts example demon-
in Listing 1 allows for alternate when it is stored back in the collection: strates a tradeoff between efficiency and
implementations of an account’s flexibility. I’m not suggesting that you
data, the type of the accounts ac[id] = rec; should never design with future exten-
array is IAccountData. The type of sibility in mind. However, be aware of
the accounts array in the strongly Over time, these boxing operations the performance considerations when
typed implementation is simply can add up to have a significant impact evaluating different design alternatives.
AccountData. on performance. When I ran the code
• The return type and the “param- in Listing 3 over the strongly typed String Manipulations
eter” to the index operator: The fact implementation I was able to execute Another situation where managed
that the type of the accounts array the loop 2.3M times per second. How- objects are created when you might
is a reference type (IAccountData) ever, the loosely typed implementa- not expect them to be is when you’re
in Listing 1 requires that a reference tion got through only .13M times per manipulating instances of the System.
type be the return type and param- second. This difference in performance String class. The implementation of
eter to the index operator. In our can be explained by looking at the System.String holds an immutable copy
case, the index operator works with performance statistics in Table 1 (see of the underlying character string that
instances of System.Object. the side bar .Net Compact Framework the type represents. Any changes to the
Performance Statistics for details on string result in the allocation of a new
The most important distinction how to interpret these statistics). instance and a copy of the data from
between these two implementations As you can see, the difference in the original String instance into the new
is the use of reference types by the amount of work done by the garbage String instance. As with boxing, appli-
index operator and the accounts array collector varies considerably between cations that perform only a few string
in Listing 1. The flexibility provided by the two implementations. In the loosely manipulations won’t see any affect
using reference types is what makes typed implementation, the garbage on performance. However, the extra
the implementation shown in Listing 1 collector had to traverse more than objects created by manipulating strings
loosely typed. 410,000 objects while collecting. The frequently can add up, just as they did
Now that we’ve looked at the differ- creation of these objects through box- in the boxing example we looked at ear-
ences between the two implementa- ing caused the collector to run four lier. Fortunately, there’s an easy work-
tions, let’s see how they perform. The times within our loop. In contrast, the around for applications that need to do
code in Listing 3 iterates through the strongly typed implementation didn’t frequent string manipulations: use the
accounts collection, initializing each create any garbage at all. As a result, the System.Text.StringBuilder class.
account with a balance of 100. After
all accounts have been populated, we
iterate back through them, deduct-
ing 10 from each account. The loop
Strongly Typed Loosely Typed
that updates the balances is timed Implementation Implementation
using Environment.TickCount. I iter- Boxed Value Types 2 410,002
ate through the loop long enough to
run the entire operation for at least 1 Bytes Collected By GC 0 4,128,840
second (generally speaking, running a
performance test for at least one sec- Garbage Collections 0 4
ond increases the consistency of the
results). GC Latency (ms) 0 140
There are several places where
boxing occurs when running the code t1 Table 1: Performance statistics for two implementations of the Accounts collection
in Listing 3 against the loosely typed
implementation of our Account class.
The first boxing operation occurs String StringBuilder
when we pass an instance of our
AccountId value type to the index
Implementation Implementation
operator that takes an instance of Managed String Objects Allocated 20,040 56
Object:
Bytes of String Object Allocated 5,800,480,574 2,097,718
AccountData rec =
(AccountData)ac[id]; Bytes Collected By GC 5,918,699,036 1,081,620

The same boxing operation occurs Garbage Collections 4,912 2


two lines later in our listing when we
use the index operator again: GC Latency (ms) 107,128 21

ac[id] = rec; t2 Table 2: Performance statistics for two different approaches to string concatenation

36 February 2006 • dotnetdevelopersjournal.com


Let’s take a look at an example that result.Append(“ Rocks!”); the garbage collector’s overall impact on
highlights the differences between using } application performance is the number
String and StringBuilder when manipu- of objects your application creates. Because
lating character strings. The following The performance difference between the .Net Compact Framework’s garbage col-
code sample uses the String concatena- these two implementations is amazing: the lector runs after every 1MB of objects are
tion operator to combine several strings example that uses String takes 173 seconds allocated, the more you allocate, the more
together: to run while the StringBuilder version takes time must be spent collecting those objects.
only .1 seconds! This dramatic difference can In many cases, the objects that are created
String result = “”; be solely attributed to garbage collection. implicitly on your behalf vastly outnumber
for (int i=0; i<10000; i++) { Look at the performance statistics in Table 2. the objects you create explicitly using the
result += “.NET Compact Framework”; As you can see, the garbage collector new operator. The boxing of value types
result += “ Rocks!”; ran almost 5,000 times in the slower imple- and the extra objects created when chang-
} mentation. In addition, by comparing the ing instances of System.String are two sce-
Bytes Collected by GC and Bytes of String narios where implicit object creation can
This code snippet accomplishes the Objects Allocated, you can see that the col- have surprising performance implications.
same task using StringBuilder: lector spent almost all of its time collecting If you suspect a performance problem
“extra” instances of System.String. Of the 173 related to garbage collection, use the .Net
StringBuilder result = new seconds the loop took to run, 107 of those Compact Framework performance statis-
StringBuilder(); seconds were spent collecting Strings. tics to find out how often the collector is
for (int i=0; i<10000; i++){ running, how much time it is taking, and
result.Append(“.NET Compact Summary whether most of objects it collects are cre-
Framework”); The single biggest factor affecting ated implicitly.

Listing 1: A loosely typed implementation of Accounts {


public struct AccountId private int m_balance;
{ public int Balance
public int m_number; {
public override int GetHashCode() get { return m_balance; }
{ set { m_balance = value; }
return m_number; }
} }
}
public interface IAccountData public class Accounts
{ {
int Balance { get; set;} public const int num = 10000;
} AccountData[] accounts = new AccountData[num];

public struct AccountData : IAccountData public AccountData this[AccountId id]


{ {
private int m_balance; get { return accounts[id.GetHashCode()]; }
public int Balance set { accounts[id.GetHashCode()] = value; }
{ }
get { return m_balance; } }
set { m_balance = value; }
}
} Listing 3: Accessing Account Information
Accounts ac = new Accounts();
public class Accounts int i;
{
public const int num = 10000; for (i = 0; i < Accounts.num; i++)
IAccountData[] accounts = new IAccountData[num]; {
AccountData rec = new AccountData();
public IAccountData this[Object id] rec.Balance = 100;
{ AccountId id; id.m_number = i;
get { return accounts[id.GetHashCode()]; } ac[id] = rec;
set { accounts[id.GetHashCode()] = value; } }
}
} long iterations = 0;
long start = Environment.TickCount;
do
Listing 2: A strongly typed implementation of Accounts {
public struct AccountId for (i = 0; i < Accounts.num; i++)
{ {
public int m_number; AccountId id;
public override int GetHashCode() id.m_number = i;
{ AccountData rec = (AccountData)ac[id];
return m_number; rec.Balance -= 10;
} ac[id] = rec;
} }
iterations += i;
public struct AccountData } while (Environment.TickCount - start < 1000);

dotnetdevelopersjournal.com • February 2006


37
The Training Corner

SPBU.NET: Principles and Experience


of Teaching .NET, Compilers, Software
Engineering, and OS
Teaching Microsoft .NET and Phoenix technologies

t
his article is devoted to On the contrary, my viewpoint of understanding of the fundamental
my SPBU.NET educational the current software engineering is concepts. For example, concur-
project supported by as follows: now the time has come rency and multi-threading have
Microsoft Research in 2004 for commercialization (i.e., imple- been around since Prof. E. Dijkstra’s
and accomplished in 2004-2005. The menting in commercial systems and 1960s pioneering works on sema-
goal of the project was to develop a being used by millions of custom- phores; exceptions have existed
complex of educational materials on ers) of great ideas (like OOP, modu- since Prof. B. Liskov’s CLU language
Microsoft.NET, compilers, software lar and component programming, signal construct in early 1970s. It is
engineering, and operating systems, exception handling, etc.) whose interesting to emphasize that, as a
based on my 28 years of teaching foundations were actually laid in result, students themselves (even
and R&D experience at St. Petersburg 1960s and 1970s. without the teacher’s recommenda-
University. The results of the project In university teaching I use my tions) start doing the same in their
[1-6] are uploaded to the Microsoft own teaching paradigm referred to seminar presentations.
Developer’s Network Academic as ERATO, which is an acronym for
Alliance Curriculum Repository Experience, Retrospective, Analysis, Analysis
(MSDNAA CR) Web site in the form Theory, Oncoming perspectives Making critical and comparative
of presentations and lecture notes for (Erato is the name of the muse of analysis of the most important con-
four courses (in English) and materi- romantic poetry in antique Greek cepts and technologies when teach-
als of two seminars. The results have mythology shown in Figure 1). ing them is essential. For example, I
attracted a lot of attention and I analyze the Microsoft.NET platform,
received a lot of invaluable feedback Experience as compared to the competitive Java
from all over the world. My courses Experience consists of a descrip- platform, and explain the funda-
received good ratings, and my course tion of my long-term commercial mental reasons why .NET is more
on .NET [1] was recommended by and research software project general, open style, and prospective.
a Microsoft expert for teaching at experience in my courses. In par- I certainly explain to students that
Columbia University. ticular, from 1992 to 2002 I lead St. the authors of .NET have taken the
BY VLADIMIR SAFONOV In this article I describe my own Petersburg Sun projects in the com- best of Java, since .NET was devel-
ERATO teaching paradigm I’ve been pilers and Java areas. Since 2002 oped about five years later. On the
using in all my university teaching I started working with Microsoft other hand, I show the students that
work, the contents of the courses and Research on the Aspect.NET project .NET technologies have great back-
seminars included in the SPBU.NET [7-10], which I’ve already described ward influence on Java – in particu-
project, my experience of teaching in this journal in a series of articles, lar, it relates to the decision of Java
these courses and seminars (what and on Phoenix [11], within the founders to specify and implement
the most interesting and the most framework of the Phoenix Academic boxing, unboxing, and annotations
difficult parts were for the students), Program. These kinds of things (or metadata) in Java 1.5. This way
and then outline perspectives of fur- are of great interest to students, the students can better understand
ther development. and it helps to better illustrate the the dialectic nature of software engi-
concepts and principles that I am neering development.
The ERATO Teaching Paradigm teaching.
Many current tutorials and other Theory
teaching materials on software Retrospective This entails the provision of
engineering tend to represent the Retrospective allows for the theoretical definitions, justifica-
techniques that are taught as being consideration of the historical tions, known theorems, and issues
brand new and invented currently by background of each topic being relevant to the topic being taught. In
the commercial companies that are taught since its early origin, so particular, when teaching the con-
advertising them. that students may have a deeper cept of data type, I make a review

38 February 2006 • dotnetdevelopersjournal.com


of the techniques of formal specifica- For each of the parts of SPBU. and using understandable, practical AUTHOR BIO:
tions of abstract data types: Sir Tony NET project [1-6] uploaded to the working code examples, in addition to Vladimir Safonov is a professor
Hoare’s theoretical papers on data MSDNAA CR Web site, I provide a general concepts. of computer science and the
types published in during 1960s and README file explaining the structure head of the computer science
70s, papers by D. Scott on type theory, of the corresponding course (or semi- Microsoft.NET Architecture and the laboratory at St. Petersburg
papers on initial and final algebra nar) archive. C# Language [1] University. He received his
semantics of abstract data types by For each course [1-4], I provide This is an undergraduate course Masters degree in computer
the ADJ group (1970s) (which resulted lecture presentations and lecture notes. for fourth-year students, and one science there in 1977 and has
in algebraic data-type specification Each of the lecture notes is related to of the first in Russia on this subject. been with the university for 28
languages OBJ and SDL), etc. the slides of the corresponding lecture According to my teaching principles, years. Vladimir has published five
presentation. The lecture note can be in this course I consider Microsoft. books and his research interests
Oncoming Perspectives used as the basis for teaching the lec- NET not just “per se,” but in his- include AOP, Microsoft.NET,
This is to explain my vision of near- ture. Also, a practical home task (like torical retrospective. In the history of Java, programming technolo-
future progress in the area of the topic. “please implement this method/algo- computing a number of approaches gies, compilers, and knowledge
For example, I prove and explain to rithm in C#”) is provided with each have already appeared to support management.
the students the perspectives of using lecture, based on its material. multilanguage programming whose
Microsoft.NET as a scalable software Each seminar [5, 6] material con- foundations were very close to .NET, 4 v_o_safonov@mail.ru
development platform during the near- sists of the best students’ presenta- though they supported an older, pro-
est decade. tions of the talks made at the seminar cedural paradigm. For example, the
for a few recent years. To get his credit US Burroughs 6700/7700 computer
Structure, Practice and Experience for the seminar, each student is to project and the Russian “Elbrus”
of SPBU.NET project make a report (one or two academic computer project [12] were based
This section of the article explains hours long) on one of the topics I on the principles of supporting the
the principles and the specifics of the offer to the students, or on any other basic mechanisms of programming
curriculum structure provided as the related topic selected and offered languages and their implementa-
result of the SPBU.NET project, and by the student. In any student pre- tion. They used postfix notation as
the specific details and issues related sentation I require using PowerPoint the instruction set. Actually though,
to each of its items. presentations (preferable in English) in “Elbrus” these postfix instruc-

Advertiser Index
ADVERTISER URL PHONE PG

.NET Developer’s Journal www.sys-con.com/dotnet 888-303-5282 31


.NET Rocks! www.dotnetrocks.com 877-273-4838 23
AJAX Seminar www.ajaxseminar.com 201-802-3022 43
CFDynamics www.cfdynamics.com 866-233-9626 19
ESRI www.esri.com/develop 888-288-1277 9
Forum Systems www.forumsys.com 866-333-0210 17
GraphOn www.graphon.com/itsg 800-GRAPHON 21
Hosting.com www.hosting.com 800-446-7627 13
IBM www.ibm.com/middleware/tools 5
Information Storage & Security www.issjournal.com 888-303-5282 27
IT Solutions Guide www.itsolutions.sys-con.com 888-303-5282 39
iTVcon.com Conference & Expo itvcon.com 201-802-3023 25
KaPow Technologies www.kapow.com 800-805-0823 Cover III
MapInfo www.mapinfo.com/sdk 800-327-8627 Cover II
Parasoft www.parasoft.com/jdjmagazine 888-305-0041 Cover IV
RadView Software www.radview.com/analyze 888-RADVIEW 3
Synaptris www.intelliview.com/netj 866-99IVIEW 15
SYS-CON Events www.events.sys-con.com 201-802-3023 47
SYS-CON Newsletters www.sys-con.com 888-303-5282 33
SYS-CON Website www.sys-con.com 888-303-5282 49
Verio www.verio.com/partners 866-237-4121 11
Visual Paradigm www.visual-paradigm.com 408-426-8212 6
General Conditions: The Publisher reserves the right to refuse any advertising not meeting the standards that are set to protect the high edito-
rial quality of .Net Developer’s Journal. All advertising is subject to approval by the Publisher. The Publisher assumes no liability for any costs
or damages incurred if for any reason the Publisher fails to publish an advertisement. In no event shall the Publisher be liable for any costs or
damages in excess of the cost of the advertisement as a result of a mistake in the advertisement or for any other reason. The Advertiser is fully
responsible for all financial liability and terms of the contract executed by the agents or agencies who are acting on behalf of the Advertiser.
Conditions set in this document (except the rates) are subject to change by the Publisher without notice. No conditions other than those set forth
in this “General Conditions Document” shall be binding upon the Publisher. Advertisers (and their agencies) are fully responsible for the content
of their advertisements printed in .Net Developer’s Journal. Advertisements are to be printed at the discretion of the Publisher. This discretion
includes the positioning of the advertisement, except for “preferred positions” described in the rate table. Cancellations and changes to adver-
tisements must be made in writing before the closing date. “Publisher” in this “General Conditions Document” refers to SYS-CON Publications,
Inc. This index is provided as an additional service to our readers. The publisher does not assume any liability for errors or omissions.

dotnetdevelopersjournal.com • February 2006


39
The Training Corner
tions were compiled “on the fly” by the types defined and used in an quite possible to offer much more
hardware to ordinary three-address assembly. To better explain it, I use efficient techniques. For example, I
code. Speaking in modern terms, it historical analogies and explain the explain how my principle of storing
was a kind of hardware-supported role of types on all stages of com- and updating the reference to the
just-in-time compilation (imple- putation, including run time. As current effective definition(s) for an
mented in late 1970s). There was an for security, students don’t always identifier from the hashed identi-
analogue of metadata in “Elbrus,” understand various kinds of .NET fiers table helps to make semantic
referred to as object code file exten- security, especially, role-based secu- analysis much more efficient and to
sion, which was actually program rity, evidence-based security, and avoid linear search in most cases.
structure and type information in security stack walk. To better explain Another very important topic of my
some tree-like, common, language- these concepts, historical analogies course is the concept of data type
agnostic format used by the com- and practical examples are used. and related efficient algorithms of
mon run time of this system. The most interesting topic in type-checking for the languages
Other topics of .NET are also .NET for students is XML Web ser- with name identity and structural
considered in my course from gen- vices. Students do understand its identity of types. As one of the
eral viewpoint. For example, when importance and are happy to pro- first users of Microsoft Phoenix, I
teaching the .NET Common Type vide examples and to give deep and also teach students the basics of
System (CTS), I make a review of long analytical talks on this subject. Phoenix – a state-of-the-art toolkit
the most widely known type sys- for developing, optimizing, and
tems and approaches in classical Compiler Development [2] multitargeting compiler develop-
languages, such as Pascal, C, C++, This is a course for graduate ment developed by Microsoft [11].
Simula 67, and others. I show the (in our Russian practice, fifth- As a distinguished expert on .NET
students that CTS is a reasonable year) students. The specifics of my and Java, I explain to students in
generalization of most of the well- compiler course, as compared to my compiler course the specifics
known type systems. many others, are as follows. I am of compiler development for .NET,
The course covers all main top- teaching my own efficient com- and of Java implementation.
ics of Microsoft.NET: CLI, CTS, CLS, piler development techniques that Based on the experience of
CLR, assemblies and strong names, I developed and implemented in teaching the compiler course, stu-
tools, security, Web services, remot- commercial compilers (in par- dents understand quite well both
ing, languages, etc. ticular, in Sun Pascal compiler for classical and modern concepts of
It is interesting to analyze, from SPARC architecture in the 1990s). compiling, including lexical analy-
my experience, which are the most Some of them I issued as my three sis, top-down and bottom-up pars-
difficult .NET topics for the stu- US compiler patents in 1990s. Most ing, semantic analysis, optimiza-
dents to understand, and which of these methods relate to seman- tion, code generation, run time and
.NET topics attract most of stu- tic analysis – efficient lookup and its relation to OS, and just-in-time
dents’ attention. semantic attributes (in particular, and ahead-of-time compilation. In
The most difficult themes for types) evaluation. In my course I my opinion, the students’ interest
students are metadata and security. surely refer to classical compiler in the subject of compiler develop-
The students do not always real- textbooks by D. Gries, A. Aho, R. ment is due to the fact of spreading
ize the role of metadata in .NET, as Sethi, and J. Ullman, but I show the .NET with its ideas of peer-to-peer,
language-agnostic information on students that in some cases it is multilanguage programming.
The most interesting topics for
students appeared to be: parsing
(surprising as it may seem), opti-
mization, and code generation for
RISC, VLIW, and EPIC architectures.

Software Engineering [3]


This is a course for graduate
(fifth-year) students. One major
part of this course is its devotion to
a detailed review of programming
paradigms – both the classic ones,
such as structured programming,
modular programming, abstract
data types (including the CLU lan-
guage that laid the foundation for
many modern ideas) , object-ori-
ented programming, and modern
paradigms, especially aspect-ori-
ented programming (AOP). In this
f1 Figure 1: Erato, muse of romantic poetry in antique Greek mythology course, I explain to students major

40 February 2006 • dotnetdevelopersjournal.com


concepts of software engineer- messaging/SIP/SIMPLE) are con- Readers are welcome to use my
ing, from E. Dijkstra’s structured sidered. The course also contains course and seminar materials in
programming and F. Brooks’ chief an appropriate review of computer your teaching and research proj-
programmer’s team, till modern and networking hardware and its ects. I would be grateful for any of
problems of AOP, in particular, the parts. your feedback on and interest in
principles of our Aspect.NET proj- The most interesting topics of the SPBU.NET project and perspec-
ect and tool [7-10]. Another major the course for students appeared to tives of its use and enhancement.
part of this course is devoted to be: process synchronization, sema-
detailed analysis of approaches and phores and monitors, memory man- References
techniques used at various stages of agement, and paging. 1. Safonov, V.O. Microsoft.
the software life cycle: specification, NET Architecture and the
design, implementation, testing, Programming for Microsoft.NET [5] C# Language. Undergraduate
and maintenance. The material is This is an undergraduate semi- university course: www.msd-
based on my own long-term experi- nar for fourth-year students. Many naa.net/curriculum/?id=5911
ence in leading commercial and of them provided good presenta- 2. Safonov, V.O. Compiler
research software projects for major tions with working code examples Development. Graduate uni-
companies, including Microsoft that caused agile discussions during versity course: www.msdnaa.
and Sun. the seminar. Some of the students net/curriculum/?id=5938
The most interesting topics in made presentations on their com- 3. Safonov, V.O. Software
this course appeared to be: abstract mercial projects based on .NET, Engineering. Graduate univer-
data types, aspect-oriented program- because, in our Russian reality, sity course: www.msdnaa.net/
ming, and software testing. most of the students have to work curriculum/?id=5983
since their first year at the univer- 4. Safonov, V.O. Operating Systems
Operating Systems and sity, in parallel to their education, and Networking. Undergraduate
Networking [4] to provide a financial basis for university course: www.msd
This is a course for under- themselves and their families. This naa.net/curriculum/?id=6006
graduate (second-year) students. It is great from the viewpoint of soft- 5. Safonov, V.O. Programming for
explains the basic ideas, principles, ware engineering practice. Some of Microsoft.NET. Undergraduate
and algorithms in these areas, the students even talked about their university seminar: www.msd
which are used for resource alloca- own tools for .NET, such as a tool naa.net/curriculum/?id=6243
tion, synchronization, network- to automatically check CLS compli- 6. Safonov, V.O. Compiler
ing protocols, etc. The material is ance for an assembly [5]. Development. Graduate uni-
based on my own experience of versity seminar: www.msdnaa.
using a lot of operating systems, Compiler Development [6] net/curriculum/?id=6244
since the systems for mainframe This is a seminar for graduate 7. Safonov, V.O. Aspect.NET – An
(IBM 360 and many Russian) com- (fifth-year) students. Most of them Aspect-Oriented Programming
puters, minicomputers (PDP-11 showed their deep understanding Tool for Microsoft.NET (work-
and its clones), supercomputers of compiler topics and their good ing prototype, documenta-
(such as the Russian “Elbrus” [12]), practical experience in the compiler tion, articles, and presen-
personal computers (running MS- area. One of the most popular top- tations): www.msdnaa.net/
DOS, all versions of Windows, and ics at the seminar appeared to be curriculum/?id=6219
Linux), and SPARC workstations ANTLR (Another Tool for Language 8. Safonov, V.O. “Aspect.NET
(running Solaris). Special atten- Recognition), a very widely spread – A New Approach to Aspect-
tion is paid to such fundamentals compiler development tool used as Oriented Programming.” .NET
as multithreading. In particular, it the basis for a lot of research and Developer’s Journal (Vol.1, iss.4).
may be an interesting fact that in development compiler projects. 9. Safonov, V.O. “Aspect.NET:
“Elbrus” a kind of multithreading Very interesting talks were also Concepts and Architecture.”
(with semaphore-based synchroni- made on optimization, code genera- .NET Developer’s Journal (Vol.2,
zation) was already implemented tion, and on compiling for VLIW iss.10).
and used in the late 1970s and and EPIC architectures. 10. Safonov, V.O., and Grigoryev.
early 1980s, due to the fact that D.A. “Aspect.NET : Aspect-
the concept of process in “Elbrus” Conclusion Oriented Programming for
semantically corresponds to the Based on the results of my SPBU. Microsoft.NET in Practice.”
later-defined concept of lightweight NET project, I have started another .NET Developer’s Journal (Vol.3,
process found in many later OSs. A project – TrustSPBU.NET, supported iss.7).
lot of material in the course is illus- by Microsoft Research in 2006, whose 11. Microsoft Phoenix Web site:
trated by examples from Windows purpose is to integrate the fundamen- http://research.microsoft.com/
2000/XP/Embedded and Solaris. As tal ideas, principles, and techniques phoenix
for networking technologies, both of trustworthy computing into my 12. Safonov, V.O. Programming
fundamental concepts (such as university courses [1-4] on Microsoft. Languages and Methods for
ISO/OSI network layers model) and NET, compilers, software engineering, the “Elbrus” System. Science
new ones (such as Wi-Fi and instant and operating systems. Publishing Co. Moscow, 1989.

dotnetdevelopersjournal.com • February 2006


41
���
���
��
��
SOA ���
��

Enabled SOA Transformation


���
���
���
���
Leveraging open source principles ��
��
���
a
s numerous organizations tributed software development – not EA assessment usually reveals a map
are planning to embark on only within your enterprise, but also in of redundancies across business pro- ��
their first endeavors in ser- the extended enterprise that includes cesses and systems. These redundancies
vice-oriented architecture partners, suppliers, and clients? Do you become the “low hanging fruit” for the
���
(SOA), it is important to recognize that have a successful culture of component- first areas to be targeted for migration to
the necessary organizational transfor- based design and software reuse? Do enterprise services.
mation has as much to do with cultural you consider the elimination of silos An oversimplified example might be
transformation, as it has to do with open, within your enterprise to be a major an organization with multiple business
Internet standards–based design. In fact, goal? How well aligned are your opera- systems, all of which require a software
the very nature of how business and IT tions infrastructure and capabilities with process to calculate loan risk or interest
view each other’s role and how the enter- the role of IT service provider? rate. Upon such a discovery, a natural
prise views its relationships with its mar- The aforementioned questions lead inclination might be to fund a project
ketplace partners and customers is being to a few aspects of open source prin- to create a common shared service that
altered. Such cultural change has never ciples and characteristics that may miti- could be leveraged by all such business
come easily and represents a significant gate or address some of the significant systems. Although this approach is logi-
organizational dilemma. challenges of SOA transformation. Table cal and has an obvious supporting ROI,
At the heart of an enterprise SOA 1 lists SOA challenges matched with the actual implementation will require
transformation is also the need to “think associated open source characteristics. more consideration and effort.
differently” about how an enterprise The list is by no means comprehensive, The first problem is the cultural
acquires and manages IT systems. but it is thorough enough to show the bias of the existing business systems
Albert Einstein might well have been potential relationship in applying open owners. Some will seek exemptions
talking about the challenges of SOA source principles to the business prob- to not participate, usually based upon
rollout when he said, “No problem can lem of implementing SOA. some notion that their requirements
be solved by the same level of con- Given the success of open source are somehow unique (i.e., somehow
sciousness that created it.” Building software, the overall premise is that at a the financial aspects of the math are
service-based systems involves a shift minimum there is something that can different for them). The real underlying
in thinking from large-scale, centrally be learned from the open source devel- reasons can run the gambit of NIH, con-
planned IT systems to smaller, modular opment model, which enables orga- cerns over support, or a reluctance to
development that requires collabora- nizations to become service-oriented develop dependencies on other organi-
tion and consensus building among all enterprises (SOE). zations or departments. These are some
of the stakeholders of an end-to-end IT of the cultural dynamics that are often at
process. Problem Illustration work, which tend undermine efforts to
These aspects of SOA transformation The starting point for many SOA create reusable SOA components.
BY MICHAEL alone represent a large impediment to transformations is the desire of the A second problem is very tangible
KOCHANIK success for most organizations. Some enterprise to define an overall enterprise in the sense that building a shared ser-
simple questions that can highlight the architecture (EA). EA is often employed vice for this calculation may not be the
importance are: How well do your busi- as the tool of business modernization. right thing to do in all cases. Assume
ness and IT stakeholders collaborate in In any EA initiative, the first step is usu- we deploy an enterprise service and
the fielding of new business functions? ally an evaluation of the current state institute a governance model where we
How well do you execute globally dis- of affairs by means of assessment. The instruct engineers to invoke this service

SOA Challenge Open Source Characteristic


Aligning business and IT Transparency, community-based development

Driving adoption and utilization Ease of access, community-based development

Application lifecycle management (ALM) Project persistence, agile processes, shared source code

Globally distributed development Ease of access, Internet-enabled tools

Component-based design and reuse Ease of access, shared source code, peer review

t1 Table 1: SOA challenges and open source characteristics

42 February 2006 • dotnetdevelopersjournal.com


������������� ����������� ���� ���� ������������� ������
�������������������������������������������������������
����� ����������� ���� ���� ������������� ����������� ����
���������������������
���� ������������� ����������� ���� ���� ������������� ���
������������������������������������������������������
��������� ����������� ���� ���� ������������� �����������
����������������������������
�����������������������������������������������������
����������� ���� ���� ������������� ����������� ���� ����
�����������������������
������������� ����������� ���� ���� ������������� ������ �������������������
�������������������������������������������������������
��������������������������
����� ����������� ���� ���� ������������� ����������� ���� �������������� ��������������
���� ������������� ����������� ���� ���� ������������� ���
���������������������������
������������������������������������������������������
��������� ����������� ���� ���� ������������� �����������
�����������������������������
������������ ������������
�����������������������������������������������������

���������������������
���������������������
������������������������

����������
������������������������������������������������������� ������������ �������������
����������������������������������������������������� �������
���������������������
���������������������
��������������
���������������������������������������������������������� ������������

���������� �����������������
������������������������������������� ����������������
���������
�������
������������������������

���������
����������������������������������������������� ���������������� ������������������

������������������������������� ������������������
���������������������
�������������
����������������

����������������������������������������������������������������� ������������
���������������� ����������������
������������������������
��������������������������������������������������������������� ������������������ �����������������������
������������������������ ������
�����������������������������������������������������������������������
����������������������������������������������������������������
���������������������������������������������������������������������������������
��������������������������������������������������������������������� ��������������������������

�����
������������������������������������������������������������������������

� � �
� ���������� ���� ��������������������������������������������������
��������������������������������������������������������������������� ������
���������������������������

��������������������������������������������������������������������� �������
��� ������� �������������������������������������������������������
��
����� ���
���������������������� �������������

���
�����
�����
� � ������
�����������
�������������
���������������������������������
� �
������������������
� ������������
COPYRIGHT ©2006 SYS-CON MEDIA ALL RIGHTS RESERVED NOTE: SPEAKER LINE-UP SUBJECT TO CHANGE WITHOUT NOTICE
���������
���
�����������
SOA
alignment with the goals of reducing the developers to register their compo-
development redundancy and having nents after development was complete
consistent enterprise architecture. to make them easy to discover.
The theory was that engineering
Some Focus Areas leads and project managers would occa-
According to the Yankee Group’s sionally search this library of compo-
“2004 Enterprise Web Service Study,” nents and reuse them if possible. Given
75 percent of the more than 400 US IT the amount of serious and sustained
organizations surveyed are planning attempts by qualified organizations and
to invest in SOA approaches over the smart people, the fact seems to remain
f1 Figure 1: What is changing in enterprise software development next 12 months. This seems reasonable that software reuse initiatives are rarely
because in any large-scale organiza- as successful as has been hoped. Many
directly rather than running their own tion, the concept of enterprise shared of these repositories ended up looking
copy of the software on their own sys- services that employ component-based like a kitchen junk drawer.
tems. Well, that might work for some design is not new and is easily under- The implication for SOA is that
applications that only need to invoke stood for its cost benefits. Often, “where the same fate can befall SOA service
that service a couple of times a minute, to begin” is the harder problem and registries. Whether is it reusing code
but what about other applications that reflects where open source processes or adopting a service, there are a lot
need to invoke it hundreds of times per might be applied. questions that potential users want to
second, or are in latency-critical situa- have answered before making a com-
tions, such as rendering a Web page? In Driving Adoption and Utilization mitment. Obvious questions are: What’s
this case we might option for building In the end, what makes for a suc- planned on the roadmap? Who is sup-
the software process as both an “open cessful Web service is fundamentally a porting the service? What are the known
standard” by giving it a Web services case based on whether or not anyone bugs and limitations? Who else is using
interface and as “open code” by pub- cares. Success is really a proof point it?
lishing the source and allowing it to be based on actual adoption and utiliza- The final decision is really about
run locally. tion levels. Successful open source proj- mitigating the risk of adoption. The con-
This example hopefully provides ects understand this point and invest sumer might feel more comfortable if,
an appreciation for the application of some significant percentage of effort to through the interaction with a service’s
open source principles in an attempt to support and grow the COI around the associated COI, they can get a sense
address a complex issue. In addressing project. There is a strong correlation for the service, its user base, and pos-
the cultural problem, we could adopt between how open source COIs grow sibly even the consumer’s own desire to
a community-based development and how to succeed in creating highly become a contributing member of the
approach in which business systems successful SOA components. project. The probability of adoption and
owners collaboratively participate in the A case in point is discovery. The the actual utilization of a service can be
development of a new solution. Such question is whether or not discovery enhanced by enabling a discovery regis-
a shared development model could via UDDI registry or other means is suf- try to provide easy access to the COI that
mitigate perceived risks of support and ficient by itself to drive a service’s adop- is supporting the Web service.
inflexible organizational dependencies. tion rate? This problem is analogous to
In the performance-based design prob- the push to develop reusable software Application Lifecycle Management
lem, having easy access to source code assets based upon traditional compo- While SOA’s impact on culture might
and a supporting community of interest nent-based design. Many enterprises be intuitive, what is not so obvious is its
(COI) might enable the best solution to implemented so called “component critical impact on application lifecycle
be applied. This would still be in general repositories” where they encouraged management (ALM). Existing tools

ALM Functional Area Requirement/Characteristic


Process Process-independent, supports Agile methods

Life-cycle phases Supports full spectrum of definition, design, code and build, test, deployment, and support

SCM Lightweight and net-centric code management


Example: Subversion (www.tigris.org), CVS (www.cvshome.org)

Stakeholder support Full spectrum support for business and IT users, integrates business, engineering and operations

Security Supports role-based access and application-level security for across-the-firewall collaborative
development

Deployment model Net-centric deployment as a service, SaaS vendors

t2 Table 2: Integrated ALM for SOA

44 February 2006 • dotnetdevelopersjournal.com


and software development processes may becomes even more important. A shared • Employ a Community Source Process: AUTHOR BIO:
not be well aligned to support the move component-based development method- Having access to source code is a benefit Mike Kochanik is vice presi-
to SOA. At a macro level, an organization ology is essential, and the use of common to participants in enabling successful dent of alliances at CollabNet
needs to understand that is it essentially technical frameworks is highly desirable,” SOA initiatives. Whether this is open (www.collab.net), a provider of
migrating from insular LAN-centric devel- according to Dr. Gautam Shroff, vice presi- source, shared source among partners, on-demand distributed appli-
opment with a captive group of resources dent of the Technology Program and head or simply access to the code that is asso- cation lifecycle management
to a more open WAN-centric development of the Technology Innovation Lab at Tata ciated with APIs, the potential users of a solutions for software develop-
environment with a diverse ecosystem of Consultancy Services, Ltd. Web service are more likely to participate ment. Mike has been a major
stakeholders. While the image of open source pro- and become effective contributors in the contributor to the creation of
In a recent interview on the impor- grams from an ALM perspective might be long term usage and life cycle of a Web network-centric IT strategies
tance of ALM, Gartner analyst Theresa that of an ad hoc collection of developers, service if they are enabled to participate that leverage open source soft-
Lanowitz commented that “As we start to the reality is that well-run open source at a source-code level. ware and community-based
bring forward this idea of a services-ori- projects have a comprehensive set of ALM • Adopt a Common ALM Approach: The development processes at
ented architecture, and as we start to see processes enabled by agile tools. Table 2 ability to apply a common life cycle Global 1000 organizations.
services exist in a business-to-business shows some of the characteristics of inte- across the spectrum of definition, design,
environment, the services exist from two grated ALM for SOA. Organizations can code/build, test, deployment, and sup- 4 mike@collab.net
separate companies, and those services determine by inference the core compe- port is an essential part of enabling large-
possibly are federated together in a loosely tencies in software development that they scale SOA implementations. It brings
coupled environment. So we find the idea need develop in order to address the chal- about the required communication and
of the application ecosystem, the idea of a lenges of SOA transformation. visibility across all stakeholders, including
development ecosystem, is crucial as well, project management, enterprise archi-
because there are going to be two different Summary tecture, engineering, QA, operations, and
organizations creating a service that will As an organization looks to migrate business end users. ALM also feeds the
have to be used together.” from a large, monolithic application cul- necessary compliance hygiene for SOX or
Many organizations are not prepared ture to an agile, Web service–based (SOA) other governance compliance programs.
to address the need to support across the culture, it will have to hone new core com- • Use Network-Centric Tools: Design
firewall software development with smaller petencies in managing globally distributed teams can no longer be assumed to be
agile teams from either a technology or development across the extended enter- collocated. More often than not, today
process perspective. Figure 1 shows the prise and across its partner ecosystem. these resources are coming from flex-
ALM perspective of the potential impact of The foundational pillars of these new core ible sourcing partners located in any
moving from monolithic IT applications to competencies are: governance, collabora- number of offshore locations. The tools
granular Web services. tion, ALM, discovery (UDDI registries, employed have to work efficiently across
From an open source project perspec- etc.), run time quality of service (QoS), and the Internet, while enabling the neces-
tive, the right side of Figure 1 represents service level agreement (SLA) manage- sary security. Where possible, employ-
“business as usual” for many open source ment. The good news is that most software ing WAN-centric open source tools is a
projects (i.e., smaller and geographically development organizations should be able benefit as it lowers the cost of entry for
distributed individuals and teams employ- to glean some aspects of open source prin- participants and does not create a tool
ing agile development processes, working ciples and be able to apply them to drive a barrier to prevent collaboration.
on some modularize software function logical benefit. • Support COI: Successful Web services
or component, and using the Internet as Here are some key capabilities and rec- will attract and build associated COIs.
the backbone for a software development ommendations to consider for addressing The ability to support and sustain these
platform). Project governance is often the challenges of SOA transformation: communities requires supporting
consensus driven and the project home • Get Modular: Maybe the first thing service-oriented infrastructure (SOI),
becomes a focal point for code, context, an organization needs to do is to “get including communication services and
and community. modular” about the code it builds. One collaborative software development ser-
A case in point is globally distributed approach is to use APIs that can be mir- vices. SOA initiatives should consider the
development (GDD). The ALM environ- rored as a Web service. This allows the concept of proactive community devel-
ment that supports a SOA transformation user community to decide the correct opment and management.
will have to enable an end-to-end life-cycle delivery approach, based on its own In general, the theme for success is that
process across a diverse group of stake- voluntary sense of where the control vs. it is less about how you want to do it and
holders and locations. In many cases, off- performance balance should be set. much more about how others want to do
shore development partners and business • Get Good at Collaboration: it. SOA implementation turns ordinary
partners will be critical members of the Collaboration is a critical skill in sustain- IT organizations into suppliers of shared
overall ecosystem. ing SOA. “The best companies are the services that are subject to the same con-
“With SOA you can have business best collaborators. In a flat world more straints as traditional software vendors in
units create point applications, which and more business will be done through terms of delivering expected functional-
publish services that are used by others collaboration within and between com- ity, support, and QoS. In other words,
in the same manner as using functional- panies,” as cited by Thomas Friedman being successful at SOA means there
ity from an SaaS (Software as a Service) in The World is Flat, with respect to how is some amount of “selling” to be done
provider such as Salesforce.com. Along companies will cope in a new flat land- in order to drive adoption and success.
with these opportunities, enhanced col- scape. Collaboration is an essential skill Applying open source principles maybe
laboration between distributed teams both for IT and business. a beneficial step along the way.

dotnetdevelopersjournal.com • February 2006


45
Book Review

Beginning .NET Game Programming


A beginner’s guide in both VB.NET and C#

i
f you are interested overview of DirectX, DirectX 3D,
in writing computer and GDI+. This introduction takes
games or simulations in you through devices, device param-
.NET, then the Apress eters and capabilities, and display
book Beginning .NET Game modes and into 3D coordinate
Programming will prove to be a systems, scene creation, camera
valuable resource. A trio of authors, placement and textures, as well as a
notably David Weller, Alexandre very brief introduction to matrices
Santos Laboa, and Ellen Hatton, and transformations that are part
wrote this book, which introduces and parcel of 3D computer graph-
the reader to many of the fun- ics. If your focus is on developing a
damental concepts that go into 3D game or simulation, you’ll want
programming a game. All topics to supplement the material found
are illustrated in .NET using Visual here with additional resources (to
Basic .NET or C# along with the help the reader here, the authors
.NET Framework managed wrapper provide a resource section at the
APIs for DirectX and GDI+. Title: Beginning .NET Game Programming in end of nearly every chapter to pres-
The book is organized princi- VB.NET, Beginning .NET Game Programming ent additional information).
pally around four game projects, in C# Chapter 4 provides an introduc-
including a .NET version of Tetris, Authors: David Weller, Alexandre Santos Lobao, tion to key concepts that include
as well as a space arcade game and Ellen Hatton vector and trigonometric functions
called Spacewar. Nearly every sec- (used to calculate object velocity,
Publisher: Apress
tion of the book is accompanied etc.) and the game field, and also
paperback/414 pp.
by several source code listings that delves further into sprites with an
demonstrate the concept at hand. introduction to sprite animation.
BY KEVIN WITTMER Because the source code plays an that most games require such as In addition, the authors devote
important role in introducing the network I/O for multi-user gaming coverage to developing a game
Kevin Wittmer works for reader to a particular concept, as well as applying AI algorithms to project proposal (in this context,
SmartSignal Corporation as a most will appreciate that this book implement intelligent or challeng- the proposal is used to define the
technical lead. His programming is available in either a Visual Basic ing strategies for interactive game scope of the game and the require-
interests span .NET, Java, .NET or C# edition. Thus if you pre- objects. ments that are involved). Chapters
C++, and Perl. fer to read source code examples This book touches on all of 5 through 7 develop the Spacewar
from one language to another, be these topics to varying degrees. arcade-style game, illustrating the
4kevinwittme7@hotmail.com sure to find the edition that match- The material is divided into seven concepts introduced in the first
es your language preference. chapters with the first chapter four chapters while also introduc-
There are a dozen or so core tackling the basics of GDI+ and ing more advanced concepts such
programming concepts that are collision detection. Although the as point sprites. As a bonus chap-
fundamental in developing a authors do a good job of intro- ter, they walk the reader through
graphics-based computer game ducing algorithms such as Axis porting .NETTrix to the Pocket PC
or simulation, and they include Aligned Bounding Boxes (AABB) for compact framework.
the base game object, the field or implementing collision detection, Beginning .NET Game
world, image manipulation, sprites I would have preferred that more Programming (in C# or VB.NET)
and sprite animation, the game or basic game programming concepts will provide you with a good start
simulation loop, collision detec- such as sprites (introduced in toward developing 2D or 3D games
tion, and path finding. In addi- chapter 2, after the introduction on or simulations. Although the book
tion to these concepts, there is a applying AI in games) be developed was written with .NET 1.x in mind,
myriad of fundamental concepts for the reader first. all of the fundamental game pro-
and technical details involving the Chapter 3, “Managed DirectX gramming concepts that this book
APIs used for 2D and 3D graphics First Steps” is packed with several presents are independent of a par-
display and rendering, as well as key topics. The first part of the ticular .NET release, and thus are
sound output. Finally, there are chapter launches into the managed applicable to both .NET 2.0 as well
intermediate to advanced topics DirectX API and also provides an as .NET 1.1.

46 February 2006 • dotnetdevelopersjournal.com


����������������������
��������������������������������������������������
�������������������������������������������������

���������������������������������������������
��������������� ���������������

������������������������������������������������������������������������������ ������������������������������������������������������������������������
����������������������������������������������������������������� ���������������������������������������������������������������������������
����������������������������������������������������������������������� �����������������������������������������������������������������������
������������������������������ ����������������������������������������������������������������������������
�������������������������������������������������������������������������
������������������� ����������������������������������������������������������������������������
����������������������������������� ������������������������� ��������������������������������������������������������������������������������
������������������������ ������������������� ����������������������������������������������������������������
������� ������������������
��������������� ���������� �������������������
����������� ��������������������������
��������������������������� ��������������������� ���������������������� ���������
��������������������� ���������������� ���������������������� �������������������
������������������������� ���������������� ����������� ����������������������������
������������������������� ����������������������������� ������������������ ������������������������������
�������������������������� ���������������������������� ����������������������� ����������������
���������������������������������������� �����������������

�������������������������������������������
������������

� ������������������������������
� �������� �������������������������������
��

� � �������������������������
��

� � ��������������������
������������������������������������������ � � �����������������������

����������������������������������������
� ����������������� �����������
© 2005 WEB SERVICES EDGE. ALL RIGHTS RESERVED
Book Review

Pro ADO.NET 2.0 A complete guide to ADO.NET 2.0

t
his book bills itself as the The final chapter on basic ADO.
only ADO.NET you will ever NET covers updating data, including
need. This is a bit boister- adding, modifying, and deleting rows.
ous, but mostly true. This It spends a lot of time on merging
book covers pretty much all facets of tables, including some more informa-
ADO.NET programming, and covers tion on differences between how SQL
them well. This well-written book can Sever and Oracle handle merging.
take an ADO.NET novice, and advance The first chapter in what I would call
him or her to being an ADO.NET pro. the advanced section (the book is not
This book concentrates on ADO. officially divided into two sections)
NET, so to be a complete database continues with more advanced updat-
programmer, you will need other books ing issues such as concurrency issues,
to cover the non-ADO.NET parts of null values, and how triggers affect
database programming; in particular, the “number of rows affected” value
this book does not really cover SQL returned by an update. It also includes
syntax, or non-programming aspects of working with hierarchical data. The
databases. Experienced database pro- next chapter covers transactions start-
Title: Pro ADO.NET 2.0
grammers will already have this knowl- ing with the basic ACID definition
Author: Sahil Malik
edge, but programmers who are new (Atomic, Consistent, Isolated, and
Publisher: Apress
to database programming will need Durable), to threads and differences
ISBN #: 1-59059-512-2
at a least a good book on SQL syntax. between ADO.NET 1.1 and ADO.NET
However that is fine; no book can cover Price: US $49.99 2.0.
everything, and as far as ADO.NET 2.0 The next-to-last chapter covers
itself goes, this is likely to be the only some more advanced topic such as using .NET as stored procedures and
book you need. executing large queries asynchro- triggers inside SQL Server. Microsoft
Like most ADO.NET books, this one nously, storing .NET objects in SQL and others are pushing triggers and
starts off discussing the problems with Server 2005, and retrieving multiple stored procedures as the best and most
connected ADO database program- datasets with a single query. Although modern way to implement database
ming, and how the disconnected model this book concentrates on using SQL logic, and starting with SQL 2005, SQL
BY DENNIS HAYES of ADO.NET solves these problems. It Server 2005, it also points out how server can import .NET assemblies
then does an excellent job of present- things differ if you are using Oracle, into the server to be used as stored
Dennis Hayes is an independent ing an overview of the entire ADO.NET Access, or older versions of SQL Server. procedures. Personally, I think this is
software consultant in Atlanta, GA, class hierarchy. This includes the base Here it points out that you can return the coolest feature in SQL 2005, and
and has been involved with the classes that define ADO.NET, and the multiple datasets from Oracle, but it this book does a good job of getting you
Mono project for over three years. derived classes that provide interfaces warns that for future compatibility, started using it.
for each of the different databases. It you should return multiple cursors The final chapter in the book covers
4dennisdotnet@yahoo.com does this both graphically with class instead. I like that about this book. It ADO.NET best practices. This chapter
diagrams, and by discussing each of the follows this with a chapter on discon- is dived into two sections. The first sec-
classes and its members. nected databases covering details on tions covers situations such as deciding
It then shows how to do basic the DataSet object including tables, between using a DataReader and a
database programming using both the rows, columns, constraints, relations, DataSet, where the choice depends on
drag-and-drop capabilities of ADO.NET and primary keys. The chapter ends the job. The book gives good, concise
components and Visual Studio, and also with a discussion of strongly typed information on when to use which
how to manually create connections DataSets using XML Schemas. Later in one. The last part of the chapter cov-
using just code. The next half dozen the advanced part of the book there is ers situations like connected versus
chapters go into more detail on each a chapter devoted to accessing XML disconnected databases, where baring
part of database programming, starting files as databases. There is a chapter unusual circumstances, one will clearly
with connecting to the database with on retrieving data and creating que- be the better option.
details on the IdbConnection interface ries both manually and graphically, a Also as a bonus, until about March,
and the DbConnection class. It also cov- chapter on sorting, searching, and fil- those who purchase this book can also
ers why connection pooling is impor- tering, which includes more informa- download the ebook (normally $25) for
tant, how it works, and how to change tion on the XmlDataDocumnt object, free.
the default settings when needed. and creating XmlSchemas. XML plays This is likely to be the one ADO.
Next it covers basic database several key roles in ADO.NET, and this NET book that stays next to my desk for
queries on connected databases, and book reflects that. quick reference.

48 February 2006 • dotnetdevelopersjournal.com


Visit the���
���������������

Website Today!
���������������������������������
���������������������������

24/7
����������������
������������������������������������������
���������������������������������������������������

����������
�������������������������������������������������������������������������������������

�������������
����������������������������������������������������������������������������������������

��������
������������������������������������������������������������������
��������������������
����������
���������������������� ��������������������������������������������������
������������������ ����������������������
������������������������������������ ������������������������������ ��������
��� ����������� �������������������������������������������������������������
�������������������� ������������������������������ �
������������������������ ��������������������������� ����������
������������������� ����������������� ������������������������������������������������������������������������������
������������������� ����
��������������������������� ��������������������������������
��������������������
�����������������������������������������������������������������������

������������������������������������������
Mono

Mono 1.1.12 Released New book on Mono from Apress

Mono 1.1.12 Released in Parse, implementations for New Mono Book from Apress
The biggest changes in this the 2.0 string compares, System. Apress has released Practical
release come in SWF (System. Globalization, System.Text 2.0 Mono another book on Mono. It
Windows.Forms). This makes sense, (including updated CJK codecs), covers WinForms under Mono
as SWF is moving into debugging updated reflection code, and URI (including a section on 2.0 con-
mode in anticipation of having full parsers. The System.XML 2.0 API trols), ASP.NET (including how to
support for SWF in the major 1.2 is done, except for System.XML. set up both the Apache server and
release expected in early 2006 (pos- Serialization. Last-minute changes the Mono XSP server), GTK+, and
sibly by the time you read this). The to Nullable<T> boxing conventions other important parts of Mono.
“Nice” theme has been improved, are partially implemented, it still The book uses System.Windows.
and a new “ClearLooks” theme has some bugs, and some changes Forms to create an RSS aggregator
has been added. Newly supported need to be made to the run time as using many common WinForms
features include MDI applications, well. Work continues on the System. controls, including a data grid.
toolwindow, and shortcut and key Configuration namespace needed .NET Developer’s Journal and I
navigation. TextBox and RichTextBox for ASP.NET 2.0. The named and have made an agreement that I
now support cut and paste, includ- unnamed 2.0 Semaphore classes will write a book review for the
ing keybindings, drag and drop, and have been implemented. magazine each month in 2006. This
undo. Pedro, who worked on the started last month with a review of
DataGridView control, has contin- .NET 2.0 Generics from WROK press,
ued to work on the control, and this Pro ADO.NET 2.0 from Apress this
version includes his latest updates. month, and Mono: A Developer’s
The Menu infrastructure has been Notebook from O’Reilly next month.
improved, and System.Drawing is A full review of Practical Mono will
now 2.0 compatible. appear at some point in the next
The JIT compiler for S390 has few months. Suffice to say, the book
been improved, PowerPC bugs is worth its US$49.99 price, and you
exposed by new tests have been should not wait for the full review
fixed, and bugs in floating point to add it to your bookshelf. I will
code generation for ARM proces- also be reviewing two other books
BY DENNIS HAYES sors have been fixed. The JIT com- on Mono, Cross-Platform .NET
piler also has a new, better optimiz- Development, also from Apress,
Dennis Hayes is an independent er for dead code elimination, which and the aforementioned Mono: A
software consultant in Atlanta, GA, will be even more useful in the next Portable.NET Developers Notebook.
and has been involved with the release when new optimizations Last month I noted that Portable.
Mono project for over three years. will tend to produce more dead NET had received two US$4,500 Odds and Ends
code. grants (totaling US$9,000) for com- There has been some code
4dennisdotnet@yahoo.com The new debugger is working, pletion of LibJit, and the addition of checked in to Mono as a start on
but with bugs; X-Develop, a com- a C# front end for LibJit. This raised COM Interop; this is interesting, but it
mercial multilanguage, cross-plat- the question of what happened is hard to tell what will come of it.
form IDE from Omnicore that sup- to the US$4,500 donated as prize Firebird has a release candidate
ports Mono, now has a GUI interface money for work on SWF last year. It for version 1.5.3, and a first beta of
for the Mono debugger (www. turns out that only US$500 had been version 2.0. The project also now
omnicore.com). claimed, so US$1,700 was awarded has a newsletter, and has published
An implementation of the reg- to Gopal for his work on the project; a roadmap for 2006. The plan is to
istry is now available on Unix, and so, there is still US$2,300 of that have a beta release of version 3.0
Iron Python 0.9.6 can run on this prize money to be claimed by devel- towards the end of the year that will
release of Mono. Mono now has an opers. Join the project and maybe be based on the “Vulcan” project,
embeddable HttpListner Web server, you can earn part of it. which is a heavily refractored ver-
many bugs were fixed in the mbas Two big changes coming in the sion of Firebird. Firebird is the open
compiler, and the Npqsgl database next release of Portable.NET will be source database based on code from
driver was upgraded to use the latest the use of LibCrayons (a lightweight the Borland Interbase product. You
version (1.0beta1). drawing library created specifically can get all of the code, programs, the
There are a number of updates to implement System.Drawing) as document mentioned above, and
to the .NET 2.0 classes, includ- the back end for System.Drawing, more from their home page at www.
ing performance improvements and the use of LibJit in Portable.NET. firebirdsql.org.

50 February 2006 • dotnetdevelopersjournal.com

Das könnte Ihnen auch gefallen