Sei sulla pagina 1di 36

0109vsm_C1.

v2

12/15/08

11:56 AM

Page 1

Is Agile Rock or Disco?


VisualStudioMagazine.com

E N T E R P R I S E

S O L U T I O N S

Partition
Web Apps
Intelligently
JANUARY 2009 Vol. 19, No. 1

Microsofts MVC framework makes it


possible (finally!) to implement a
separation of concerns in ASP.NET.
PLUS

Target Multiple .NET Frameworks


Windows Workflow Changes Direction

F O R

.N E T

D E V E L O P M E N T

Project5

12/11/08

4:42 PM

Page 1

BeTheDataGuru

Visual Studio

WPF/Silverlight

SharePoint

SQL Server

Java

COM

PowerShell

Project5

12/11/08

4:43 PM

Page 2

Achieve AHigher State Of DataVisualization


To master the art of data visualization, you must seek out the leader. For almost two decades,
Software FX has risen above all others by bringing top-of-the-line data visualization tools to
enterprise developers working with diverse markets, platforms and environments. This
wisdom has evolved into a vast body of products, including a data presentation tool that
provides a best-of-breed solution for Windows developers seeking enterprise quality and
performance, as well as a professional IT monitoring solution offering incredible features for
reporting and monitoring data. For a world of data visualization products that can raise your
work to a higher level, depend on the source thats clearly on top.
Our most popular product, Chart FX provides
charts, gauges and maps with additional vertical
visualization functionality for business intelligence
(OLAP), geographic data, financial technical
analysis, and statistical studies and
formulas. Recognized as the innovator
and leader of the charting component
category for the past 15 years, Chart FX
delivers incomparable gallery options,
aesthetics and data analysis features.
Grid FX was specifically designed for visual studio
developers to take advantage of a powerful
design-time experience, integrated Chart FX
functionality right in the box, and AJAX to
provide robust, run-time functionality in ASP.net
applications. The dynamic aesthetic features
for data presentation and analysis allow simple
adaptation to an existing application or to specific
corporate branding guidelines.
PowerGadgets puts powerful IT monitoring
on your desktop and in your data sidebar.
IT professionals can now create gadgets
that consume data from WMI, Exchange,
SQL Server and even the Windows Registry.
PowerGadgets does not require any
development environments, servers or
browsers to run real-time gadget components
such as charts, gauges and maps.

Visit softwarefx.com for interactive demos and more information about our latest products.

Data visualization for every need, every platform

0109vsm_TOC_02-04.v6

12/15/08

9:39 AM

Page 2

Contents
January 2009 VOLUME 19 NO. 1

C O LU M N S
C# CORNER

21

Target Multiple .NET


Frameworks
Many developers have the misconception that
targeting older versions of the Framework means
you cant use any of the new C# language features.
Its time to dispel that myth. BY BILL WAGNER

D E PA RT M E N T S

6 Letters to the Editor


7 Editors Note BY PATRICK MEADER
8 First Looks
Product Listings . . . . . . . . . . . . . . . . . . . . . . . . . . . .8
Reviews . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9

10
F E AT U R E S

10 Partition Web Apps Intelligently


Microsofts Model-View-Controller framework makes it possible to
implement a separation of concerns in ASP.NETsomething that was
difficult, if not impossible, previously. Learn how to take advantage of
MVC to design better Web apps that separate their architectural elements
the UI, business logic, and codeproperly, as well as how to review what
you create with unit testing. BY STEVE MICHELOTTI

The MVC framework solves the


separation of concerns problems of
traditional web forms by partitioning
responsibilities between Models,
Views, and Controllers.
Steve Michelotti, Partition Web Apps Intelligently, p. 10

VISUAL STUDIO MAGAZINE January 2009 VisualStudioMagazine.com

24 Ask Kathleen
Windows Workflow Changes Direction
Learn how Windows Workflow 4.0 changes everything; why using string primary keys is a bad idea;
get a data grid for Windows Presentation
Foundation; load files at runtime; and how to copy
files into the executable directory.
BY KATHLEEN DOLLARD

28 Special Interview
Connect to the Cloud
In this special interview, Microsoft Corporate Vice
President Robert Wahbe discusses the Azure
Services Platform and Software plus Services
applications with 1105 Medias Jeffrey Schwartz
and Michael Desmond.
BY JEFFREY SCHWARTZ
AND MICHAEL DESMOND

31 Index of Advertisers
32 The Pragmatic Developer
Is Agile Rock or Disco? BY BILLY HOLLIS

Project4

12/11/08

4:04 PM

Page 1

Your best source for


software development tools!

LEADTOOLS Document
Imaging v 16:
by LEAD Technologies
LEADTOOLS Document Imaging has every
component you need to develop powerful
image-enabled business applications including
specialized bi-tonal image display and
processing, document clean up, high-speed
scanning, advanced compression (CCITT
New
G3/G4, JBIG2, MRC, ABC) and more.
Version
Multi-threaded OCR/ICR/OMR/
16!
MICR/Barcodes (1D/2D)
Forms recognition/processing
PDF and PDF/A
Paradise #
L05 03201A01 Annotation (Image Mark-up)
C/C++, .NET, WPF - Win32/64
$
99
programmers.com/lead

2,007.

Paradise #
D77 09101L01

1,444.99

949.

Call for pricing on the Standard High Availability


Acceleration Kit and Midsize Acceleration Kit.

Foundation
Acceleration Kit
Paradise #
V55 47101A01

2,504.99

programmers.com/vmware

TX Text Control 14

by /n software

The c-treeACE database engine is a high performance


database alternative proven by developers in mission
critical enterprise systems, desktop deployments, and
embedded devices for over 25 years.
Complete set of APIs including ADO.NET, LINQ,
C#, C/C++, ODBC, JDBC, VCL, and dbExpress
Graphical productivity tools
Simple deployment
No DBA or ongoing administration
Low deployment licensing costs
Cross-platform support for all major platforms
including Windows, UNIX, Linux, and Mac OS X

New
Word Processing Components
Release!
TX Text Control is royalty-free,
robust and powerful word processing
software in reusable component form.

/n software Red Carpet Subscriptions give


you everything in one package: communications components for every major Internet
protocol, SSL and SSH security, S/MIME
encryption, Digital Certificates, Credit Card
Processing, ZIP compression, Instant
Messaging, and even e-business (EDI)
transactions. .NET, Java, COM, C++, Delphi,
everything is included, together with per
developer licensing, free quarterly update CDs
and free upgrades during the subscription term.
programmers.com/nsoftware

Sophisticated workflow engine

Paradise #
SC5 03101A01

Bottom line: dtSearch manages a terabyte of


text in a single index and returns results in
$
99
InfoWorld
less than a second.
programmers.com/dtsearch

VMware Infrastructure 3 offers SMB


organizations a scalable and cost-effective
way to optimize utilization of technology
assets, simplify IT management and protect
the data and IT environments that run their
businesses. Three new Acceleration Kits are
now available, one for each of the three
editions of VI3. These new kits offer midsize
and smaller organizations and branch offices
a cost-effective way to deploy a comprehensive virtualization solution that includes
centralized management functionality.
The ideal organization has a growing IT
environment with between 15-60 servers.

by FairCom

TechExcel DevTrack is the most powerful,


affordable and easy-to-use defect and project
tracking tool for development organizations.
Youll dramatically transform your development
processes, save significant time and resources,
and deliver quality products on-time and
on-budget.

1,414.99

Single Server
Paradise #
D29 02101A07

New
Release!

c-treeACE Professional

Powerful Defect and Project Tracking


by TechExcel

Add dtSearchs blazing speeds


(CRN Test Center) searching and
New
file format support
64-bit
Version!
dozens of full-text and fielded
data search options
file parsers/converters for hit-highlighted
display of all popular file types
Spider supports dynamic and static web data;
highlights hits with links, images, etc. intact
API supports .NET, C++, Java, SQL and more;
new .NET Spider API

/n software Red Carpet


Subscriptions

DevTrack Small Team Edition

5-User Pack
Paradise #
T34 0208

VMware Infrastructure
Acceleration Kits

dtSearch Engine for Win & .NET

Point-and-click administration
Fully configurable user interface

Paradise #
F01 0131

711.99

Make your applications faster, easier to deploy,


and more affordable with c-treeACE.
programmers.com/faircom

Altova MapForce 2008

programmers.com/techexcel

919.

programmers.com/theimagingsource

Enterprise Architect 7.1

Visual Data Conversion,


Transformation, and
Integration Tool
by Altova
MapForce: The premier data mapping,
conversion, and integration tool from
the creators of XMLSpy. Through
its visual interface, users can map
seamlessly between any combination
of XML, database, flat file, EDI, and/or
Web service, then convert data instantly
or auto-generate an application for
recurrent transformations. Languages for
code generation include: XSLT 1.0/2.0,
XQuery, Java, C++, and C#.

.NET WinForms control for VB.NET and C#


ActiveX for VB6, Delphi, VBScript/HTML, ASP
File formats DOCX, DOC, RTF, HTML, XML, TXT
Professional Edition
PDF export without additional 3rd party
Paradise #
tools or printer drivers
T79 02101A01
Nested tables, headers & footers, text
$
99
frames, bullets, numbered lists, multiple
undo/redo, sections, merge fields
Download a demo today.
Ready-to-use toolbars and dialog boxes

New
Release!
Enterprise Edition
1 user
Paradise #
I0D 03101A02

1,056.99

programmers.com/altova

Visualize, Document and


New
Control Your Software Project
Release!
by Sparx Systems
Enterprise Architect is a comprehensive,
integrated UML 2.1 modeling suite
providing key benefits at each stage of
system development. Enterprise Architect
7.1 supports UML, SysML, BPMN and
other open standards to analyze, design,
Corporate Edition
test and construct reliable, well under1-4 Users
stood systems. Additional plug-ins are
Paradise #
also available for Zachman Framework,
SP6 0001
MODAF, DoDAF and TOGAF, and to
integrate with Eclipse and Visual Studio
$
99
2005/2008.
programmers.com/sparxsystems

196.

StorageCraft ShadowProtect
IT Edition v3.x

Telerik RadControls

Multi-Edit 2008

by Telerik

by Multi Edit Software

by StorageCraft
Create, edit or restore backup images on as
many servers, desktops and laptops as needed.
Create online or cold state backups in minutes,
no software installation required. StorageCraft
ShadowProtect IT Edition provides complete
bare metal recovery in minutes. ShadowProtect
IT Edition provides IT Professionals with a
bootable Windows environment to create and
restore compressed and encrypted backups,
no software installation required.

Add grid, combo, editing, navigation and charting


functionality to your AJAX and ASP.NET projects.
RadControls for ASP.NET enhances your Web
applications by adding AJAX functionality to your
ASP.NET projects. The suite takes full advantage
of the features included in Visual Studio 2005.
RadControls for ASP.NET helps developers deliver
feature-rich, standards-compliant (WAI-A, WCAG
1.0, XHTML 1.1) and cross-browser compatible
Single Developer
Web applications, while significantly cutting
Paradise #
their development time. RadControls for ASP.NET
TB3 01101A01
includes: RadEditor, RadTabstrip, RadInput,
RadCalendar, RadUpload, RadWindow, RadAjax,
$
99
RadGrid, RadCombobox, RadMenu, RadSpell,
RadChart, RadTreeview and more.
programmers.com/telerik

Multi-Edit 2008 delivers, a powerful IDE,


with its speed, depth, and support for
over 50 languages. Enhanced search
functions include Perl 5 Regular
Expressions and definable filters.
Supports large DOS/Windows, UNIX,
binary and Mac files. File Sync
Integration for: Delphi 6, 7, 2005,
C++Builder 6, BDS 2006 and RadStudio
2007, VB 6, VC 6, VS 2003 & VS
2005. Includes file compare, code
beautifying, command maps, and
much more.

648.

3,252.99

programmers.com/storagecraft

800-445-7899
Prices subject to change. Not responsible for typographical errors.

New
Release!
1-49 User
Paradise #
A30 01201A02

161.99

programmers.com/multiedit

programmersparadise.com

0109vsm_TOC_02-04.v6

12/15/08

9:39 AM

Page 4

Online

Check out these and other exclusive online articles and tutorials on the Visual Studio Magazine Web site at

VisualStudioMagazine.com

Content
LEARN FROM THE PROS
As a developer you are constantly
facing the problem of how to keep
up with all the new technologies
being released while still getting
your job done. You keep hearing
about solutions to your programming problems but the question is:
are they the right solutions for your
particular needs? You could spend
the hours or even days trying to
find the answers yourself, or you
could let the experts do it for you.
Redmond Media Group Events offers
a variety of conferences and shows
where you can learn about new technologies and what they might offer
you, attend in-depth workshops that focus on topics specific to your
needs, ask questions of the experts, and interact with your peers to
discuss problems they face and what solutions theyve come up with.
Whether its Web design, .NET development, or SQL Server programming,
weve got an event that matches your needs. Visit the Redmond Media
Group events page at http://redmondevents.com to learn more about
upcoming conferences and shows.
ONLINE ARTICLES

Inside VSTS: Branching in


Visual Studio 2010
One limitation in Team System today is that you cant easily visualize
your branching structure so its difficult to understand the movement of
code from branch to branch. In this installment of Jeff Levinsons Inside
VSTS online column, he takes a look into the future and explains how
the new branch visualization feature in VS 2010 will bring order to the
chaos of branching and merging.
LOCATOR+ CODE: VS0901JL1

Practical ASP.NET: Creating Master/Detail


and Update Pages with Entity Framework
In previous columns Peter Vogel showed how to build a simple Entity
Framework model and used it to drive a series of drop-down lists both
with and without the AJAX-enabled UpdatePanel. With this column, he
moves on to the next obvious step: Creating a Master/Detail page
with updating.
LOCATOR+ CODE: VS0901PV1

Practical ASP.NET: Routing Your


ASP.NET Application
One of the features added in Service Pack 1 for .NET 3.5
is routing (which first appeared in the MVC version of
ASP.NET). Routing allows you to disconnect the physical
structure of your site from the URLs that users invoke to
access pages on your site. Peter Vogel explains how to
take advantage of this feature to rearrange your sites
structure without invalidating your users bookmarks.
LOCATOR+ CODE: VS0901PV2
ONLINE BLOGS

VSMs Big Issue


Visual Studio Magazines Editor in Chief Patrick Meader
and Managing Editor Guy Wright are kicking off a collaborative blog where they take a look at some of the bigger
issues facing .NET developers these days. The blog will
feature opinions, interviews with industry insiders, and
pose questions designed to stimulate discussion. Check
out their new blog.
LOCATOR+ CODE: VS0901BI1
ONLINE TUTORIALS

Wahlin on .NET: Adding Style to


Silverlight 2 Controls
Silverlight 2 provides a nice set of controls that can be
used to capture and display data. While control properties can be set directly on the control in a XAML file
using attributes, some properties will be duplicated
between controls, causing maintenance headaches. In
this tutorial, Dan Wahlin explains how to avoid duplicating
properties between controls.
LOCATOR+ CODE: VS0901DW1

What Are Locator+ Codes?


Locator+ codes give you instant access to a feature on Visual
Studio Magazine Online. Simply type the Locator+ code into
the field in the upper-right corner and click on FIND IT.

.NET NEWSLETTER SIGN-UP


Every week, the .NET Insight e-mail newsletter brings you up-to-date news, technical information, opinions,
interviews, and analysis on topics and technologies such as Visual Basic .NET, C#, SQL Server and data access,
ASP.NET, wireless, Web services, and XML. Sign up for free at visualstudiomagazine.com.

VISUAL STUDIO MAGAZINE January 2009 VisualStudioMagazine.com

San Francisco
Hyatt Regency Embarcadero
February 23-27, 2009

SAVE
UP TO

$300

Dont Miss Out On This Special


Offer For VS Magazine Readers!
Register for VSLive! And Get a FREE pass to
the MSDN Developer Conference!
Register for VSLive! San Francisco by Jan. 21 and save an additional $100
over our Early Bird savings. Be sure to use promo code NQ9F14 and save
an additional $100 off of our regular conference packages.
Software development is changing faster than ever, and
Microsoft continues to introduce key new products. Dont
get left behind. Join your fellow developers for:

Tons of independent, deep-dive content VSLive! is


known for.
Over 80 sessions and workshops
Production products including NET 2.0, ADO.NET
Entity Framework, SAP.NET, AJAX, Windows Forms,
and DataSet.
New products including WPF, WCF, WF, .NET
3.0/3.5, Silverlight 2.0, VSTO, LINQ, ADO.NET Entity
Framework
Future technology including .NET 4.0, Cloud
computing, Rosario, Windows 7, Multi-Touch
Tech tips from the best minds in the business with
information you can use now.

BONUS!
FREE pass to Microsofts one-day
MSDN Developer Conference on
Monday, Feb. 23.
(Space is limited; first come, first served.)

To view the complete agenda and take


advantage of your VS Magazine reader
discount, go to vslive.com/sf2009. Be
sure to enter priority code NQ9F14.

Brought to you by:

0109vsm_VSLive Ad_p5.indd 1

12/15/08 2:15:41 PM

0109vsm_Letters.6.v5

12/15/08

2:30 PM

Page 6

Letters
Letters to Visual Studio Magazine are
welcome. Letters must include your
name, address, and daytime phone
number to be considered for publication. Letters might be edited for form,
fit, and style. Letters express the point
of the individual authors, and do not
necessarily reflect the views of the
editors, VSM, or 1105 Media. Please
send them to Letters to the Editor, c/o
Visual Studio Magazine, 230 California
St., San Francisco, CA 94111; fax
them to 415-814-0961; or e-mail
them to vsmedit@1105media.com.

VisualStudioMagazine.com
January 2009 Volume 19 No. 1
Editorial Staff
Vice President, Doug Barney
Editorial Director
Editor in Chief
Managing Editor

Patrick Meader
Guy Wright

Managing Editor, RMG

Wendy Gonchar

Associate Managing
Editor, RMG

Katrina Carrasco

Contributing Editors
Andrew J. Brust, Ken Cox, John Cronan, Dan Fergus, John Gavilan,
Roger Jennings, Don Kiely, Martin Kulov, Jeff Levinson, Bill McCarthy,
John Charles Olamendy Turruellas, Keith Pleas, Peter Varhol, Bill Wagner
Art Staff
Creative Director Scott Shultz
Senior Art Director

Bruce Gardner

Graphic Designer

Erin Horlacher

Online/Digital Media
Editor, VisualStudio Becky Nagel
Magazine.com

Reader Likes the Switch

ve been a VSM reader for more than five years and a Visual Basic user for a few years longer
than that. I wanted to let you know that I especially enjoyed VSM s recent twin columns from
Kathleen Dollard [Ask Kathleen, What C# Devs Should Know About VB, December 2008]
and Bill Wagner [C# Corner, What VB Devs Should Know About C#, December 2008] on the
issues you face when switching between C# and VB.
Too often, developers and authors turn the differences between languages into arguments about why one language is better or worse than the other. These real-world articles told
you how the languages work and the issues you can expect to encounter if you switch between
the two. As a VB user, it was informative for me to read about the potential issues C# devs
might face when they work on projects with me. After reading Dollards article, I can understand better why my own team has faced some of the issues it has.
I like VSM immensely and have enjoyed reading it these several years, but I love what
you did with these articles and hope to see more like them in the future. Please keep up the
good work.
Rodney Bryant, received by e-mail

Office and Vista Both Exasperate


I agree completely with VSM Editor in Chief Patrick Meaders comments about Office 2007
and its detestable, exasperating ribbon with the pared down menu options [Editors Note,
Microsoft Opens Up (Even More), October 2008].
Office 2007 is a daily source of frustration for me at my job. I have had only a little experience with Vista, and I do find the new explorer easy to navigate. Nevertheless, silly omissions
like the Run command on the Start menu really bug me. Mr. Meader is not alone, and certainly
not a raving nutter. I suspect the vast majority of users have the same frustrations. As a seasoned
Windows user and software architect by trade, I have been consistently advising my colleagues
and relatives who are contemplating buying a new PC to get one with XP pre-installed and to
buy Office 2003. Maybe this is because theyre all going to ask me for help or even blame me
if they get stuck or lost in Vista or Word 2007.
Its sad that Microsoft, with its vast resources, has somehow dropped the ball on its core
products by trusting its younger generation of product managers without some serious
hands-on usage of their own dog food. I suspect that their executives would have found these
products just as frustrating as we do had they been using them without handholding or flashy
demos from their evangelists.
Norm Katz, San Diego, Calif.

VISUAL STUDIO MAGAZINE January 2009 VisualStudioMagazine.com

Executive Editor, New Media


Online News Editor
Associate Editor, Web
Web Producer

Michael Domingo
Kurt Mackie
Gladys Rama
Shane Lee

Director, Web Development

Rita Zurcher

President

Henry Allain

Vice President, Publishing


Director of Marketing
Online Marketing Director
Marketing Programs Manager

President &
Chief Executive Officer
Senior Vice President
& Chief Financial Officer
Executive Vice President

Matt N. Morollo
Michele Imgrund
Tracy S. Cook
Videssa Djucich

Neal Vitale
Richard Vitale
Michael J. Valenti

President, 1105 Events

Dick Blouin

Vice President, Finance


& Administration

Christopher M. Coates

Vice President, Audience


Marketing & Web Operations
Vice President, Information
Technology & Web Operations
Vice President,
Circulation
Chairman of the Board

Abraham M. Langer
Erik A. Lindgren
Carmel McDonagh

Jeffrey S. Klein

REACHING THE EDITORS


Editors can be reached via e-mail, fax, telephone, or mail.
A list of editors and contact information is available at
VisualStudioMagazine.com.
E-mail: E-mail is routed to individuals desktops. Please use the
following form: FirstnameinitialLastname@1105media.com.
Do not include a middle name or middle initials.
Telephone: The switchboard is open weekdays 8:30 a.m.
to 5:30 p.m. Pacific time. After 5:30 p.m. you will be directed
to individual extensions.
San Francisco Office 415-814-0950; Fax 415-814-0961
Irvine Office 949-265-1520; Fax 949-265-1528
Corporate Office 818-734-1520; Fax 818-734-1528
Visual Studio Magazine
The opinions expressed within the articles and other contents
herein do not necessarily express those of the publisher.

0109vsm_EdNote_07.v6

12/15/08

Editors

9:13 AM

Page 7

Note

VSMS
NEW BIG IDEA

BY PATRICK MEADER
editor in chief

PHOTO BY PAT JOHNSON STUDIOS

If youre a longtime programmer or merely someone who has followed


computers for a while, its possible youve seen the work of VSMs managing
editor before. Guy Wright has been working at computer-related magazines
since the personal computers relative infancy, stretching back
to 1983, when he began his publishing career with a two-year
stint as the technical editor and technical manager of RUN
Magazine, which served Commodores VIC-20 and Commodore 64 computers. Guy followed that gig up by serving as
the founding editor in chief at AmigaWorld Magazine. Once
upon a time, when the Apple 2 loomed large and the IBM PC
juggernaut had yet to be established, all of the cool kids I knew
had Amigas, and they were always telling me how much their
computer kicked the ass of every other computer.
Since his time at AmigaWorld Magazine, Guy has been
involved in several computing- and B2B-related titles, both
print- and Web-based. He has worn other hats, as well, working
with the development team on Commodores ill-fated CDTV
device, putting the first comic books on CD-ROM, and even
spending some time in purgatoryI believe he calls it heaven
using VB3 to create magazine archive CD-ROMs and demo
discs. To put it another way, Guy was programming in VB
before Id even heard of VB, and Ive been working at this magazine for going on 13 years. He notes that he wasnt a professional
programmera not-uncommon trait for many people who
initially picked up VBbut he appreciated the way it let smart
people who knew the business rules implement solutions for
their domains. One subject Guy and I have chatted about
extensively is the fact that its much harder to pick up VB.NET
and be productive in the same way that pre-.NET versions of
VB let you pick up the tool and be productive.
I felt it was a coup for the magazine to score someone
with Guys experience when we hired him. I still do. For the
past couple of years, Guy has played policeman on the staff,
making sure the process runs smoothly and the articles are
edited properly, while also nagging the editor in chief to turn
his articles in.
Youve been doing this long enough that your turnaround on these should be minutes, not days! he tells me.

Hes been writing editorials for years, he reminds me, and it


gets easier over time. Maybe, maybe not.
But in the time-honored tradition of bosses everywhere,
I sense opportunity here. If its so easy, let him do it. And so he
shall. Beginning this month, Guy will begin overseeing VSMs
new online blog: VSMs Big Issue. This blog will serve as a
jumping-off point for discussing the issues and technologies
of interest to Visual Studio developers, issues that wouldnt
normally fit neatly into the pages of VSM.
In contrast to many other blogs you can read, where the
writers climb up on their own particular soapboxes to share
their takes on the world, we want the VSM blog to be more of
an open forum where we pose questions on topics we think
are worth discussing and then encourage readers to share their
opinions. (OK, we might occasionally do a little soapboxing
when the mood strikes.)
We will be inviting many of our friends of the magazine
to stop by and chat about these same issues. Well include
short interviews with magazine luminaries and columnists,
movers and shakers at Microsoft, and key technology implementers at the third-party companies who drive much of the
innovation in Visual Studio.
We will be updating this blog frequently, so be sure to
stop by often to see whats new. Guy and I will both be posting
to the page, though Guy will be posting a bit more frequently
than I willhe does have to show me how its done, after all.
One of our main goals with this blog is to make it easier
to talk to the editors, to express what you like or dont like
about the magazine, and to give you a forum for telling us how
we at VSM can serve you better. We look forward to carrying
on this conversation online. VSM
Talk Back: What would you like to see us cover in the new
VSMs Big Issue blog? Tell me at vsmedit@1105media.com or
ednote@1105media.com.

VisualStudioMagazine.com January 2009 VISUAL STUDIO MAGAZINE

0109vsm_FirstLooks_08-09.v8

12/15/08

9:30 AM

Page 8

First
PRODUCT LISTINGS

Looks

REVIEWS

DXperience v2008 Volume 3; Isolator


and Racer; and TeamCity 4.0

Developer Express has released DXperience


v2008 volume 3, a suite of presentation components, reporting controls, IDE productivity
tools, and business application frameworks
for Visual Studio.
Along with numerous major enhancements
to its existing WinForms and WebForms
products and the eXpressApp Framework,
DXperience v2008 vol 3 offers a set of new
ASP.NET controls including a new Gauge Control, Filter Editor Control, Data-Bound Image
Control, and Loading Panel Control. The
upgraded suite also includes a new ASP.NET
Grid View, a new HTML Editor for SharePoint,
and a new WinForms Alert Window Control. All
Developer Express .NET technologies can be
purchased separately or as part of the
DXperience Subscription program.
For a complete list of the new controls,
features, and options that are available, visit
http://tinyurl.com/5wtqxr.
DXperience v2008 vol 3
Developer Express Inc.

The Typemock Isolator mocking framework


for .NET unit testing helps agile developers
with .NET unit testing and test-driven development. Isolator gives the agile developer tools
to isolate, stub, or mock any class in the system.
Features include the ability to mock the
.NET Framework; the ability to mock any .NET
language; the ability to mock any class, any
interface, any constructors, and all instances
of a type; the ability to mock a class while
keeping its original behavior; the ability to
dynamically choose at runtime whether to
keep the classes original behavior; and more.
Typemock Racer helps find possible deadlocks in production code by allowing developers
to write threaded tests to detect possible
problems. Racer provides a framework API
that can be used in Parallel Computing tests,
which allows the code to be tested for deadlocks in multithreaded code. When Racer
detects a deadlock, the events that lead to
itincluding thread names and locked
resourcesare displayed in Visual Studios
output window.

communication, and helps dev teams implement agile methodology and best practices.
TeamCity 4.0 provides scalability and
extensibility via its Java API, and integrates
with multiple IDEs, version control systems,
and build tools. With features such as fast
feedback on build progress, pre-tested commits, and server-side code analysis with over
600 code inspections, TeamCity shortens the
time needed for introducing new features
and fixes.
The latest version allows developers to
break down a single build procedure into several parts that can be run on different build
agents, in sequence or in parallel, using the
same set of sources. Other features include
the ability to redo any build from a particular
version-control revision; improved agentsauthentication mechanics, per-agent CPUbenchmarks, and agents overview statistics for
an entire project; new integrations, including
FxCop and a dedicated Rake runner, as well as
improvements for old ones such as MSTest;
and improved Eclipse integration.

Price: DXperience Enterprise Subscription prices


start at $1,299.99

Isolator and Racer

TeamCity 4.0

Web: www.devexpress.com

Typemock Ltd.

JetBrains

Phone: 702-262-0609

Price: Contact vendor for pricing

Price: Professional Edition (up to 20 users) is

Web: www.typemock.com

free; Enterprise Edition prices start at $1,999

Phone: +972-3-681-5177

Web: www.jetbrains.com

Isolator and Racer


Typemock has announced the release of its
next-generation unit-testing tools, Isolator
and Racer.
Typemock products support Microsoft
Visual Studio 2005, Visual Studio 2008, and
Visual Studio Team System 2008, and work
with any test framework.

Phone: 650-378-8571

TeamCity 4.0
JetBrains has announced the availability of its
continuous integration server and distributed
build management tool, TeamCity. TeamCity
automates routine procedures, aids the software development process, improves team

VISUAL STUDIO MAGAZINE January 2009 VisualStudioMagazine.com

Editors Note: Please send product information


to New Products Editor, c/o Visual Studio Magazine,
230 California St., San Francisco, CA 94111;
Phone: 415-814-0950, fax: 415-814-0961;
e-mail vsmedit@1105media.com.

0109vsm_FirstLooks_08-09.v8

12/15/08

PRODUCT LISTINGS

9:30 AM

Page 9

REVIEWS

Understand What Your App Does


If youre building a complex application or working as part of a
team, DevPartner Studio from
Compuware Corp. gives you the
ability to understand just how
goodor badyour application
really is. DevPartner Studio integrates with Visual Studio to give
you tools for analyzing application
performance, determining memory usage (down to the memory
used by individual objects), scanning for security problems, and
reviewing source code. Additonally,
DevPartner integrates well with DRILL DOWN ON APPS WITH PERFORMANCE ANALYSIS.
Visual Studio 2008 (Visual Studio
Compuwares DevPartner is a comprehensive set of testing and performance analysis
2005 is also supported), giving
tools. Depicted here is the live graph generated by the Studios Performance Analyzer
you access to all of its function- tool; it tracks CPU usage, disk transfers, and network access.
ality through a single toolbar.
If youre working in a team environment, a source code anacations as they run in Visual Studio and report on which methods
lyzer provides the most effective way to ensure that youand
are called, how often theyre executed, and where your applithe rest of the teamare following organization standards and
cation is spending its time. In addition to a detailed set of
best practices. Studio will do a static analysis of your source
post-performance reportswhich you can save to review
code, comparing it against a database of more than 600 rules.
laterStudio also includes a live runtime graph that tracks key
If you dont like the rules that come with Studio, you can cusperformance metrics as your application executes.
tomize the rules database, though youll need some knowledge
The only real limitation on Performance Analyzer is that it
of regular expressions if you want to add new rules. Additionrequires a custom runtime manager that doesnt support all
ally, source code analysis can be time consuming. Analyzing a
application types. For example, ASP.NET isnt supported. Provided
solution containing several thousand lines of code spread
you keep most of your codeand all of your performance-critical
across an ASP.NET application, a Windows Service, and several
codein middle-tier business objects, you can still use Studio to
class libraries took more than an hour on my computer.
analyze your code as long as youre willing to knock together
When runtime performance is critical, you need the ability
some WinForms applications to exercise your objects.
to identify the bottlenecks in an application and determine the
None of this comes cheap. In addition to the purchase
impact of any enhancements you make. Studios Performance
priceobviously aimed at larger shopsyoull need a computer
Analyzer and Performance Expert lets you monitor your appliwith sufficient resources to run the tools. When I tried using
Performance Analyzer in a virtual machine with only one
gigabyte of memory, DevPartner failed with a memory corAT A GLANCE
ruption problem.
DevPartner Studio Professional Edition 9.0
That said, I found DevPartner to be a well-behaved addiCompuware Corp.
tion to Visual Studio. When working on projects where I didnt
Web: www.compuware.com
want to use DevPartner, it stayed out of my way. Even when
Phone: 800-521-9353
DevPartner crashed due to memory restrictions, it left Visual
Price: $2,400
Quick Facts: Suite of tools for static and runtime analysis
Studio running and allowed me to continue working.
of applications for both Visual Studio 2005 and 2008.
If youre building an application thats too big to hold in your
Pros: Highly functional; well integrated into Visual
head at onceor if youre working in a team environment where
Studio; good product support.
adhering to standards is importantyou need DevPartner. VSM
Cons: Expensive; no direct support for ASP.NET

performance testing; 2GB of memory required.


Peter Vogel is a .NET consultant, author and instructor living in
Goderich, Ontario.

VisualStudioMagazine.com January 2009 VISUAL STUDIO MAGAZINE

0109vsm_F1WebApps_10-20.v8

F E AT U R E

12/15/08

9:26 AM

Page 10

MVC FRAMEWORK

Partition
Web Apps
Intelligently
Microsofts Model-View-Controller framework makes it
possible to implement a separation of concerns in ASP.NET
something that was difficult, if not impossible, previously.
Learn how to take advantage of MVC to design better
Web apps that separate their architectural elementsthe UI,
business logic, and codeproperly, as well as how to review
what you create with unit testing. BY STEVE MICHELOTTI

T
TECHNOLOGY TOOLBOX
VB.NET
C#
SQL Server
ASP.NET
XML
Other:
MVC Framework

10

perform unit tests of the presentation layer much


more easily. Ill show you how to take advantage
of both these features, first walking you through
how to build an MVC application from scratch
that features a true separation of concerns, and
then show you how to perform unit tests against
that same application.
In any object-oriented application, separation of concerns is one of the most important
aspects of a clean design. One of the fundamental
object-oriented concepts is that a class should
have a single job. The purpose of a class becomes
unclear when it contains too many members or
methods with different responsibilities. The

VISUAL STUDIO MAGAZINE January 2009 VisualStudioMagazine.com

Extract class refactoring (Fowler, 1999) is one


of the most fundamental refactorings that currently exist to address this situation. The
Extract class seeks to break apart the original
bloated classes into multiple classes, each with
its own distinct purpose.
Traditional ASP.NET Web forms applications have suffered from this age-old problem of a
lack of clean separation of concerns because the
code behind class often becomes a dumping
ground for both business logic and presentation
logic. The business logic might consist of getting
the appropriate business objects from the data
layer, executing business rules for validation, or

ILLUSTRATION BY RYAN ETTER

he new ASP.NET Model-View-Controller (MVC) framework


from Microsoft offers many new features for Web developers,but
two features stand out above the others.The first is that the MVC
now facilitates separation of concerns. The second is that the MVC
framework, unlike traditional Web forms, enables the developer to

0109vsm_F1WebApps_10-20.v8

12/15/08

9:26 AM

Page 11

MVC FRAMEWORK

business processing on those objects. The presentation logic might


consist of populating form controls,handling events for form controls,
redirecting users to other Web pages, and so on. All of this code can
cause the code behind classes to become bloated, with no clear job.
The MVC framework solves the separation of concerns problems of traditional Web forms by partitioning responsibilities
between Models, Views, and Controllers (see Figure 1). Note that
the Model is unaware of both the Controller and the View. The primary job of the Model is to contain the state thats passed to the
presentation layer. The View knows about the Model, but is blissfully unaware of the Controller. The sole purpose of the View is to
contain presentation logic. Finally, the responsibility of the Controller is to interact with the data layer and provide the appropriate
Models to the appropriate Views. The Controller is the key interaction point in the MVC framework.
Creating the App
Before drilling down into the specifics of the MVC implementation,
lets take a step back and consider the details of a sample application
that shows off this feature.The app is the Contact module of a personalinformation manager such as Outlook. It needs two screens. The first
screen shows the list of all my contacts (see Figure 2, p. 14). It lets you
delete any contact, as well as provide links to edit any contact and add
new contacts. If the user selects a contact or clicks on the link to add a
new contact, the application sends the user to the second screen,
where the user can add or edit the contact details (see Figure 3 , p. 14).
The MVC framework utilizes a rich routing engine provided
by the System.Web.Routing assembly. The routing engine enables
the ability to use URLs that dont map to a physical file. In the
context of MVC, the most common pattern for this is {controller}/{action}/{id}. For example, an MVC page that invokes
the ContactControllers Create() action method for a given ID
might look like this:

FIGURE 1 Model-View-Controller (MVC). The Model is unaware of


both the View and the Controller. The Controller is the heart of the
MVC framework orchestrating the flow. The View is aware of how to
present the Model.

{
public ViewResult Index();
public ViewResult Create(int? id);
public RedirectToRouteResult Delete(int id);
public ActionResult Save(Contact contact);
}

The ContactController interacts with the data layer to send and


receive the appropriate objects to the data repository. The data layer
contains a class called ContactManager that implements an interface called IContactManager:
public interface IContactManager
{
IEnumerable<GetContactListResult> GetContactList();
IEnumerable<State> GetStates();
Contact GetContact(int contactID);

http://somedomain/Contact/Create/21

ILLUSTRATION BY RYAN ETTER

void SaveContact(Contact contact);

The routing framework is extremely flexible, and the route mappings are set up in the Global.asax file.A full discussion of the routing
framework is beyond the scope of this article, but its important to
note that this basic pattern is used throughout this article.
To implement a Controller class, you must inherit from System.Web.Mvc.Controller. Any public method in your Controller
that returns a derivative of ActionResult is a valid Controller Action
method. Based on the first screen defined, you need Controller
actions to display a list of contacts,delete a contact,and send users to
the contact details screen to add or modify a contact.
A Controller action to save the contact is also required for the
contact details screen. This code provides the ContactController
class definition:
public class ContactController : Controller

void DeleteContact(int contactID);


}

A detailed discussion of the data layer is beyond the scope of this


article, but its important to note that the presentation layer works
on the IContactManager abstraction of the data layer. Although the
data layer is using LINQ to SQL, the presentation layer is blissfully
unaware of this fact and requires no reference to the
System.Data.Linq assembly. In fact, the LINQ data context class is
internal to the assembly, and the presentation layer cant access it.
The next step is to display the list of contacts when the user
navigates to the main contacts screen. The first action method to
accomplish this looks like this:
public ViewResult Index()

VisualStudioMagazine.com January 2009 VISUAL STUDIO MAGAZINE

11

Project5

12/11/08

4:26 PM

Page 1

UGLY, FIRE-BREATHING SCHEDULE?


GET A FLYING START.

Project5

12/11/08

4:33 PM

Page 2

Your challenge: over-deliver on features, while


beating deadlines. Defy it: start with Visual Studio
Tools for Microsoft Ofce for apps that win the day.
More tips and tools at defyallchallenges.com

0109vsm_F1WebApps_10-20.v8

12/15/08

9:26 AM

Page 14

MVC FRAMEWORK

ders itself as an HTML <span> tag when sent to


the browser. Alternately, the MVC framework
gives the developer complete control over the
rendered HTML with no bloated ViewState.
A link must be available for the user to
click on, so the user can go to the details page to
create or edit a contact. Specifically, you must
invoke the ContactControllers Create()
method. You can accomplish this with the
ActionLink method of the HtmlHelper:
FIGURE 2 Main Contact Screen. Shows a list of contacts that can be selected for editing
or deleting. The screen provides a link to add a new contact. Action Links are utilized on this
screen for invoking Controller action methods.

<%=Html.ActionLink<
ContactsController>(c=>
c.Create(contact.
ContactID), "Edit")%>

{
IEnumerable<GetContactResult> contactList =
contactManager.GetContactList();

Using a C# 3.0 lambda expression lets you specify the strongly


typed method for invoking the Create. Similarly, you can use a
Delete link in the same fashion:

ViewData.Model = contactList;
return View(Index);

<%=Html.ActionLink<ContactsController>(c=>

c.Delete(contact.ContactID), "Delete") %>

This method is quite simple, but there are some important things
happening. First, this code is getting the list of contacts from the
data layer. Next, it sets that collection as the Model of the Controllers ViewData. This ViewData is passed to the View. Finally,
the returned View is called Index.The MVC framework searches
for a physical file called Index.aspx or Index.ascx in the folder that
corresponds to the Controller name or the Shared folder. If you
omit the Index name parameter to the View method, it looks automatically for a View that has the same name as the current action
method name (Index, in this case). However, you should avoid
doing this because you want your code to be as explicit and testable
as possible.
Now you want to implement the view. Begin by inheriting
from ViewPage:

Once the user selects a specific contact, they must be sent to the contact details screen so that modifications can be made. There are two
pieces of data that the screen requires. First, the appropriate contact
object needs to be available. Second, the screen must provide a dropdown list of U.S. states that the user can pick from. How do both
pieces of information get sent to the View as a single Model? You
accomplish this by creating a simple wrapper class called ContactViewData that acts as your Model. Its a common misconception
to think of the business objects as the Model in the ASP.NET MVC
framework. This is sometimes true, but its not always accurate. The
Model is actually whatever abstraction is needed for the presentation
layer to accomplish its objective properly. This is quite often more
than business objects. This code describes the complete implementation of the ContactViewData class:

public partial class Index :


ViewPage<IEnumerable<Contact>>

Note that the Index View page specifies a generic


type constraint. This lets you access the Model in
a strongly typed manner (see the complete
implementation of the Index View page in Listing
1, p. 15). The first aspect that often throws traditional ASP.NET developers is that there are no
server controls in the markup. This is an intentional part of the MVC framework. In the
MVC framework, there are no ViewState or
runat=server attributes. In traditional
ASP.NET applications, the server controls provide abstractions over HTML elements. For
example, an ASP.NET Label server control ren-

14

FIGURE 3 Contact Details Screen. Detail screen where contacts can be edited and then
persisted. Validation messages are present for each control based on business object
validation. The results are posted to the Controllers Save action method.

VISUAL STUDIO MAGAZINE January 2009 VisualStudioMagazine.com

0109vsm_F1WebApps_10-20.v8

12/15/08

9:27 AM

Page 15

MVC FRAMEWORK

plete code for the ContactBinder in the code download for this
article (see Go Online, p. 18, for download details).
In this scenario, the first job of the Save method is to validate the
object by invoking the validation rules defined in the business layer. If
the object is valid, you send it to the data layer for persistence and
then redirect the user back to the main screen. Otherwise, you need
to show the user the form again, so they can fix the invalid data.
Best practices dictate that validation of business objects
should occur in the business layer. Too often, developers implement the validation only in the presentation layer, or worse, duplicate
the validation of their business objects in the presentation layer. A
great framework to validate business objects declaratively is the
Microsoft Enterprise Library Validation Application Block (VAB).
The VAB allows you to validate your business objects on the objects
themselves. Another great aspect of MVC is that it provides a flexible framework to hook the UI validations into already existing
object validations. The VAB is simply one of the many frameworks

public class ContactViewData


{
public Contact Contact { get; set; }
public IEnumerable<State> StateList { get; set; }
public ContactViewData(Contact contact,
IEnumerable<State> stateList)
{
this.Contact = contact;
this.StateList = stateList;
}
}

Using the Create action method isnt complicated if you take


advantage of the ContactViewData:
[AcceptVerbs(HttpVerbs.Get)]
public ViewResult Create(int? id)
{
if (id.HasValue)
{
Contact contact =
contactManager.GetContact(id.Value);
IEnumerable<State> stateList =
contactManager.GetStates();
this.ViewData.Model =
new ContactViewData(contact, stateList);
return View(Create);
}
else
{
return View(Create,
new ContactViewData(new Contact(),
contactManager.GetStates()));
}
}

Again, the markup in the View is simple and straightforward. Additionally, theres no code required in the code
behind. (See Listing 2, p. 18, for the complete code for
the Create.aspx page.)
One thing of note in Listing 2 is the ContactControllers Save action method. There are various
ways to save form data in the MVC framework. One
of the most elegant methods is to utilize Model
Binders. Using Model Binders, which implement the
System.Web.Mvc.IModelBinder interface, means the
act of creating an object from form parameters can be
encapsulated in the binders and abstracted away
from the Controller actions methods. This allows the
Controller action methods to save objects strongly
typed for that method. That is, the resulting object
from the binder will be passed in to the appropriate
Controller method for saving. You can find the com-

C#

CREATE THE CONTACT LIST SCREEN

<%@ Page Title="Contacts" Language="C#"


MasterPageFile="~/Views/Shared/Site.Master"
AutoEventWireup="true" CodeBehind="Index.aspx.cs"
Inherits="Pim.Web.Views.Contacts.Index" %>
<%@ Import Namespace="Pim.Web" %>
<%@ Import Namespace="Pim.Web.Controllers" %>
<%@ Import Namespace="Pim.BusinessLayer" %>
<asp:Content ID="Content2"
ContentPlaceHolderID="mainContent" runat="server">
<%=Html.ActionLink<ContactsController>(c
=> c.Create(null), "Add New Contact") %>
<table cellspacing="0" cellpadding="4" border="1">
<tr>
<th scope="col">First Name</th>
<th scope="col">Last Name</th>
<th scope="col">Email</th>
<th scope="col">&nbsp;</th>
</tr>
<%foreach(GetContactListResult contact in
this.ViewData.Model) { %>
<tr>
<td><%=contact.FirstName %></td>
<td><%=contact.LastName %></td>
<td><%=contact.Email%>&nbsp;</td>
<td>
<%=Html.ActionLink<ContactsController>(c =>
c.Create(contact.ContactID), "Edit")%>
<%=Html.ActionLink<ContactsController>(c =>
c.Delete(contact.ContactID), "Delete") %>
</td>
</tr>
<% } %>
</table>
</asp:Content>

LISTING 1 This is the complete mark up for the contact list screen.

VisualStudioMagazine.com January 2009 VISUAL STUDIO MAGAZINE

15

Project7

12/15/08

1:21 PM

Page 1

NEW Studio for Silverlight

NEW Studio for ASP.NET

NOW INCLUDES 30+ SILVERLIGHT CONTROLS

COMPLETELY RE-ENGINEERED

Display rich, interactive geographical information


using C1Maps

Fully exploits the AJAX Framework

10x faster performance

Rich client-side object model

Cross-browser support

Create full-featured, animated data visuals with


C1Chart

3x smaller footprint

Built-in visual styles and animation effects

Develop complex dashboards easily with


C1LinearGauge and C1RadialGauge

Coming Soon Studio for iPhone


FIRST SUITE OF IPHONE-ENHANCED WEB CONTROLS

Cross-browser support
Incorporate powerful, data-bound grids to your
applications with C1DataGrid

The first and only ASP.NET component suite that enables you to build iPhone
Web apps that look and feel like the native UI
Includes design elements for menus, UI buttons, content controls, sliders, and more

Grids Char ting Repor ting Scheduling Menus and Toolbars Ribbon Data Input Editors PDF

ComponentOne Sales

1.800.858.2739 or 1.412.681.4343

1987-2009 ComponentOne. All rights reserved.


iPhone is a trademark of Apple Inc. All other product
and brand names are trademarks and/or registered
trademarks of their respective holders.

ved.
duct
ered
ders.

Project7

12/15/08

1:21 PM

Page 2

It's here and supercharged for the Web: Studio Enterprise 2008 v3.
This new release delivers exactly what you need to produce nextgeneration UIs for the Web.

WinForms WPF ASP.NET Silverlight iPhone Mobile ActiveX

DOWNLOAD YOUR FREE TRIAL @

componentone.com/amazingweb

0109vsm_F1WebApps_10-20.v8

12/15/08

9:27 AM

Page 18

MVC FRAMEWORK

C#

CREATE THE EDIT CONTACTS VIEW

<%@ Page Title="" Language="C#"


MasterPageFile="~/Views/Shared/Site.Master"
AutoEventWireup="true"
CodeBehind="Create.aspx.cs"
Inherits="Pim.Web.Views.Contacts.Edit" %>
<%@ Import Namespace="Pim.Web" %>
<%@ Import Namespace="Pim.Web.Controllers" %>
<%@ Import Namespace="Pim.Mvc.Web.Models.Home" %>
<asp:Content ID="Content2"
ContentPlaceHolderID="mainContent" runat="server">
<form id="mainForm" name="mainForm"
action="<%=Url.Action("Create") %>"
method="post">
<table><tr><td>
<table>
<tr>
<td>First Name:</td>
<td>
<%=Html.TextBox("Contact.FirstName")%>
<%=Html.ValidationMessage("Contact.
FirstName") %>
</td>
</tr>
<tr>
<td>Last Name:</td>
<td>
<%=Html.TextBox("Contact.LastName") %>
<%=Html.ValidationMessage(
"Contact.LastName")%>
</td>
</tr>
<tr>
<td>Email:</td>
<td>
<%=Html.TextBox("Contact.Email")%>
<%=Html.ValidationMessage(
"Contact.Email")%>
</td>
</tr>
<tr>
<td>Company:</td>
<td>
<%=Html.TextBox("Contact.Company")%>
<%=Html.ValidationMessage(
"Contact.Company")%>
</td>
</tr>
<tr>
<td>Title:</td>
<td>
<%=Html.TextBox("Contact.Title")%>
<%=Html.ValidationMessage(
"Contact.Title")%>
</td>
</tr>
</table>
</td>

<td valign="top">
<table>
<tr>
<td>Street Address:</td>
<td>
<%=Html.TextBox(
"Contact.Address.StreetAddress")%>
<%=Html.ValidationMessage(
"Contact.Address.StreetAddress")%>
</td>
</tr>
<tr>
<td>City:</td>
<td>
<%=Html.TextBox("Contact.Address.City")%>
<%=Html.ValidationMessage(
"Contact.Address.City")%>
</td>
</tr>
<tr>
<td>State:</td>
<td>
<%=Html.DropDownList("(Select)",
"Contact.Address.StateID", new
SelectList(this.ViewData.Model.StateList,
"StateID", "StateDesc",
ViewData.Model.Contact.Address.StateID)) %>
<%=Html.ValidationMessage("Contact.Address.
StateID")%>
</td>
</tr>
<tr>
<td>Zip:</td>
<td>
<%=Html.TextBox("Contact.Address.Zip")%>
<%=Html.ValidationMessage("Contact.Address.Zip")%>
</td>
</tr>
</table>
</td>
</tr></table>

<a href="javascript:document.mainForm.
submit();">Save</a>
<%=Html.ActionLink<ContactsController>(c
=> c.Index(), "Cancel") %>
<%=Html.Hidden("Contact.ContactID") %>
<%=Html.Hidden("Contact.LastUpdated",
ViewData.Model.Contact.LastUpdated.ToString(
"MM/dd/yyyy HH:mm:ss.fff"))%>
</form>
</asp:Content>

LISTING 2 The code for the edit contacts view is simple and straightforward.

18

VISUAL STUDIO MAGAZINE January 2009 VisualStudioMagazine.com

0109vsm_F1WebApps_10-20.v8

12/15/08

9:27 AM

Page 19

MVC FRAMEWORK

that can be used to integrate with MVC validation; validating with


the VAB and redisplaying the view with all appropriate messages is
straightforward (see Listing 3).

ContactsController controller = new


ContactsController(contactManager.Object);
ViewResult result = controller.Index();
// verify

IEnumerable< GetContactListResult >


Implement Unit Testing
viewDataModel = result.ViewData.Model
One of the most problematic areas of traditional ASP.NET Web
as IEnumerable<GetContactListResult>;
forms is their lack of testability. Among these issues is a lack of
Assert.IsNotNull(viewDataModel,
HttpContext when a Web server isnt present. Fortunately, the
"ViewData should not be null.");
MVC framework provides an HttpContextBase class that lends
Assert.AreEqual(4, viewDataModel.Count(),
itself well to mocking in the context of unit-testing frameworks.
"View data must have items.");
Additionally, quality unit tests ensure that only small units of
contactManager.VerifyAll();
logic are tested in each test. However, the lack of separation of
}
concerns in traditional ASP.NET Web forms makes this quite difficult. The MVC architecture is based on a pluggable model, so its
The Controller contains a reference to the IContactManager intereasy to utilize Dependency Injection to facilitate more granular
face rather than the concrete ContactManager itself, so you can use
unit tests.
dependency injection to pass in a mock contact manager.
Proper Test-Driven Development (TDD) principles state that
Taking a slightly more complex example, a unit test is required
unit tests should be written before actual application code. Ive vioto test the Save functionality.Specifically,if a valid object is passed into
lated that principle in this article solely for the purpose of introducing
the Save method,the unit test must verify that the data persistence was
the MVC framework. The beauty of MVC is that it allows unit tests to
invoked and the user was redirected back to the main screen. Simibe written first in accordance with true TDD best practices.
larly, a separate unit test must verify that, if an invalid object is passed
This article uses MSTest for unit testing, but you could use
in, the validation messages are added and the screen is redisplayed.
any unit-testing framework, including NUnit, xUnit, or MBUnit.
This code shows you how to test for saving a valid contact:
I highly recommend you select the unit-testing framework that
you and your development team are most comfortable with.
VALIDATE OBJECTS WITH VAB
C#
This article also uses Moq for a mocking framework, but again, you could use any mocking framework,
[AcceptVerbs(HttpVerb.Post)]
including Rhyno Mocks or TypeMock. MVC puts no
[ActionName(Actions.Create)]
public ActionResult Save(Contact contact)
constraints on the personal preference of a developer
{
with respect to using their preferred tools.
ValidationResults validationResults = Validation.
The first unit test you create is for the main
Validate(contact);
screen. Specifically, the unit test must verify the logic
if (validationResults.IsValid)
{
in the ContractControllers Index method. The job of
contactManager.SaveContact(contact);
the Index method is to retrieve the collection from the
return RedirectToAction(Actions.Index);
data layer and then pass that collection to the Index
}
else
view. However, its important that only the code in the
{
Controller is tested and not the code in the data layer.
foreach (ValidationResult validationResult
Therefore, the data layer will be mocked so that only
in validationResults)
the code in the Controller is being tested. Heres the
{
string mvcKey = GetMvcKey(validationResult);
complete unit test for the Index method:
this.ViewData.ModelState.AddModelError(
mvcKey, validationResult.Message);

[TestMethod]

}
IEnumerable<State> stateList = contactManager.
GetStates();
this.ViewData.Model = new
ContactViewData(contact, stateList);
return View(Actions.Create);

public void ContactController_Index_Test()


{
// set up
var contactManager =
new Mock<IContactManager>();

IEnumerable<GetContactListResult>
contactList = TestUtil.
CreateContactList();
contactManager.Expect(c =>
c.GetContactList()).Returns(contactList);

LISTING 3 Microsofts Microsoft Enterprise Library Validation Application Block (VAB)


gives you a great way to validate business objects. This code shows you how to use
the VBA to redisplay the page with error messages.

// execute

VisualStudioMagazine.com January 2009 VISUAL STUDIO MAGAZINE

19

0109vsm_F1WebApps_10-20.v8

12/15/08

9:27 AM

Page 20

Instantly Search
Terabytes of Text

MVC FRAMEWORK

N dozens of indexed,

unindexed,
fielded data and
full-text search
options (including
Unicode support
for hundreds
of international
languages)

[TestMethod]
public void ContractController_Save_Valid_Test()
{
// set up
Contact contact = TestUtil.CreateValidContact();
var contactManager = new Mock<IContactManager>();
var mockedHttpContext =
MoqMvcMockHelpers.FakeHttpContext();
ContactsController controller = new
ContactsController(contactManager.Object);

N file parsers /

converters for
hit-highlighted
display of all
popular file
types
N Spider supports

static and
dynamic web
data; highlights
hits while
displaying links,
formatting and
images intact

controller.ControllerContext = new
ControllerContext(mockedHttpContext,
new RouteData(), controller);
contactManager.Expect(c =>
c.SaveContact(contact));

h Spider
Desktop wit
h Spider
Network wit
CD/DVDs
Publish for
pider
Web with S
Win & .NET
Engine for
Linux
Engine for

// execute
var result = controller.Save(contact) as RedirectToRouteResult
// verify
Assert.AreEqual("Index", result.Values["action"],

New
64-bit

N API supports .NET, C++, Java, databases, etc.

New .NET Spider API

The Smart Choice for Text Retrieval


since 1991
N Bottom line: dtSearch manages a terabyte of text

in a single index and returns results in less than a


second InfoWorld
N For combing through large amounts of data,

dtSearch leads the market Network Computing

"ViewName is not correct.");


contactManager.VerifyAll();
}

You can find the complete unit-testing implementation for the


entire application in the accompanying code download for this
article (see Go Online for details). One nice aspect of the MVC
frameworks architecture is that its completely pluggable, with separation of concerns implemented elegantly. It was designed with
testability in mind throughout. This in turn lets you to write higherquality code. VSM
Steve Michelotti, MCSD, MCPD, MCT, is a principal software
engineer at Applied Information Sciences. You can reach him at
steve.michelotti@gmail.com.
ADDITIONAL RESOURCES:
Stephen Walther on ASP.NET MVC: http://tinyurl.com/57d9ba
Scott Guthries Blog: http://tinyurl.com/5d6a6f
ASP.NET MVC: www.asp.net/mvc

N dtSearch covers all data sources ... powerful

Web-based engines eWEEK


N dtSearch searches at blazing speeds Computer

Reseller News Test Center


See www.dtsearch.com for hundreds more reviews,
and hundreds of developer case studies

Contact dtSearch for


fully-functional evaluations

1-800-IT-FINDS www.dtsearch.com

MVC on CodePlex: http://tinyurl.com/6ky4vp


Scott Hanselmans Blog: http://tinyurl.com/6gk2qh
ASP.NET MVC Session at Mix08, TDD and MvcMockHelpers. Blog post by
Scott Hanselman: http://tinyurl.com/39qpnp
GO ONLINE
Use this Locator+ code at VisualStudioMagazine.com to go directly to these
related resources.
READ & DOWNLOAD
VS0901SM Read this article online and download a sample MVC application
that shows separation of concerns implemented properly.

0109vsm_C#Corner_21-23.v8

12/15/08

C# CORNER

9:09 AM

Page 21

TA R G E T M U LT I P L E F R A M E W O R K S

Target Multiple
.NET Frameworks
Many developers have
the misconception that
targeting older versions of
the Framework means you
cant use any of the new C#
language features. Its time
to dispel that myth.
BY BILL WAGNER

argeting multiple .NET platforms is a subject that confuses many developers.For example,
many developers mistakenly believe that if you target older versions of the platform,
you must forego all the new language features. Yes, you must accept some limitations,
but you dont have to give up all the new language features you like. Targeting multiple
versions of the Framework is a great way to ensure that you and your peer developers
can use Visual Studio 2008 even when one of your target environments must support an older version of
the Framework. More than that, it doesnt stop you from using the features in the C# 3.0 language. On
the downside, there are some nuances that can crop up when using the newer language features if youre
targeting an older version of the Framework. Ill walk you through some of these nuances, explaining
what capabilities are in bounds, which require care, and which ones you cant use when you have to target
an older version of the Framework.
Multitargeting is a project-level feature. To select your target version of the Framework, right click
on the project node and select properties. You can pick any of the 2.0, 3.0, or 3.5 versions of the Framework. In this article, Im concentrating on the differences between various language features and how
you can make use of the newer language features even though youre targeting an older version of the
Framework. Obviously, if youre targeting the 2.0 Framework, none of the 3.0 librariesWindows
Presentation Foundation (WPF),Windows Communication Foundation (WCF), or Windows Workflow
Foundation (WF)are available to use. In general, other libraries that rely on .NET 2.0 and 3.0 share
the same limitations. (Space considerations prevent me from exhaustively discussing the differences
between the 2.0 and 3.0 Frameworks.)

TECHNOLOGY TOOLBOX

ILLUSTRATION BY BRUCE GARDNER

VB.NET
C#
SQL Server
ASP.NET
XML

VISUAL STUDIO MAGAZINE January 2009 VisualStudioMagazine.com

21

0109vsm_C#Corner_21-23.v8

12/15/08

9:09 AM

Page 22

C # C O R N E R TA R G E T M U LT I P L E F R A M E W O R K S

The most important consideration when multitargeting is to


use straight language features versus the library features. Of course,
there are some subtleties. You can use any of the language features
in C# 3.0, provided they dont access the 3.5 libraries. This is also
true when using C# 3.0 when youre targeting the 2.0 Framework:

public IEnumerable<TResult>
Select<TResult>(Func<TResult> selector)
{
foreach (var peep in storage)
yield return selector(peep);
}

var foo = 27;

// elsewhere:
public delegate TResult Func<TResult>(Person id);

Thats really no big deal, but it might lead you to try more. Object and
Collection initializers work even when you target the 2.0 Framework:
List<int> sample = new List<int>
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

You can even use lambda expressions:


sample.RemoveAll(n => n % 3 == 0);

Lambda expressions mean you can apply those techniques to your


own methods. You can create any of your own methods that take
delegates, knowing that clients can take advantage of the easier
lambda expression syntax to use your types.
You can create and use Anonymous types,though without LINQ
support, theres less you can do with them than you might think.
Obviously, you cant use LINQ libraries. LINQ to SQL, LINQ to
XML, and Entity Framework are all part of the .NET 3.5 library, so
those are off limits if youve targeted an older version of the Framework.
Extension methods are decorated with the System.CompilerServices.Extension attribute, which is declared in System.Core.dll.
Thats not available in earlier versions of the .NET Framework, so
you cant create extension methods when youre targeting an earlier
version of the Framework.
I mentioned there are some nuances that you need to keep in
mind when you target earlier versions of the Framework. Take a
moment and consider what would happen if you tried to execute
this code snippet:
People folks = new People() {

The select member method in People satisfies the query-expression


pattern for the case where the sequence is of type People so the
range variable must be of type Person. I had to define a new version
of Func, because Func<TResult> is not available in the .NET
2.0 Framework.
I intentionally chose a simple example because implementing
the entire query-expression pattern is a large exercise, and Im not
advocating it if you still have to support the 2.0 Framework. This
amount of work would dwarf the amount of work necessary to
rollout the 3.5 Framework in almost any customer base. However,
its important to understand that the query expression syntax is
shorthand for method calls.
According to the C# spec, the Select method should have a signature of the form:
public C<T> Select<U>(Func<T,U> selector)

Thats a mouthful of type parameters, so lets start with a concrete


example. The select statement above looks for a method that has
the form:
public IEnumerable<string> Select(
Func<string, Person> selector);

The Select method in People does match that pattern. Therefore,


the select compiles. The compiler translates it into this method call,
which makes the method call a little easier to understand:
var foo = folks.Select(person => person.FirstName);

new Person {FirstName = "Joe", LastName = "Smith"},


new Person {FirstName = "Bob", LastName = "Jones"},
};
var foo = from f in folks
select f.FirstName;

What would happen depends on what methods are defined in the


People class. The select keywordin fact, the entire query-pattern
syntaxmaps to specific methods. The compiler then translates
those keywords into method calls. If a candidate method is in scope,
the query will compile, even if youre targeting the 2.0 Framework.
This is where it gets a bit complicated so lets take a close look
at another example. The select clause in the snippet just described
looks for a Select method in scope. The People class contains a possible Select method:

22

VISUAL STUDIO MAGAZINE January 2009 VisualStudioMagazine.com

What you want to remember from this discussion is that the query
expressions are nothing more than shorthand for method calls.
Where those method calls are present, the query syntax will work
fine when targeting the .NET 2.0 Framework. However, to write
code like this in a general way is to create far more work for yourself
than would normally be justified.
Changes in Behavior
Your development box must have .NET 3.5 if youre running
Visual Studio 2008, as well as the C# 3.0 compiler. This combination can lull you into a false sense of security. Your testing on your
development machine will not uncover any incompatibilities
between the 2.0 and 3.5 Frameworks. The Visual Studio IDE will
help you with almost all of those issues, because the IDE will tell

0109vsm_C#Corner_21-23.v8

12/15/08

9:09 AM

Page 23

C # C O R N E R TA R G E T M U LT I P L E F R A M E W O R K S

you if youre trying to include any assemblies that were added in a


READ & DOWNLOAD
newer version of the .NET Framework. Microsoft tried hard to
VS0901CS Read this article online and download the sample code, which
ensure that there were no breaking changes, but a few things still
illustrates many of the concepts discussed in this article.
snuck in.
You can find one example of this particular issue in the INotifyPropertyChanging
interface. In .NET 3.5, the System.ComponentModel namespace added the INotifyPropertyChanging interface. This interface
is new and corresponds to the INotifyPropNew 7.0
ertyChanged event. The problemfor a
ge
multitargeting applicationis that this event
tIma se
o
D
will compile fine when targeting the 2.0
a
Rele
Framework. Its in an existing namespace and
an existing assembly. In fact, it will run on
your development machine, but it will fail
when you move to a machine where only the
2.0 Framework is available. Fortunately,
thats the only example of this kind of problem
that Ive encountered so far, but its the kind
of problem you will only find by testing on a
machine where the target frameworkand
only the target frameworkis installed.
Ive always viewed multitargeting as a
short-term solution to enable developers to
move forward, while still supporting customers that arent ready to move to the latest
distributions. If you view it in this light, you
The .NExT Step In Document
can safely move development staff to the latest
version of Visual Studio and take advantage of
and Photo Imaging
some of the newer language features while still
supporting those customers that must run on
older legacy systems. The goal of such a move
should be to get customers and developers
looking at the higher productivity available in
DotImage 7.0More Powerful,
the newer versions of the .NET Framework
with Zero-Footprint Imaging, and
and to ultimately drive toward targeting the
3 Months of Free Gold Support.
newest Framework. VSM
Bill Wagner brings more than 20 years experience to his roles as co-founder of SRT Solutions
and Microsoft Michigan regional director. Bill
is an internationally recognized author on the
C# language evolution, Smart Clients, and
enterprise design. Bill has written two books,
Effective C# (Addison-Wesley Professional,
2004) and More Effective C# (AddisonWesley Professional,2008).He also annotated the
3rd edition of the C# Language Specification.
GO ONLINE

New features to our already powerful imaging toolkit include PDF/A


support, AJAX Vector Annotations including FreeHand, WPF annotations, and more. Use templates in our AJAX Wizard to create zerofootprint web applications in C# and VB.NETTake document and
photographic imaging to the .NExT step.
Visit Atalasoft.com for web demos, video tutorials, and a free trial.

Atalasoft, Your .NET Imaging Partner


Call us toll free at 866-568-0129

www.atalasoft.com

Use this Locator+ code at VisualStudioMagazine.com


to go directly to these related resources.

VISUAL STUDIO MAGAZINE January 2009 VisualStudioMagazine.com

23

0109vsm_AskKat.24-27.v6

Ask

12/15/08

9:06 AM

Page 24

Kathleen

WINDOWS WORKFLOW
CHANGES DIRECTION

BY KATHLEEN DOLLARD

Learn how Windows Workflow Foundation (WF) 4.0 changes everything


you thought you knew about workflow.Also, learn why using string
primary keys is a bad idea; find out where to get a data grid for Windows
Presentation Foundation (WPF); overcome the annoying issue of files not
loading at runtime; and copy files into the executable directory.
Technologies mentioned in this article include Visual
Basic, Windows Workflow Foundation (WF); Windows
Presentation Foundation (WPF), reflection, and C#.

Ive been hearing that Windows Workflow 4.0 was


announced at the Professional Developers Conference
(PDC), and that it changes everything. Is this true, and if
so, what does this mean to those of us that have existing workflows?

Windows Workflow Foundation (WF) 4.0 was


unveiled at PDC and is available now as part of the
current .NET 4.0 Community Technology Preview
(CTP). As such, details arent complete, so remember that my
answer is based on these preliminary announcements.
WF 4.0 represents a bottom-up rewrite with entirely new
thinking. The gains are enormous: custom activities take center
stage, and authoring them is much simpler; workflows are
entirely declarative; and there are three workflow flow styles
that you can combine seamlessly. Its possible that you could
see a 10-fold improvement in the time required to create and
debug workflows, in addition to 10- to 100-fold runtime performance improvements. Youd also have better control over
persistence. Additionally, theres support for partial trust, a
completely rewritten designer, and a better debugging experience. One of the most important improvements is in the
re-hosting experience. This allows you to create activities and
to allow power usersand othersto build or modify workflows with the constrained set of activities youve created. Yes,
this is possible in WF 3.0/3.5, but the necessary code is challenging, not to mention exceedingly difficult to debug.
The improvements to WF 4.0 come at a cost. Microsoft
developed two inter-op strategies to help you over this hurdle.

24

VISUAL STUDIO MAGAZINE January 2009 VisualStudioMagazine.com

WF 3.0/3.5 will remain part of the framework and will run


side by side with WF 4.0. This lets you manage the transition at
a time that fits your organizations broader goals. The other
inter-op strategy is an inter-op activity that allows you to use
WF 3.0/3.5 activities in a WF 4.0 workflow. Workflows are a
specialization of activities, so youll probably be able to run
entire 3.0/3.5 workflows inside WF 4.0 workflows.
While side-by-side running is essential for timing your
conversion, youre likely to skip the inter-op activity in favor of
creating consistent WF 4.0 workflows. Outside of the inter-op
activity, your workflows, activities, and rules arent going to
transition to WF 4.0 unless Microsoft creates a transition tool.
A transition tool that can fully transform your workflows and
activities seems unlikely. One of the prime benefits of WF 4.0
is a better strategy for breaking workflows into discrete functional units. Transitioning workflows directly wont improve
their design, but rewriting them will. A quick list of significant
features Windows Workflow 4.0 doesnt have includes Code
Activity, Data Exchange Service (DES) events, DES method
calls, a code model (its declarative only), rules as you know
them now, an Initialize event, and dependency properties.
If youre contemplating using WF and can wait until .NET
4.0 is released, I suggest waiting. This is particularly true if you
have an existing state-based solution you can nurse along for
another year or two.If you do write new workflows in the interim,
Ive collected a set of preliminary guidelines for preparing
workflows to transition (see Write New Workflows with .NET
4.0 in Mind,p. 26). If youve worked with WF 3.0 or 3.5, this is a
jaw-dropping list; many of the primary elements you might
think of as WF disappear in the transition to WF 4.0.
Another important aspect of your transition strategy
concerns long-running workflows. The simplest transition

0109vsm_AskKat.24-27.v6

12/15/08

9:06 AM

Page 25

A S K K AT H L E E N W I N D O W S W O R K F LO W 4 . 0

strategy is to allow all workflows to complete in 3.0/3.5 but to begin


restricts usage of Social Security numbers, and many applications
new workflows in 4.0. If you have aggregate information or if you
cannot legally require submission of a valid Social Security number.
have long-running workflows,this might not be an acceptable strategy.
Strings present performance issues because of the inefficiency
In this case, you need a strategy to bring down existing workflows
of string comparisons and clustering issues. Comparing two
and bring them back up in WF 4.0. If youre writing workflows today
strings is significantly slower than comparing two integers. Within
and believe youll need this strategy, consider building in events to
a database index, there are a large number of comparisons, and priinitiate the process. If you have existing workflows, you might need to alter them later, but
its not yet clear whether Microsoft will provide
a tool to help automate the 3.0/3.5 workflowmodification strategy.
If you have deployed workflows, its
LEADTOOLS v.16 .NET, WPF, C API, C++ Class Lib, COM & more!
almost certain you invested most of your time
'HYHORS\RXUDSSOLFDWLRQZLWKWKHVDPHUREXVWLPDJLQJWHFKQRORJLHVXVHGE\Microsoft, HP, Sony,
in understanding and engineering the busiCanon, Kodak, GE, Siemens, WKH US Air Force DQGVeterans Affairs Hospitals.
ness process in order to know what workflows
/($'722/6SURYLGHVGHYHORSHUVHDV\DFFHVVWRGHFDGHVRIH[SHUWLVHLQFRORUJUD\VFDOHGRFXPHQW
PHGLFDOYHFWRUDQGPXOWLPHGLDLPDJLQJGHYHORSPHQW,QVWDOO/($'722/6WRHOLPLQDWHPRQWKVRI
to write,and in working through the dozens of
UHVHDUFKDQGSURJUDPPLQJWLPHZKLOHPDLQWDLQLQJKLJKOHYHOVRITXDOLW\SHUIRUPDQFHDQGIXQFWLRQDOLW\
quirks and challenges of 3.0/3.5 workflows.
IXOOIHDWXUHGZHEEDVHGPHGLFDOLPDJHGHOLYHU\
Image Formats: $OO LQGXVWU\ VWDQGDUGV
Creating the workflows themselves probably
DQGYLHZHUDSSOLFDWLRQV
LQFOXGLQJ 7,)) (;,) 3') -3(*-3(* ',&20
Medical Image Viewer: +LJK OHYHO GLVSOD\
3&/':*DQGKXQGUHGVPRUH
took a smaller chunk of time. Certainly, youll
FRQWURO ZLWK EXLOWLQ WRROV IRU LPDJH PDUNXS
Image Compression: )URP VWDQGDUG -%,*
put effort into transitioning your current
ZLQGRZ OHYHO PHDVXUHPHQW]RRPSDQFLQH
-%,* $%,& -3(* DQG &&,77 ** WR /($'V
DQG/87PDQLSXODWLRQ
VSHFLDOL]HG$%&&03DQG&0:FRPSUHVVLRQ
workflows and redesigning aspects of them to
DICOM: )XOO VXSSRUW IRU DOO ,2' FODVVHV DQG
Display Controls: 6FUROO ]RRP SDQ PDJQLI\
PRGDOLWLHVGHQHGLQWKH',&20VWDQGDUG
JODVVEULJKWQHVVFRQWUDVWJDPPDZLQGRZOHYHO
take advantage of new features. But your busi LQFOXGLQJ(QFDSVXODWHG3')&'$ DQG 5DZ
Image Processing:  OWHUV WUDQVIRUPV DQG
ness engineering work will survive and the
'DWD 
FRORU FRQYHUVLRQ IXQFWLRQV ZLWK H[WHQGHG JUD\VFDOH
DICOM Communications: )XOO VXSSRUW IRU
WRELW VXSSRUW
simpler model of WF 4.0and the significant
',&20 PHVVDJLQJ DQG VHFXUH FRPPXQLFDWLRQ
OCR/ICR/OMR:)XOOSDJHRU]RQDOPXOWLWKUHDG
input Microsoft received in fixing the issues
HQDEOLQJ TXLFN LPSOHPHQWDWLRQ RI DQ\ ',&20
HGUHFRJQLWLRQZLWKIRUPDWWHGRXWSXWLQFOXGLQJ3')
6&8DQG6&3VHUYLFHV
'2&DQG7;7IRU:LQDQG[
that plagued WF 3.0/3.5should result in a
Barcode:5HDGZULWHDOOLQGXVWU\VWDQGDUG'DQG WPF (XAML): 9LHZHU ,PDJH /LVW
product with fewer quirks to trip you up.
$QQRWDWLRQV7UDQVLWLRQVDQG:,&&RGHFV
'EDUFRGHV 'DWD0DWUL[3')0LFUR3')
AJAX:HE)RUP,PDJHFRQWUROVIRUGHYHORSLQJ
45&RGHDQGPRUH 
If youve deployed workflows and believe
ULFKZHEDSSOLFDWLRQV
Forms Recognition and Processing: $XWRPDWL
youll have a challenging transition, Id like to
JPIP&OLHQWDQG6HUYHUFRPSRQHQWVIRU
FDOO\LGHQWLI\IRUPVDQGH[WUDFWXVHUOOHGGDWD
LQWHUDFWLYHVWUHDPLQJRIODUJHLPDJHVDQG
Document Cleanup/Preprocessing: 'HVNHZ
know more about your scenario so we can
DVVRFLDWHG LPDJH GDWD XVLQJ WKH PLQLPXP
GHVSHFNOH OLQH DQG ERUGHU UHPRYDO UHJLVWUDWLRQ
help Microsoft improve the transition experiSRVVLEOHEDQGZLGWK
PDUNVDQGPRUH
Scanning: 7:$,1 DQG :,$  DQG ELW 
PDF and PDF/A: 5HDGZULWH UDVWHU DQG WH[W
ence for you and others.

Q
A

Heres something Ive had a hard


time understanding: why shouldnt I
use string primary keys?

String primary keys present


problems in database integrity,
maintainability, and performance.
From a maintainability point of view, string
primary keys almost always have meaning.
Database values with meaning will eventually
change and wreak havoc on foreign-key
usage. At the least, they change when a dataentry mistake must be corrected. When you
make these kinds of changes, you must also
update all foreign keys.
Few string columns that have a meaning
are truly unique. Social Security numbers are
theoretically unique,but data-entry errors and
fraudulent usage results in redundant values.
This prohibits entry of the second record,
regardless of whether the second occurrence is
the legal use of the number. Also, federal law

VHDUFKDEOH3')OHV
Annotations: ,QWHUDFWLYH 8, IRU GRFXPHQW
PDUNXS UHGDFWLRQ DQG LPDJH PHDVXUHPHQW
LQFOXGLQJVXSSRUWIRU',&20DQQRWDWLRQV 
Grayscale Imaging: 'LVSOD\ DQG SURFHVV
VLJQHGXQVLJQHGELWELWGDWD
Medical Web Viewer Framework: 3OXJLQ
HQDEOHG IUDPHZRUN WR TXLFNO\ EXLOG KLJKTXDOLW\

'RFXPHQW

0DUNXS

DXWRGHWHFW RSWLPXP GULYHU VHWWLQJV IRU KLJK


VSHHGVFDQQLQJ
DVD:3OD\FUHDWHFRQYHUWDQGEXUQ'9'
LPDJHV
Multimedia:&DSWXUHSOD\VWUHDPDQGFRQYHUW
03(* $9, :09 03 03 2** ,62 '9' DQG
PRUH

)RUPV5HFRJQLWLRQ

%DUFRGH

0HGLFDO

0XOWLPHGLD

LEADTOOLS SDKs feature LEADs iCompress Technologies.


Free 60 Day Evaluation!

www.leadtools.com/msdn
800 637-1840

VisualStudioMagazine.com January 2009 VISUAL STUDIO MAGAZINE

25

0109vsm_AskKat.24-27.v6

12/15/08

9:07 AM

Page 26

A S K K AT H L E E N W I N D O W S W O R K F LO W 4 . 0

mary key indices are used extensively during normal database


operations. Slowing down these comparisons hurts overall database performance.
Clustered indexes allow physical organization of an index to
improve performance. Successful clustering relies on intrinsic
ordering of data and a relatively even spread. Integers provide this
ordering and distribution; strings and globally unique identifiers
(GUIDs) do not. In the case of GUIDs, just turn off clustering. In
the case of strings, replace them with a meaningless integer or
GUID primary key and add a secondary index on the meaningful
key. The secondary index can be a unique index and allows rapid
retrieval on your meaningful string values while still retaining
database maintainability, integrity, and performance.

System.IO.FileNotFoundException: Could not load file or


assembly 'RuntimeLoad.dll' or one of its dependencies. The
system cannot find the file specified.

Ive simplified my test code to:


Dim dllName = "RuntimeLoad.dll"
Dim assem As Reflection.Assembly = Nothing
Try
assem = Reflection.Assembly.Load(dllName)
Catch ex As Exception
Console.WriteLine( _
"Assembly failed to load: " & dllName)
Throw

Q
A

I want to switch to Windows Presentation Foundation


(WPF), but I need a data grid. I understand WPF doesnt
include a data grid, so what do you suggest I use?

End Try

WPF in .NET 3.0 and .NET 3.5 doesnt contain a data


grid. However, Microsoft has released the WPF Toolkit,
which includes a data grid, calendar control, and date
picker. This toolkit requires WPF 3.5 Service Pack 1 (SP1). The
included data grid is fairly full featured,but doesnt support grouping.
If youre working in .NET 3.0 or 3.5, youll need to either perform
inter-op on the Winforms data grid or use a third-party control.
This is another good reason to upgrade to .NET 3.5 SP1.

Reflection.Assembly.Load requires the assembly name


without the DLL extension. Remove this extension from
the string you pass to the Load method, and test again. If
this doesnt solve your problem, you should ensure that the file is in
the correct location, which is adjacent to the executable. By default,
this is at <project directory>/bin/Debug, where <project directory>
is the directory containing your project file (.vbproj).
You can also handle loading assemblies at runtime using
System.AddIn.The System.AddIn approach is important in some scenarios,but it might be overkill for what youre trying to accomplish.

Im frustrated trying to load an assembly at runtime. Even


though IO.File.Exists returns true, I get the error:

I need to copy some files into the executable directory, but


they arent in the project directory so it doesnt make sense to
treat them as resources. Weve been trying to do this manually,

Write New Workflows with .NET 4.0 in Mind


You can tweak your 3.0/3.5 workflows to make the transition
to Windows Workflow Foundation (WF) 4.0 a little easier. These
guidelines limit the scenarios in which theres no corresponding
feature in 4.0.
1. Create custom activities. Create custom activities instead of
code-beside logic in a CodeActivity. Theres no CodeActivity in WF
4.0. Remember that the custom activity model also changes, so its
best to move complex code out of the activity into utility libraries
or services.
2. Scope tightly. 4.0 variables are more constrained than 3.0
dependency properties. They no longer use the property
bag/dependency property approach but instead are scoped vertically. Choose a variable in a parent activity set retrieved by
child activities rather than directly retrieving data from a
sibling activity.
3. Use Windows Communication Foundation (WCF) messaging
when theres a choice. The Data Exchange Service (DES) model
goes away in WF 4.0: theres no external event model; external
communications is through WCF; and WCF interactions will be considerably easier in WF 4.0. For workflows that might transition to
4.0, write them in WF 3.5, and use the Send and Receive activities.
However, if you dont yet have WCF in your application or organiza-

26

VISUAL STUDIO MAGAZINE January 2009 VisualStudioMagazine.com

tion, implementing it in WCF 3.5 may be onerous. In this case, use


events, and assume youll rewrite around the new communications approach.
4. Perform initialization logic in the Activity.Execute method.
The signaling model changes in WF 4.0, and theres no
Activity.Initialize event. Any setup should be done in the Activity.Execute method.
5. Use WorkflowInstance.EnqueueOnIdle for queuing. If youre
doing manual queuing, which is relatively uncommon, you should
use the EnqueueOnIdle method, as this will be the only queuing
model supported going forward.
6. Be careful with data. The tracking and persistence databases
are likely to change significantly between 3.5 and 4.0. Holding
data only in tracking is hazardous, unless you prepare a strategy
for extracting data, such as when a workflow completes. If youre
using rules for simple data retrieval for values that should be set
outside the workflow, consider holding this data in a configuration
file or database.
Note that these are preliminary suggestions. Check out my
blog (http://msmvps.com/blogs/kathleen) for pointers towards
Microsofts formal guidance, as well as tools (as they become available) that will help you transition workflows.

0109vsm_AskKat.24-27.v6

12/15/08

9:07 AM

Page 27

A S K K AT H L E E N W I N D O W S W O R K F LO W 4 . 0

but weve made many mistakes related to not copying the updated files
properly. Is there a way to automate this?
Visual Studio supports pre- and post-build events, but I
think its easier to modify the project file. The project file
is an MSBuild script, capable of managing complicated
builds. It also makes it easy to handle
straightforward scenarios, such as copying
your files.
You can edit project files (.csproj and
.vbproj) in Notepad or another editor, but
editing them within Visual Studio supplies
XML syntax checking and IntelliSense. To
open your project file in Visual Studio, right
click on the project, and select Unload Project. Once it is unloaded, right click on it
again, and select Edit <project file name>.
The only downside of opening projects this
way is that Visual Studio loses its marker to
the startup project if you unload that project.
Scroll to the bottom to find the location
for one of several well-known targets:

GO ONLINE
Use this Locator+ code at VisualStudioMagazine.com to go directly to these
related resources.
READ MORE
VS0901AK Read this article online.

<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->

You dont need to understand targets or


why this works to put your pre- or postbuild code into the correct location.Copy
is an MSBuild task with the source file location relative to the project directory:
<Target Name="BeforeBuild">
<Copy SourceFiles=
"..\RuntimeLoad\bin\Debug\
RuntimeLoad.dll"
DestinationFolder="$(TargetDir)" />
</Target>

TargetDir is one of many predefined MSBuild


properties. You can see some of the most
common properties as macros for the preand post-build events by typing $( in Help. VSM
Kathleen Dollard is a consultant, author,
trainer, and speaker. Shes been a Microsoft
MVP for 10 years and is an active member of
the INETA Speakers Bureau. Her blog is
http://msmvps.com/blogs/kathleen. You can
reach her at kathleen@mvps.org.

VisualStudioMagazine.com January 2009 VISUAL STUDIO MAGAZINE

27

0109vsm_QandA_28-30.v4

12/15/08

9:35 AM

Page 28

INTERVIEW

Connect to

the Cloud
In this special interview, Microsoft Corporate Vice
President Robert Wahbe discusses the Azure Services
Platform and Software plus Services applications with
1105 Medias Jeffrey Schwartz and Michael Desmond.
BY JEFFREY SCHWARTZ AND MICHAEL DESMOND

ow that Microsoft has rolled out its


cloud-computing strategy, the company is hoping developers will start to
explore the Azure Services Platform and think
about how to build applications that live in the
Software plus Services (S+S) world.
A key evangelist on that front is Robert
Wahbe, corporate vice president of Microsofts
Connected Systems Division. Wahbe runs the
companys engineering teams that are charged
with delivering its Web services and modeling
platforms. The editors of VSMs sister publication Redmond Developer News sat down with
Wahbe at the recent Microsoft Professional
Developers Conference 2008 (PDC) to discuss
Azure and what impact it will have on the
Microsoft developer ecosystem.

28

VISUAL STUDIO MAGAZINE January 2009 VisualStudioMagazine.com

Microsoft Corporate Vice President Robert Wahbe

To what extent is Windows Azure based on


Hyper-V, and to what extent are we looking at a
whole new set of technologies?

AWindows Azure is a natural evolution of our platform. We think its going to have a long-term radical
impact with customers, partners, and developers, but its
a natural evolution. It takes what we have todayfrom
the phone to the desktop to the serverand brings that
to the cloud. Its built foundationally on top of Windows
Server 2008 and .NET Framework. We have millions of
developers on top of Visual Studio and on top of .NET
Framework, and they can take the vast majority of their
skill set and build apps the way they have been today.
They can deploy those on the premises.

0109vsm_QandA_28-30.v4

12/15/08

9:35 AM

Page 29

CO N N E C T TO T H E C LO U D

You can take Visual Studio and .NET Framework and build an
ASP.NET app, and then you can decide to deploy that locally, or
you can decide to deploy that to Windows Azure.

Q. So youre saying developers can write to the Windows cloud, otherwise known as Azure apps, and theyll run on Windows Server onpremises? That logic can be redeployed to Azure?
AThe key thingand Ray [Ozzie, Microsofts chief software architect] did mention this [during his PDC keynote]right now, many
applications arent built with the scale-out in mind from the beginning. The notion of stateless front-ends being able to scale out, both
across the data center and across data centers requires that you make
sure you have the right architectural model. Microsoft will be trying
hard to make sure we have the patterns and practices available to
developers to get those models [so that they] can be brought onto the
premises. As you write your applications in a scale-out model from
the premises, they can be brought into Windows Azure.
The example we showed was a situation where you can take
Visual Studio and .NET Framework and build an ASP.NET app,
and then you can decide to deploy that locally, or you can decide to
deploy that to Windows Azure. The only thing you have to do when
you go to Windows Azure is to specify some additional metadata.
You have to specify how many instances youre going to run on, and
what kind of SLA youre looking forthat kind of metadata. Then
Windows Azure can take that and implement that correctly.
Q How do they specify that metadata?
ARight nowto the coreits in an .XML file. Thats a great
example of an executable model, and Windows Azure understands
that model to its toes. So its a model, and it delivers that. You can
write those models in Oslo using the DSL written in M, targeting Windows Azure in those models.
Q So theres a natural fit here for apps developed in Oslo?
AYes, because Oslo is about helping you write apps more productively. You can write any kind of application, including cloud apps.
You can also write server applications and client applications. But
were definitely working hard on the models for the cloud as well.
Q What challenges might be awaiting dev shops? What sort of skills do
they need to either discover or refine as they move to a services-aware,
cloud-aware application?
A A lot of your existing skill set and a lot of your practices
whether it be the development methodology you use around ALM
or using TFS [Team Foundation Server]will just carry forward.

At the end of the day, youre just writing code, and youre deploying
that code. Windows Azure provides a new deployment target at a
fundamental level, so theres a lot thats similar.
A couple of things are new. There are a lot of new services that
developers are going to need to learn in order to see if they make
sense for their solutions. One example: If you were going to hook
up two businesses together with some sort of business-to-business
messaging application, we have a lot of technology that makes that
easyWindows Communication Foundation, these kinds of
things. But now you need to ask yourself: Does it make sense for
me to use the Azure platform and the service bus, which is a part of
.NET services? And youre going have to learn what the pros and
cons are if youre adding it to your solutions.
Every developer has a unique set of needs, and they need to
choose differently between how much theyre doing in the cloud
and how much theyre doing on the premises. So depending on
regulatory, compliance, or whatever assets they have and their scale
requirements, it might be an opportunity to learn something new.
Q Are we looking at plug-ins to Visual Studio or new development
interfaces to service-enable some of these things? Are we bringing
more development resources to the table?
A Youre going to see some very natural extensions to whats in
Visual Studio today. For example, youll see new project types. I
wouldnt call that a new tool; rather, Id call it a fairly natural extension to the existing tools. Youll see new properties in the property
descriptions of solutions. So you can say things like: How much
scale-out do I want? Do I want this to run in multiple data centers?
If you look at the portals for Windows Azure and the Azure Services Platform,there are new kinds of tools that are great for IT pros to
look at utilization,at what the load is on their applications, and so on.
Q What can we expect in terms of Oslo uptake and some of the stuff
that developers are going to have to grasp as they start developing into
the Azure space?
A We want to get bits into the hands of developers as early as we possibly can.We dont take the attitude that were going to wait until were
basically close to shipping, and then spring it on people. We want to
get a CTP [community technology preview] out early and engage in
that conversation.Now we can get this thing out broadly,get the feedback, and I think for me, thats the most powerful way to develop a
platform. If youre going to build a platform in a vacuum, its very
hard to get it right. You need to have developers pounding on it,
telling you what youre doing right and what youre doing wrong.

VISUAL STUDIO MAGAZINE January 2009 VisualStudioMagazine.com

29

0109vsm_QandA_28-30.v4

12/15/08

9:35 AM

Page 30

CO N N E C T TO T H E C LO U D

Q Given the uncertain time frame of Azure, are some of your rivals like
Amazon and Google gaining a lot of early share? How will you deal
with the competitive landscape?
A The place to start with Amazon is [that] theyre a partner. So
theyve licensed Windows, theyve licensed SQL, and we have
shared partners. What Amazon is doing, like traditional hosters, is
theyre taking a lot of the complexity out for our mutual customers
around hardware. The heavy lifting that a developer has to do to
take that and then build a scale-out service in the cloud and across
data centersthats left to the developer.
We have base compute and base storage, which is the foundation
of everything were doing with Windows Azure, but then we have
these higher-level services like the database in the cloud. We have
these user services for photos, contacts, and blogs, and these kinds
of things with the live services. We have Internet-scale buildingblock services with .NET services, and well be rolling out CRM
Services and SharePoint Services. We have these higher-level things
so that now developers can stand on the backs of thousands of
engineering years as theyre building the solution. They dont have
to build an Internet-scale pub-sub system. They dont have to have
a new way to do social networking and contacts. They dont have to
have reporting services that they have to build up themselves.
Google is a very limited offering. Its a single programming language. Its a particular part of the Web application. You cant do the
back-end processing. You dont have a full database back there. You
dont have a lot of the things you might need to build an end-to-end
application. You cant even take too long to respond to the Web
request or theyll shut you down. Its a hobby.
Q Obviously you have the Microsoft-hosted monoliths in play here.
Will an enterprise be able to host its own cloud? Will there be thirdparty partners doing that as well?
A I want to be very clear on this. We built Azure on top of Windows
Server and on top of .NET Framework. As we learn, were going to
take that innovation and bring it back to Windows Server. And then
as we innovate in Windows Server, well bring that back to Azure.
And we absolutely support the choice, depending on whether its
your data center, your cloud, your personal enterprise cloud, or the
Microsoft Azure cloud. But the way youll get your cloud is that
youll buy Windows Server, youll buy SQL Server, youll buy the
existing premises platform, and well continue to move that innovation unilaterally.
Q But in terms of the actual physical hosting of machines, if Im an
enterprise and I want to provide these cloud-based Azure services to
my users or business partners, I can have my own private cloud?
A With Windows Server, not with Azure. The Azure Services
Platform,SQL Services,Live Servicesthose are hosted exclusively in
the Microsoft data center. You get at them on Microsofts
platform and other platforms,because theyre all exposed on Internet
standards.

30

VISUAL STUDIO MAGAZINE January 2009 VisualStudioMagazine.com

Q Other platforms meaning?


A Other operating systems, other computing platforms, other
hosters that are exposed to Internet standardsREST, SOAP,
and XML.
Q So only Microsoft will be hosting Azure?
A Only Microsoft is hosting Azure, but anybody can host our core
app platform, which is Windows Server and SQL Server. And again,
the innovations are going to flow in both directions. Were going to
innovate in Windows Serverthat will move up to Azureand
well innovate in Azure.
Q We talk about the cost of computing, but what impact will all this
have on the cost of development and the management of dev processes?
A We think were removing complexities out of all layers of the stack
by doing this in the cloud for you.For example,well automatically do
all of the configuration so you can get load balancing across all of your
instances.Well make sure that the data is replicated both for efficiency and also for reliability, both across an individual data center and
across multiple data centers. So we think that by doing that you can
now focus much more on what your app is and less on all that app
infrastructure. My guess is that, to the extent that the cloud is appropriate, it will make it much simpler for you to build your applications
as a developer, and then you can also use premises as well.
Q Whats your advice for preparation now going though 2010?
A I think the call to action is to start engaging in a conversation
about the cloud and about Azure. Download the SDKs, get free
accounts, start playing with it, and start giving us feedback. That
way we can make sure that what we deliver is what [development
managers] need. Also, you need to start thinking about whats
appropriate for a hosted solution, and whats appropriate for
premises. Start getting those kinds of development practices in
place so as these roll out theres an easier way to take advantage of
the new services. These represent new patterns and practices
new best practices. VSM
Jeffrey Schwartz (jschwartz@1105media.com) is executive editor,
features, and Michael Desmond (mdesmond@1105media.com) is
editor in chief of RDN.

GO ONLINE
Use this Locator+ code at VisualStudioMagazine.com to go directly to these
related resources.
READ MORE
VS0901RW Read this article online.

0109vsm_AdIndex_31

12/15/08

2:27 PM

Page 31

Advertising Sales

Ad Index
Atalasoft, Inc.
www.atalasoft.com

pg. 23

ComponentOne
www.componentone.com

East
Andrew Mintz
National Sales Manager
Phone: 508-532-1433
amintz@1105media.com

West
Chris Kourtoglou
Regional Sales Manager
Phone: 650-579-0121
ckourtoglou@1105media.com

National Accounts Director


William Smith
Phone: 603-886-3466
wsmith@1105media.com

Microsoft Account Manager


Danna Vedder
Phone: 253-514-8015
dvedder@1105media.com

Jenny Hernandez-Asandas
Phone: 818-734-1520 ext 101
Fax: 818-734-1528
jhernandez@1105media.com

Production Coordinator
Catharine Wood
Phone: 818-734-1520 ext 233
vsmadproduction@1105media.com
cwood@1105media.com

ID Statement
Visual Studio Magazine (ISSN 1537-002X) is published
monthly by 1105 Media, Inc., 9121 Oakdale Avenue, Ste. 101,
Chatsworth, CA 91311. Periodicals postage paid at
Chatsworth, CA 91311-9998, and at additional mailing
offices. Complimentary subscriptions are sent to qualifying
subscribers. Annual subscription rates for non-qualified subscribers are: U.S. $34.97, Canada $52.97 (U.S. funds);
International $78.97 (U.S. funds). Subscription inquiries,
back issue requests, and address changes: Mail to: Visual
Studio Magazine, P.O. Box 1164, Skokie, IL 60076-8164,
email VSM@1105service.com or call toll free (888) 7688759, fax number 847-763-9564. International calls 847763-9135. POSTMASTER: Send address changes to Visual
Studio Magazine, P.O. Box 1164, Skokie, IL 60076-8164.
Canada Publications Mail Agreement No: 40612608. Return
Undeliverable Canadian Addresses to Circulation Dept. or
Bleuchip International, P.O. Box 25542, London, ON N6C 6B2.

Copyright Statement
Copyright 2009 by 1105 Media, Inc. All rights reserved.
Printed in the U.S.A. Reproductions in whole or part prohibited except by written permission. Mail requests to
"Permissions Editor," c/o Visual Studio Magazine, 2600 El
Camino Real, Ste 300, San Mateo, CA 94403.

Legal Disclaimer
The information in this magazine has not undergone any
formal testing by 1105 Media, Inc. and is distributed without any warranty expressed or implied. Implementation or
use of any information contained herein is the reader's sole
responsibility. While the information has been reviewed for

dtSearch
www.dtsearch.com

pg. 20

Intel Corporation
www.intel.com

pg. C4

LEAD Technologies, Inc.


www.leadtools.com

pg. 25

Microsoft Corporation
www.microsoft.com

Director, Print Production

accuracy, there is no guarantee that the same or similar


results may be achieved in all environments. Technical inaccuracies may result from printing errors and/or new developments in the industry.

Corporate Address

pg. 12, 13

Pegasus Imaging Corporation


www.pegasusimaging.com
Software FX, Inc.
www.softwarefx.com

pg. 27

pg. C2, 1

Visual Studio Magazine


www.visualstudiomagazine.com

pg. C3

VSLive! Events
Vslive.com/sf2009

pg. 5

Wayside Technology Group, Inc.


www.waysidetechnology.com

pg. 3

Edit Ad Index
Compuware
9
www.compuware.com

Corporate Headquarters:
1105 Media
9121 Oakdale Ave. Ste 101, Chatsworth, CA 91311
www.1105media.com

Developer Express
www.devexpress.com

Media Kits

JetBrains
8
www.jetbrains.com

Media Kits: Direct your Media Kit requests to Matt Morollo,


VP Publishing, 508-532-1418 (phone), 508-875-6622
(fax), mmorollo@1105media.com

pg. 16, 17

Typemock
8
www.typmock.com

Reprints
Reprints: For single article reprints (in minimum quantities of
250-500), e-prints, plaques and posters contact:
PARS International
Phone: 212-221-9595
E-mail: 1105reprints@parsintl.com
www.magreprints.com/QuickQuote.asp

List Rental
This publications subscriber list, as well as other lists from
1105 Media, Inc., is available for rental. For more information, please contact our list manager, Merit Direct. Phone:
914-368-1000; E-mail: 1105media@meritdirect.com;
Web: www.meritdirect.com.

Go to
VisualStudioMagazine.com
to access the stories in this
issue, plus read exclusive
online-only content.

VisualStudioMagazine.com January 2009 VISUAL STUDIO MAGAZINE

31

0109vsm_GuestOp.32.v4

12/15/08

9:32 AM

The Pragmatic

Page 32

Developer

IS AGILE
ROCK OR DISCO?

BY BILLY HOLLIS

When I was a teen, listening to 30-year-old music was distinctly uncool.Yet


todays teens listen happily to music more than 30 years old. A bit after rock
came the disco wave. For a while, it was wildly popular. The Rolling Stones
and David Bowie did songs with heavy disco influences. But
you dont find that many disco songs on Guitar Hero or
Rock Band,while you do find many vintage rock songs from
a score of sixties rock icons.
Will agile methodologies fare as well as rock? Will we still
be doing agile software development 20 or 30 years from now?
Or will agile be the disco of this software era, fading in favor of
something else in the next few years?
I dont know. I dont think anyone knows.
Agile has some interesting strengths. I think agile proponents are right on the money about a rapid feedback loop and
having clear accountability for developers. I believe there are
places where agile methodologies have dramatically improved
the outcomes of software development efforts. But I dont
think agile is perfect, nor do I think its best for everyone.
Agile means different things to different people. Im
writing a short column and not a book, so I must, out of
necessity, paint with a broad brush. I hope agile proponents
will keep that in mind.
My first criticism of agile is the fanatic mentality of some
proponents. In one of the first books about Scrum,Agile Software Development with Scrum (Prentice Hall, 2001) by Ken
Schwaber and Mike Beedle, the authors claim: Industrial
process control theory is a proven body of knowledge that
describes why Scrum works and other approaches are difficult
and finally untenable. In short theyre saying Scrum works
and nothing else does. Thats a sweeping and ridiculous claim.
No matter how good Scrum is, circumstances vary far too
much to make such an argument. Projects range in size and
complexity, and developers vary in talent and temperament.
Let me say again that I think agile has many fine qualities
and can lead to successful development projects. But that
doesnt mean agile is perfect, or that its the right choice for all
projects. Heres what I mean:
The Patterns and Practices group at Microsoft is heavily
into agile development. Don Smith is in that group, and, at a

32

VISUAL STUDIO MAGAZINE January 2009 VisualStudioMagazine.com

conference last May, he said,Its hard to do agile without really


good developers. Ive heard variations of the same thing said
from others.
But not all developers are that good. Therefore, if Don is
right, then agile isnt for everyone.
I also think agile development still has areas where it can
improve. For example, agile teams have a tendency to require a
high level of experience and professionalism just to join the
team. What about talented, but inexperienced, developers?
Richard Campbell, of the Internet audio talk show .NET
Rocks, wonders if agile is compromising our supply of development talent by ignoring such developers. I wonder if agile is
sowing the seeds of its own destruction by alienating a broad
swath of new talent. I think agile practices could improve by
formalizing mentoring beyond pair programming, which I
consider a highly inefficient way of mentoring.
Finally, I wonder how much of agile development exists
simply to make developers more comfortable. Most developers
love to write code,and agile does a pretty good job of rationalizing
why developers dont need to do anything else. Design? Code it
with test-driven development. Requirements gathering? Ive
heard proponents of agile development say that the user doesnt
know what they want until they see something, so you might as
well get straight to coding. Im sorry, but thats a cop-out. Users
can tell you what they need if you know how to ask them.
Like everything else in technology,agile development must
evolve. I hope it succeeds as rock music has; with many different
styles that suit different tastes and circumstances.And I hope it
sheds the elitism and fanaticism that I see in some proponents.
Otherwise, its more likely to share the destiny of disco. VSM
Billy Hollis is an author, consultant, and veteran software developer
on Microsoft technologies. Hes currently developing Software as a
Service applications with Windows Presentation Foundation and
Silverlight and training others on those technologies. He speaks
regularly at VSLive! events. Reach him at billyhollis@gmail.com.

0208vsm_VSMPureAd.final

1/18/08

11:46 AM

Page 32

PURE

VISUAL STUDIO AND .NET

E N T E R P R I S E

S O L U T I O N S

F O R

.N E T

D E V E L O P M E N T

M A G A Z I N E . C O M

POWERING THE WINDOWS SOFTWARE REVOLUTION

OPTIMIZED FOR
PRINT ONLINE EVENTS

For more information visit:


www.VisualStudioMagazine.com
www.RedDevNews.com
www.VSLive.com

Project1

12/15/08

11:45 AM

Page 1

EVOLVE YOUR CODE.


Parallelism breakthrough.
7KLVDOOLQRQHSDUDOOHOLVPWRROVHWVLPSOLHVSDUDOOHOLVPIRUPXOWLFRUH
IURPDQDO\VLVDQGFRPSLOLQJWKURXJKGHEXJJLQJDQGWXQLQJ'HVLJQHG
IRUWRGD\VVHULDODSSVDQGWRPRUURZVSDUDOOHOLQQRYDWRUV
/HDUQPRUHDQGVLJQXSIRU%HWDwww.intel.com/go/parallel

,QWHO&RUSRUDWLRQ$OOULJKWVUHVHUYHG,QWHODQGWKH,QWHOORJRDUHWUDGHPDUNVRI,QWHO&RUSRUDWLRQLQWKH86DQGRWKHUFRXQWULHV 2WKHUQDPHVDQGEUDQGVPD\EHFODLPHGDVWKHSURSHUW\RIRWKHUV

Potrebbero piacerti anche