silverlight ascendantpdf.101com.com/vsmmag/2010/70045069/vsm_1002dg.pdf · february 2010 volume 20,...

44
VisualStudioMagazine.com PLUS Microsoft Tunes VS2010 Performance Digging into Silverlight and MEF From MSDN Magazine Use Agile Techniques to Pay Back Technical Debt Why the next version of the Microsoft RIA platform sets the stage for line-of-business development. FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant

Upload: others

Post on 28-Jun-2020

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

VisualStudioMagazine.com

PLUS Microsoft Tunes

VS2010 Performance

Digging into Silverlight and MEF

From MSDN MagazineUse Agile Techniques

to Pay Back Technical Debt

Why the next version of the Microsoft RIA platform sets the stage for line-of-business development.

FEB

RU

ARY

20

10

Vol

ume

20

, No.

2

Silverlight Ascendant

Page 2: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

Untitled-7 2 1/8/10 3:36 PM

Page 3: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

Infuse your team with the power to create user interfaceswith extreme functionality, complete usability and the

“wow-factor!” with NetAdvantage® in your .NET developmenttoolbox. Featuring the most powerful and fastest data grids onthe market for Windows Forms, ASP.NET, Silverlight and WPF,

it’ll be like having the strength of 10 developers on every desktop. Go to infragistics.com/killerapps to find out how you and your

team can start creating your own Killer Apps.

Infragistics Sales 800 231 8588 Infragistics Europe Sales +44 (0) 800 298 9055

Infragistics India +91-80-6785-1111

Copyright 1996-2010 Infragistics, Inc. All rights reserved. Infragistics and the Infragistics logo and NetAdvantage are registered trademarks of Infragistics, Inc.

Untitled-7 3 1/8/10 3:36 PM

Page 4: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

programmersparadise.com866-719-1528

Your best source for software development tools!

Prices subject to change. Not responsible for typographical errors.

®

programmers.com/theimagingsource

Download a demo today.

NEWRELEASE!

Professional EditionParadise #

T79 02101A02$848.99

programmers.com/ca

CA ERwin® Data Modelerr7.3 – Product Plus 1 YearEnterprise MaintenanceCA ERwin Data Modeler is a data modelingsolution that enables you to create and maintain databases, data warehouses and enterprise data resource models. These models help you visualize data structures so that you can effectively organize, manage and moderate data complexities, database technologies andthe deployment environment.

• .NET WinForms control for VB.NET and C#• ActiveX for VB6, Delphi, VBScript/HTML, ASP• File formats DOCX, DOC, RTF, HTML, XML, TXT• PDF and PDF/A export, PDF text import• Tables, headers & footers, text frames, bullets,

structured numbered lists, multiple undo/redo,sections, merge fields, columns

• Ready-to-use toolbars and dialog boxes

TX Text Control 15.1Word Processing ComponentsTX Text Control is royalty-free, robust and powerful word processing software in reusable component form.

programmers.com/pragma

Pragma Fortress SSH—SSHServer & Client for Windows by Pragma SystemsContains SSH, SFTP, SCP servers and clients for Windows.• Certified for Windows Server 2008R2• Compatible with Windows 7• High-performance servers with

centralized management• Active Directory & GSSAPI authentication• Supports over 1000 sessions• Offers FIPS mode• Hyper-V and PowerShell support• Runs in Windows 2008R2/2008/2003/7/

Vista/XP/2000

Paradise # P35 04201A01 $550.99

Paradise # P26 04201E01$3,951.99

programmers.com/unify

Unify SQLBase Embedded Databaseby UnifySQLBase is an easy to deploy database for building desktop and Web applications in server environments without a DBA.

• Small footprint• Zero admin deployment• GUI admin • Embed it and forget it

For applications with encrypted security, we offer SQLBase Treasury.

Reduce your database costs and simplify maintenance with Unify SQLBase.

Paradise # C15 03101A01

$143.99

programmers.com/vSphere

FREE ON DEMAND WEBINAR SERIES:MORE Maximum Data Modeling with CA ERwin 7.3 In our last webinar series, we looked at CAERwin’s core functionality. In this second series,we provide a grounding in how CA ERwin r7.3’snew features help you with Master Data Management, MetadataManagement, Data Warehousing, Data Governance and Business Intelligence.

There are six sessions in the on demand series:• What’s New in CA ERwin 7.3• MDM (Master Data Management) with CA ERwin and Data

Profiling tool• Collaborative model management with CA ERwin ModelManager• Validate the integrity of your model with CA ERwin Validator• Reporting: Crystal Reports, PDF, HTML• SAPHIR Option: light at the end of the metadata tunnel

CA ERwin r7.3

VIEW TODAY: programmers.com/MDM_2009

programmers.com/sparxsystems

Enterprise Architect 7.5Visualize, Document and Control Your Software Projectby Sparx SystemsEnterprise Architect is a comprehensive,integrated UML 2.1 modeling suite providing key benefits at each stage ofsystem development. Enterprise Architect7.5 supports UML, SysML, BPMN andother open standards to analyze, design,test and construct reliable, well under-stood systems. Additional plug-ins arealso available for Zachman Framework,MODAF, DoDAF and TOGAF, and to integrate with Eclipse and Visual Studio2005/2008.

Corporate Edition1-4 Users

Paradise # SP6 03101A02

$182.99

programmers.com/LEAD

LEADTOOLS Recognition SDK v16.5by LEAD TechnologiesDevelop robust 32/64 bit document imaging and recognition functionality into your applications with accurate and high-speed multi-threaded Forms, OCR, OMR, and 1D/2D barcode engines.• Supports text, OMR, image, and

barcode fields• Auto-registration and clean-up to

improve recognition results• Provided as both high and low

level interface• Includes comprehensive confidence

reports to assess performance

Paradise # L05 26301A01 $3,214.99

NEWRELEASE!

Orion Network Performance Monitorby SolarwindsOrion Network Performance Monitor is a comprehensive fault and network performance management platform that scales with the rapid growth of your network and expands with your network management needs. It offers out-of-the-box network-centric views that are designed to deliver the critical information network engineers need. Orion NPM is the easiest product of its kind to use and maintain, meaning you will spend more time actually managing networks, not supporting Orion NPM.

Paradise # S4A 08201E02

$4,606.99

Certified for Windows7/2008R2

VMware vSphere Put time back into your day.Your business depends on how you spend your time. You need to manage IT costs without losing time or performance. With proven cost-effective virtualization solutions from VMware, you can:

• Increase the productivity of your existing staffthree times over

• Control downtime—whether planned or not

• Save more than 50% on the cost of managing,powering and cooling servers

Make your time (and money) count for morewith virtualization from VMware.

VMware Advanced

Acceleration Kit for 6 processors

Paradise # V55 78101A01

$9,234.99

AdminStudio & ApplicationVirtualization Packby Flexera SoftwareOne Application Software Deployment Tool for Reliable MSI Packaging, ApplicationVirtualization, and Windows 7 Migration. Top choice of Microsoft®, Novell®, LANDesk®

and other software management solutions. Cut MSI packaging time by up to 70%, Deploy software to desktops with 99% success or better. AdminStudio is the only MSI packaging solution to support multiple virtualization formats, including Microsoft®

App-V™, VMware® ThinApp™ and Citrix® XenApp™.

ProfessionalUpgrade from any Active AS Pro + Silver MtnParadise # I21 09401S05

$4,228.99

programmers.com/multiedit

Multi-Edit 2008by Multi Edit SoftwareMulti-Edit 2008 delivers, a powerful IDE,with its speed, depth, and support forover 50 languages. Enhanced searchfunctions include Perl 5 RegularExpressions and definable filters.Supports large DOS/Windows, UNIX,binary and Mac files. File SyncIntegration for: Delphi 6, 7, 2005, C++Builder 6, BDS 2006 and RadStudio2007, VB 6, VC 6, VS 2003, 2005 and 2008. Includes file compare, code beautifying, command maps, and much more.

1-49 UsersParadise #

A30 01201A01$179.99

programmers.com/grapecity

FarPoint Spread for Windows FormsNow with Charting! The Best Grid is aSpreadsheet. Give your users the look, feel, and power of Microsoft® Excel®, without needing Excel installed on their machines. Join the professional developers around the worldwho consistently turn to FarPoint Spread to add powerful, extendable spreadsheet solutionsto their COM, ASP.NET, .NET, BizTalk Server and SharePoint Server applications.• World’s #1 selling development spreadsheet • Read/Write native Microsoft Excel Files• Charts with 85 new chart types• Fully extensible models• Royalty-free, run-time free

Paradise # F02 01101A01 $936.99

NEWVERSION

5!

programmers.com/solarwindsprogrammers.com/flexera

Untitled-35 1 1/4/10 3:12 PM

Page 5: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

Contents { F R A M E W O R K S }

Going MultichannelI spoke with Forrester Research analyst Jeff rey Hammond while reporting this month’s cover feature on the Silverlight 4 beta and what it means for .NET develop-ment. To hear Hammond tell it, Silverlight 4 is part of a larger phenomenon that has mature rich Internet application (RIA) platforms playing a strategic role in the delivery of “multichannel applications.”

“TweetDeck has two completely diff erent code bases for iPhone and browser,” says Hammond of the Adobe AIR-based app, by way of example. “Yet I think of those as a single app.”

The problem for dev shops is, how do you serve these clients without multiplying the amount of code you’re managing? RIA platforms are rapidly fi lling that gap. Silverlight 4 delivers a substantial subset of the .NET Framework to a cross-platform audience, while enabling binary compat-ibility with Windows Presentation Foundation and .NET 4.

With more aggressive mobile support likely—look for details next month at the MIX10 event—Microsoft seems poised to deliver on what it calls “write once, optimize anywhere.” As Microsoft Director of the Developer Platforms and Tools Group Brian Goldfarb points out, core application code can be shared across client targets. “The work involved is literally customizing the front-end UI for the devices themselves and for the keyboard, and then taking advantage of platform-specifi c extensions,” he says.

Hammond says he expects multichannel app development to pervade the enterprise over the next three years. But will enterprises really move signifi cant amounts of development to RIA platforms like Silverlight and AIR? E-mail me at [email protected].

Michael Desmond, Editor in Chief, Visual Studio Magazine

February 2010 // Volume 20 // No. 2

FEATURES

14 Silverlight AscendantThe Silverlight 4 beta impresses, and sets the stage for mainstream app dev on Microsoft’s RIA platform.BY MICHAEL DESMOND

From MSDN Magazine20 Using Agile Techniques to Pay Back Technical Debt

Flawed code is like financial debt. It drags you down and consumes resources that would otherwise go to profit-making ventures. Here’s how to avoid getting caught in the technical debt trap.BY DAVID LARIBEE

29 LANGUAGE LAB

Practical ASP.NET PAGE 29 The QueryExtender

Extend runtime sorting and filtering of data with ASP.NET 4’s QueryExtender, which provides a single interface for DataSources.BY PETER VOGEL

Ask Kathleen PAGE 34 Digging Deeper into Silverlight and MEF

Silverlight applications based on Managed Extensibility Framework and generalized user interfaces don’t require hand coding every screen.BY KATHLEEN DOLLARD

DEPARTMENTS

6 Letters to the Editor

8 DevDisastersWeekend DriveBY ALEX PAPADIMOULIS (THEDAILYWTF.COM)

DevInsight DEVELOPER NEWS, REVIEWS, PRODUCT BRIEFS

News: VS2010 Release Candidate Expected this Month PAGE 10

Product Review: dynaTrace Offers End-to-End Multi-Tier Tracing PAGE 13

39 Index of Advertisers

COLUMNS

3 Frameworks BY MICHAEL DESMOND

40 Redmond Review BY ANDREW BRUST

14

VisualStudioMagazine.com · February 2010 · VISUAL STUDIO MAGAZINE 3

Page 6: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

Online Contents

4 VISUAL STUDIO MAGAZINE · February 2010 · VisualStudioMagazine.com

Get the complete picture —the latest dev news, analysis and how-to content—at VisualStudioMagazine.com and our partner sites in the Redmond Developer Network.

VisualStudioMagazine.com RedDevNews.com ADTmag.com

VISUALSTUDIOMAGAZINE.COM

Practical ASP.NETDefi ning Templates with jTemplateBY PETER VOGELA jTemplate template integrates data collections and JavaScript code with HTML. A combination of client-side code, Windows Communication Foundation services and jQuery lets you retrieve data from your sever and display it to the user using Web Services and client-side code.

/VogelB0210

Classic VB CornerMonitoring System Power StatusBY KARL PETERSONWindows provides a steady stream of notifi cations on power status—you only have to listen.

/Peterson0210

Desmond FileA Matter of OrchestrationBY MICHAEL DESMOND With Visual Studio 2010 and .NET 4 on the horizon, Microsoft is prepared to put its tooling and platforms in something closer to lockstep.

/Desmond0210

REDDEVNEWS.COM

Microsoft Rings in 2010 with Commercial Cloud ServicesBY KATHLEEN RICHARDSThe CTPs of the Windows Azure platform are getting phased out, except for Microsoft’s Data as a Service, code-named “Dallas.”

/RichardsA0210

Ballmer Highlights Two Screens at CES TalkBY KURT MACKIEMicrosoft CEO Steve Ballmer gave a pre-conference keynote at CES in January. Proclaiming Windows 7 the fastest selling OS in history, he said partners had delivered more than 800 apps.

/Mackie0210

RDN ExpressThe New Normal for App Dev in 2010BY KATHLEEN RICHARDSForrester Research outlines fi ve key changes for application development professionals who want to code better and cut costs this year. Analysts suggest dev teams consider a lean and mean approach, similar to Web start-ups.

/RichardsB0210

ADTMAG.COM

Google’s OpenSocial Fueling Atlassian’s SaaS Development Shift BY JOHN K. WATERSAtlassian is a longtime advocate of the OpenSocial standard for enterprise environments; the company claims Google’s OpenSocial is fueling “a major evolutionary shift” in the dev space around Software as a Service.

/WatersA0210

New SOA Gadget Tool for Enterprise Web Devs BY JOHN K. WATERSOpen source middleware provider WSO2’s new Gadget Server gives Web developers an enterprise-level tool for creating gadgets using common Web standards.

/WatersB0210

Reshaping the Smartphone MarketBY JEFFREY SCHWARTZGoogle has launched its Nexus One, a touch-based smartphone. Paired with enhancements to Google’s Android OS, Nexus One could threaten Apple’s strong developer ecosystem and erode support for the Microsoft Windows Mobile platform.

/Schwartz0210

EASY FINDITWhat we once called FindIT codes are now easy URLs. You’ll see these embedded throughout Visual Studio Magazine so you can access any additional information quickly. Simply type in VisualStudioMagazine.com/ followed by the FindIT code into your URL address field. (Note that all URLs do not have any spaces, and they are not case-sensitive.)

Page 7: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

Project3 11/10/09 2:26 PM Page 1

Page 8: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

6 VISUAL STUDIO MAGAZINE · February 2010 · VisualStudioMagazine.com

LettersASP.NET and jQueryIn a recent Practical ASP.NET column (“Integrating jQuery, Web Services, AJAX and ASP.NET,” December 2009), Peter Vogel showed readers how to use jQuery—along with server-side code and ASP.NET for AJAX—to create a typical CRUD business page. Readers welcomed the much-needed tutorial with comments such as “awesome article” and “you’ve made jQuery look easy.” Among the responses:

Let me just say that this has completely revolutionized the way I look at Web development, and has received a coveted spot on my bookmarks toolbar. Mr. Vogel, you did an excellent job in creating this introduction.

AnonymousPosted Online

I’ve been thinking about looking at jQuery, but didn’t have the time or motivation. Your excellent article changed that for me in a big way. One question though: Can you actually use server-side syntax, such as in an external .JS file? If that is indeed the case, I’ll move a ton of my .JS code off the page and into separate files. Thanks again for your enlightening writing!

John Kotuby Connecticut

Peter Vogel responds: You can use the =Control.ClientId syntax to get references to controls from code embedded in your .ASPX page. You could then pass those references to functions in an external file.

Skipping ClassesThe new generic tuple classes in .NET 4 that Bill McCarthy discussed in his latest On VB column (“Types and Tuples in .NET 4,” December 2009) didn’t convince several readers that VB10 promised better coding.

Yuck! Yet another feature to further complicate the Visual Basic language instead of making the language simpler—or more Basic.

AnonymousPosted Online

Why don’t we then name all our variables s,d,f,g so that g = person.item1, then strip out any comments except for the one that says, “See if you can work this mess out”—which represents the documentation for the poor dude who has to do maintenance in a few years. And as an aside, if you’re using the Auto properties why wouldn’t you assign the param to the property in the example constructor instead of trying to get access to the field?

AnonymousPosted Online

VisualStudioMagazine.comFebruary 2010 • Volume 20 • No. 2

Editorial Staff

Vice President, Doug BarneyEditorial Director

Editor in Chief Michael DesmondExecutive Editor Kathleen RichardsManaging Editor Wendy Gonchar

Associate Managing Editor Katrina Carrasco

Contributing Editors

Andrew J. Brust, Ken Cox, Kathleen Dollard,Roger Jennings, Jeff Levinson, Bill McCarthy, Karl E. Peterson, Keith Pleas, Peter Vogel,

Bill Wagner, Dan Wahlin,John K. Waters

Art Staff

Creative Director Scott Shultz Art Director Joshua Gould

Online/Digital Media

Director, Online Media Becky NagelExecutive Editor, New Media Michael Domingo

Site Administrator Shane Lee Designer Rodrigo Muñoz

President Henry AllainVice President, Publishing Matt Morollo

Director of Marketing Michele ImgrundOnline Marketing Director Tracy Cook

President & Neal VitaleChief Executive Offi cer

Senior Vice President Richard Vitale& Chief Financial Offi cer

Executive Vice President Michael J. Valenti

Vice President, Finance Christopher M. Coates& Administration

Vice President, Digital Media, Abraham M. LangerAudience Development

Vice President, Information Erik A. Lindgren Technology & Web Operations

Chairman of the Board Jeff rey S. Klein

REACHING THE EDITORSEditors 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: [email protected]. Do not include a middle name or middle initials.

Telephone: The switchboard is open weekdays 8:30 a.m. to 5:30 p.m. Pacifi c Time. After 5:30 p.m. you will be directed to individual extensions.

San Francisco Offi ce 415-814-0950; Fax 415-814-0961

Irvine Offi ce 949-265-1520; Fax 949-265-1528

Corporate Offi ce 818-814-5200; Fax 818-734-1528

Visual Studio MagazineThe opinions expressed within the articles and other contents herein do not necessarily express those of the publisher. Visual Studio Magazine wants to hear from you! Send us your thoughts

about recent stories, technology updates or whatever’s on your mind. E-mail us at [email protected] and be sure to include your first and last name, city and state. Please note that letters may be edited for form, fit and style. They express the views of the individual authors, and do not necessarily reflect the views of the VSM editors or 1105 Media Inc.

Letters

Page 9: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

Project3 12/16/09 11:55 AM Page 1

Page 10: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

8 VISUAL STUDIO MAGAZINE · February 2010 · VisualStudioMagazine.com

SERVED UP BY ALEX PAPADIMOULIS

</DevDisasters>{ S O F T W A R E D E V E L O P M E N T G O N E W R O N G }

Tell Us Your Tale Each issue Alex Papadimoulis, publisher of the popular Web site The Daily WTF (thedailywtf.com), recounts fi rst-person tales of software development gone terribly wrong. Have you experienced the darker side of development? We want to publish your story. E-mail your tale to Executive Editor Kathleen Richards at [email protected] and put “DevDisasters” as the subject line.

ILLU

STR

ATIO

N B

Y X

XX

XX

XX

X

Suddenly, and for no apparent reason, an internal support application at Joe R.’s company

suff ered a slowdown in executing queries and returning data. As the programmer tasked with working on this particular .NET 2.0-based Web app, this sluggish performance aff ected Joe, as his client-service software was now “unusable.”

It was assumed that the root of the problem was Joe’s code. However, Joe knew this was unlikely because the code had been working fi ne when he had left for the weekend.

Tuning the SystemWhen Monday morning arrived, Joe was informed of the application performance issues and the painfully slow responses from the Oracle database servers. He tried everything he could think of to remedy the performance problem: code optimiza-tion, query optimization, re-compiling views. Everything. Still, no dice.

The performance issue was making Joe’s internal support application run exceedingly slow, and it needed to be fi xed. Identifying the root cause kept him busy for most of the day, and the next day, and the next. He even tried executing the SQL Queries directly in his SQL Code editor.

The queries were still very slow. Queries that should have taken milliseconds were taking roughly 30 seconds to execute:

field_k", (select d.field_l from table5 d where d.field_m = a.table_2_id and d.field_j = 'My Value') as "the_field_o", a.field13, a.field14, a.field15, a.field16, (select field_p from table6 where field_q = a.field_r) field17 from table0 a, table6 b where b.field_s = a.field_t

By this point, Joe had circled back to his original conclusion: It was nothing that he did because everything was working fi ne the previous Friday. So he knew that something happened over the weekend that he had no control over.

Watch Where You Put That!Enter the boss’ son.

For some reason, the boss’ son had put all of the databases on a thumb drive. He was planning on moving the system to another server, and had accidentally put the entire thing on a USB drive.

Whoops.Once Joe discovered this, the system

was placed on the proper server and everything went back to executing smoothly. As far as Joe could tell, the higher-ups never actually said anything to anyone aff ected by this slip up—especially the other developers who worked more closely with the DBMS. They just acted like nothing happened. VSM

select field1, field2, field3, (select field_a from table1 where field_b = a.table_1_id) field_a, b.field4, a.field6, (select field_c from table2 where field_d = a.table_2_id) field_c, (select field_e from table3 where field_f = a.table_3_id) field_e, a.field7, a.field8, a.field9 AS "the_field_9", (select c.field_g from table4 c where c.field_h = a.table_4_id) as "the_field_g", (select c.field_g from table4 c where c.field_h = a.table_5_id) as "the_field_h", (select c.field_g from table4 c where c.field_h = a.table_6_id) as "the_field_i", a.field10, a.field11, a.field12, (select d.field_j from table5 d where d.field_k = a.table_2_id and d.field_j = 'My Value') as "the_

Weekend Drive

Page 11: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

Untitled-6 1 1/8/10 3:25 PM

Page 12: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

</DevInsight>D E VE LO P E R N E WS / / / RE V I E WS

DEVELOPER NEWS

10 VISUAL STUDIO MAGAZINE · February 2010 · VisualStudioMagazine.com

BY KATHLEEN RICHARDSMicrosoft is slated to off er a public release candidate (RC) of Visual Studio 2010 this month, delaying the formal “launch” of the upcoming IDE and .NET Framework 4 by a few weeks, according to the company. If Microsoft adheres to that schedule, VS2010 should be released to manufacturing (RTM) by April 12, the new launch date.

Beta 1 of VS2010 and .NET 4 were made available last May, followed by beta 2 in October. Participants in Microsoft’s Technology Adoption Program and Visual Studio Industry Partners had access to limited community technology previews (CTPs) after the beta 2 release.

In November, at the Microsoft Professional Developers Conference (PDC), company offi cials announced that the upcoming IDE and framework would offi cially launch on March 22.

But by mid-December, approximately two months into the public beta 2 release, Senior VP of the Microsoft Developer Division S. Somasegar announced plans for the unexpected public RC build in his blog. He noted that developers had provided positive feedback on the new capabilities in VS2010 and .NET 4.

Somasegar also acknowledged: “[Y]ou have also given us feedback around performance issues, specifi cally in a few key scenarios including virtual memory usage. As you may have

seen, we signifi cantly improved performance between beta 1 and beta 2. Based on what we’ve heard, we clearly needed to do more work.”

Scott Guthrie, a corporate vice president in the Developer Division, further explained in his blog: “We’ve been doing an intensive performance-optimization push the last two months that is delivering signifi cant perfor-mance and virtual memory usage improvements across the product. The early feedback from a small set of customers testing interim builds since beta 2 has been positive about these improvements. We still have several big performance fi xes in the process of being checked in that will improve things even further.”

According to Guthrie, the public RC will include a “go-live” license with support for production deployments. The go-live license doesn’t apply to Internet-based technologies such as Silverlight 4, currently in beta and slated for release in the fi rst half of the year.

Developers have reported problems with VS2010 beta 2 hanging when XAML fi les are being worked on, crashing if debugging is done with the

XAML editor open and other Silverlight and ASP.NET 4 issues. Similarly, sluggishness around Windows Presentation Foundation (WPF) and bugs in the automation models of the WPF command bars for VS add-ins have caused headaches for some people.

“For me, the main issue is XAML designer load performance, especially in a VPC [virtual PC],” says Stephen Forte, chief strategy offi cer of Telerik Inc. VPCs often lack the vector graphic video drivers and can slow down WPF and Silverlight, he points out.

“I can’t say it’s WPF that’s slowing it down, but it’s something to do with the rewrite. At the end of the day, I’m happy that [Microsoft] did this rewrite to bring Visual Studio’s code base into more modern technology,” Forte adds.

On Par with VS2008Despite performance issues, beta 2 shows considerable progress over beta 1, according to most accounts. “Beta 2 is defi nitely better than earlier builds in terms of performance and stability,” says Rockford Lhotka, principal technology evangelist for Magenic Technologies Inc. “They clearly have some way to go, though, to match VS2008. I think they understand that, as it’s the reason given for slipping the March release date they were talking about at PDC.”

VS

20

10

Will the Dev10 improvements be worth it if the result is slower performance?

VS2010 Release Candidate Expected this Month

Page 13: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

You’ve got the data, but time, budget and staffconstraints can make it hard to present that valuableinformation in a way that will impress. With Infragistics’NetAdvantage for Silverlight Data Visualization, youcan create Web-based data visualizations anddashboard-driven applications on Microsoft Silverlight(and coming soon for WPF) that will not only impressdecision makers, it actually empowers them. Go toinfragistics.com/sldv today and get inspired to createkiller apps.

Infragistics Sales 800 231 8588 Infragistics Europe Sales +44 (0) 800 298 9055 Infragistics India +91-80-6785-1111

Copyright 1996-2010 Infragistics, Inc. All rights reserved. Infragistics and the Infragistics logo and NetAdvantage are registered trademarks of Infragistics, Inc.

GeospatialMaps

SilverlightPivotGrids

FastDataCharts

Untitled-6 1 1/8/10 3:26 PM

Page 14: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

12 VISUAL STUDIO MAGAZINE · February 2010 · VisualStudioMagazine.com

</DevInsight>DEVELOPER NEWS

Telerik’s Forte also notes the great performance improvements between beta 1 and beta 2, but says he’s happy that Microsoft has delayed the fi nal release to work out some of the remaining kinks.

“I’m not too surprised about the performance issues—I think it has a lot to do with getting it to at least match the previous release,” says Rob Sanfi lippo, analyst, developer tools and strategy, Directions on Microsoft. “They’re probably getting beta feedback that it’s just not performing.”

Microsoft is making numerous changes in this release as it tries to move some of the technology to managed code, make better use of multithreading and debut a rebuilt interface that’s based on WPF.

“One of the things that they’re trying to do is scale it, so that you can deal with thousands and thousands of fi les,” says Sanfi lippo. “It’s kind of ironic, but I think that’s a separate segment of performance—I haven’t seen any feedback from developers who’ve tested scalability.”

The ambitiousness of the project has led some developers to suggest that Microsoft should have considered a three-year release cycle, instead of a two-year one. But Sanfi lippo believes Microsoft is responding to competition from open source environments such as Eclipse.

“Eclipse has the whole base of environments and add-ins, which makes it a lot more extensible,” Sanfi lippo says. “Microsoft’s concerned with competing with that, so extensibility is one of the big advances. The new interface is WPF, and it’s based on the Managed Extensibility Framework, so that it’s extensible and can do all the things that Eclipse off ers.”

Performance GainsEven with all these changes, Microsoft’s goal is to get the IDE to meet an acceptable performance level for fairly basic systems. Brian Harry, Microsoft technical fellow and product unit manager for Team Foundation Server, explained in his blog in January: “We’re really focused on taking a modest-class machine (a laptop-class hard drive, less than 2GHz CPU, 1GB of memory) and making sure it’s a pleasant experience to use. We’re also testing VMs [virtual machines] and Terminal server (with limited) bandwidth, etc. We’re testing quite a few confi gurations, but it’s all oriented toward making sure that whatever you’re doing, your experience is good.”

Harry noted that performance improved signifi cantly when moving from 1GB to 2GB of RAM, but additional memory yielded diminishing returns. In his blog, Harry also noted that a super-limited CTP 3 was slated for release in mid-January. At press time, it was unclear which VS2010 SKUs and tools would be made

available in the public RCs. VS2010 Ultimate and Team Foundation Server are defi nitely in the mix, according to Harry.

Developers will be able to uninstall beta 2 and install the RC without having to repave their machines, according to Microsoft. It’s important to note that even with the “go-live” license, the RCs are not “fully” supported. When the VS2010/.NET 4 RTMs become available, developers will have to upgrade to the RTM to receive “full” Microsoft support.

The RC will include a newer version of ASP.NET MVC 2 (preview 2 was in VS2010/.NET 4 beta 2). However, it still may not be compatible with the versions for VS2008 SP1—developers cannot currently run ASP.NET MVC 2 for VS2008 SP1 and VS2010 on the same machine—because ASP.NET MVC 2 requires functionality that’s not yet in VS2010/.NET 4. All versions will be compatible when the VS2010/.NET 4 RTM is released, according to Microsoft.

The VS2010 tooling for Windows Mobile 7 and smart devices will be released out-of-band in conjunction with the technology itself, according to Somasegar. Developers can expect to learn more about Windows Mobile 7 at the World Mobile Congress later this month and at MIX10 in March.

Guthrie also indicated that his team is working with the Windows Azure team to get .NET 4 installed on Windows Azure

as quickly as possible; he did not provide a time frame and the technology will need to be fi nal (RTM) before that happens. VS2010 Premium and higher editions—SKUs which require an MSDN subscription—include 750 Windows Azure compute hours for test and development and 10GB Windows Azure storage.

RC to RTMIn the end, will the productivity improvements in VS2010 be worth it, if it means slower coding?

“I think that a lot of people are speculating that it’s more serious than Microsoft is saying,” says Sanfi lippo. “But I don’t think that’s the case, because if it were, I don’t think they’d say that it’s [delayed by] a few weeks. I think that they probably have it under control. I expect the release to come out in the second quarter in 2010.”

A quality product is worth the wait, according to many developers. “I’d much rather see them slip the date a little than release a substandard product,” says Lhotka. “At the same time, I can hardly express how excited I am by the XAML designer capabilities. So as a XAML developer, the sooner they ship VS2010, the happier I’ll be.” VSM

Kathleen Richards ([email protected]) is executive editor of VSM.

VS

20

10

“For me, the main issue is XAML designer load performance, especially in a [virtual PC].” Stephen Forte, Chief Strategy Offi cer, Telerik Inc.

Page 15: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

VisualStudioMagazine.com · February 2010 · VISUAL STUDIO MAGAZINE 13

dyn

aTra

ce 3

.1

REVIEW

BY PETER VOGELWith most performance, logging and tracking tools you must instrument your application by adding code that writes to a trace log. dynaTrace is diff erent: It inserts hooks into the .NET runtime and passes the information to a separate server for you to review. Th is architecture allows dynaTrace to, for instance, track a transaction that begins with a JavaScript request—made through the ASP.NET ScriptManger—into a Web Service and the middle-tier business objects it calls, and, fi nally, to the SQL statements issued by your code (or even Entity Framework objects).

dynaTrace uses rule-based tracking that lets you specify what you want to record. You can specify that you want to look at particular packages, methods, application

types and more. Out of the box, dynaTrace tracks most everything. You can follow a path through a transaction and also gather “context information” for the transaction: parameter values passed to methods; method’s return value; any SQL statements issued to the database, along with any bound values; memory allocated and more. You also get visibility to actions within the methods through any calls made to framework objects.

Th e dynaTrace client provides multiple views of the data, including various table views and a UML sequence diagram that shows where control is passed off to the application’s components.

Integration with Visual Studio is minimal. If you have an app that generates an .EXE, you can launch it with tracing from the Tools menu. From the dynaTrace

client, you can navigate from an entry in a view to the related code fi le in your project.

dynaTrace is equally capable in production and development. You can do “diff s” to compare one run of a transaction against another to see if changes have made the app better or worse—and where. dynaTrace also integrates with Visual Studio Team System for Test, to facilitate comparing diff erent confi gurations of the same application. Run results are saved to a central repository for shared access.

dynaTrace expects you’ll spend a few days working with the company to implement the product. Even working with the excellent support staff , however, I had problems getting dynaTrace to track a transaction involving a Visual Studio Web site: the “projectless” dev model for ASP.NET applications. Looking ahead, dynaTrace has already done proof-of-concept testing on .NET 4 and has a pre-confi gured package for SharePoint developers, covering WebParts, Lists and CAML.

dynaTrace is an amazing product that helped me understand how my app worked in real-time. If you can aff ord it, you should be evaluating dynaTrace. VSM

Peter Vogel ([email protected]) is a principal in PH&V Information Services, specializing in ASP.NET development with expertise in SOA, XML, database and UI. His most recent book, “rtfm*: The Little Book on How to Write So You’ll Actually Get Read” (PH&V Information Services, 2008), is on writing effective user manuals; his blog on technical writing can be found at rtfmphvis blogspot.com.

dynaTrace Off ers End-to-End Multi-Tier TracingdynaTrace provides continuous monitoring of your application—from the client to the database—without requiring you to insert any instrumentation code.

dynaTrace 3.1

dynaTrace software

Web: www.dynatrace.com/en

Phone: 781-674-4000

Price: Developer Edition starts at $10,000

Quick Facts: Zero-instrumentation monitoring of application performance across tiers

Pros: Can track transactions across platforms—.NET and Java—and tiers

Cons: Cost; minimal integration with base version of Visual Studio

Figure 1. A dynaTrace PurePath beginning with a JavaScript call on the client to a Web Service and continuing into the middle-tier business object on the server. The highlighted area shows the SQL statement issued from the middle tier.

Page 16: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

14 VISUAL STUDIO MAGAZINE · February 2010 · VisualStudioMagazine.com

VSM COVER STORY

Why Silverlight 4 should change the way you make decisionsabout application development. BY MICHAEL DESMOND

Silverlight

Page 17: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

VisualStudioMagazine.com · February 2010 · VISUAL STUDIO MAGAZINE 15

it was day two of the recent Microsoft Professional Developers Conference (PDC) in Los Angeles, and the early reviews of the event were lukewarm at best. Microsoft had refined its guidance around Windows Azure cloud computing and produced some rehashed evangelism for Windows 7, but developers at the four-day confab were clamoring for something new. PDC, after all, was the event that launched .NET back in 2000 and the Windows Azure initiative in 2008.

As Andrew Brust, chief of new technology for consultancy twentysix New York and a Microsoft MVP and regional director, commented at the time: “This was the year that the ‘P’ in ‘PDC’ stood for practical.”

So credit Microsoft Corporate VP of the Developer Division Scott Guthrie for his game-saving bombshell during the second day keynote. Because when Guthrie announced the surprise release of the Silverlight 4 beta—the latest version of the Microsoft rich Internet application (RIA) platform and runtime—it immediately became the smash hit of the show.

“The Silverlight 4 stuff was huge!” enthused Stephen Chapman, author of the Microsoft Kitchen blog and a longtime Microsoft watcher who attended PDC. “I think Silverlight 4 will finally take Silverlight out of its Flash wannabe status and catapult it into its own respectable technology.”

Behind the excitement: An aggressive upgrade to the Silverlight platform that targets a host of long-lamented platform limitations, and thrusts the RIA technology firmly into the realm of mainstream

.NET development. With the release slated for the first half of 2010, it raises the question: Is it time to consider Silverlight as a legitimate vehicle for business-oriented .NET application development?

Taking Stock of Silverlight 4Todd Anglin, chief evangelist for leading component maker Telerik Inc., says Microsoft really started delivering the line-of-business goods with Silverlight 3. He singles out the addition of effective data binding support and .NET RIA Services, since renamed Windows Communication Foundation (WCF) RIA Services, as key capabili-ties for business development.

“A lot of what they delivered at PDC in Silverlight 4—improved access to the local file system, the ability to print in Silverlight, the ability to access the clipboard—all of these things are core line-of-business functions,” Anglin explains. “There are very few things you can point to now that would prevent you from creating line-of-business applications.”

Brian Goldfarb, director of the Developer Platform and Tools Group at Microsoft, says Microsoft focused on three areas when

building out the Silverlight 4 beta: rich media, business-application development and out-of-browser execution.

On the media side, Silverlight 4 added attractive capabilities like native webcam and microphone support, enhanced digital rights management (DRM) and media protection, and support for multi-cast streaming for efficient broadcast of digital media.

Perhaps most notable were the raft of improvements that break Silverlight out of the rich media penalty box. Silverlight 4’s out-of-browser execution capabilities bring the platform to parity with Adobe AIR, and enable apps to conform to familiar desktop deploy-ment models. Goldfarb singles out support for Silverlight “trusted applications” that provide access to local hardware devices as well as to Windows APIs for controlling application window size and posi-tion. Applications can now read and write to the local file system, make use of cross-site networking and support pop-up notification. Developers can also implement custom window chrome for unique and effective UI designs.

Finally, Goldfarb says Microsoft targeted functionality vital to busi-ness application development. Native printer support—long a target of developer complaint—has been added, as have important UI elements like drag-and-drop, right-click and mouse wheel support. The native rich text editor and support for internationalization, in par-ticular, appeal to developers serving large enterprises, Goldfarb says.

Other supported features in Silverlight 4 include implicit styling, HTML hosting for plug-in controls like Flash video, and updated data and networking functionality, including databinding enhance-ments and the updated WCF RIA Services stack, which promises to be critical for rapid application development on Silverlight.

Ultimately, Goldfarb says, Silverlight applications will reach beyond the desktop and Web to mobile devices and other sectors.

“We think that Silverlight becomes a common runtime across all these different device footprints,” he says.

There are also promised performance upgrades. Silverlight 4 will take full advantage of the just-in-time Common Language Runtime (CLR) compiler in .NET, potentially doubling performance of processor-intensive apps, according to Guthrie. Application start-up will also be significantly improved, while the new Silverlight Profiler API gives developers the ability to assess and optimize applications.

Visceral ResponseOne powerful argument for Silverlight as a unifying runtime is its use of Extensible Application Markup Language (XAML), the same

technology employed in Windows Presentation Foundation (WPF). Since launching Silverlight 1.0 in April 2007, Microsoft has talked about the benefit of sharing XAML code between Silverlight and WPF. With Silverlight 4, developers can compile code once and run the built assemblies on either the Silverlight 4 or .NET 4 runtimes. Five key assemblies enable code portability between Silverlight 4

tAscendant

Page 18: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

COVER STORY Silverlight

and WPF: Mscorlib, System, System.Core, System.Component-Model.Composition and Microsoft.VisualBasic.

Jeffrey Hammond, principal analyst at Forrester Research Inc., says the new capability will appeal in an era where apps are increas-ingly becoming “multi-channel,” providing similar services and user experiences across multiple computing and mobile platforms.

“I think we’ll see that idea pervade the enterprise over the next three years. That’s where I think the Silverlight/Flash/WPF approach starts to become a little interesting. I can create these XAML compo-nents and just use them as-is in my multi-channel software strategy,” Hammond says, noting that XAML gives Silverlight a “big advan-tage” over Flash.

The response in the developer community to the Silverlight release has been almost universally positive. Miguel de Icaza, vice president of developer platforms at Novell and head of the open source Mono Project, called Silverlight 4 “a case of doing the right thing for users and developers” in a blog post soon after the release.

“There are many other great features in Silverlight 4, but none as important as Silverlight becoming a universal runtime for the CLR. This is a revolution,” de Icaza wrote.

Hammond says Silverlight 4 flips the decision-making matrix for .NET dev shops. He says more and more dev shops should consider Silverlight 4 as the default runtime choice for desktop and Web development. “I think we’ve passed the inflection point with Silverlight 4,” Hammond notes.

Early returns on the beta bits delivered at PDC have been positive as well. Jason Beres, director of product management at component maker Infragistics, says his firm’s developers have been happy with what they’ve seen. “I honestly don’t think we’ve reported that many bugs,” Beres says. “It’s a very full-featured beta. It’s pretty solid. It’s very impressive how far they’ve gotten this thing.”

Evan Hutnick, developer evangelist at Telerik, calls the Silverlight 4 beta “very robust” and says it’s ready for developing on, despite a few quirks. He says Telerik customers working on Silverlight 4 proj-ects have been very impressed with the advanced rich-text editor and the printing and clipboard support. “People seem really confi-dent in this beta right now,” Hutnick says.

Chris Klug, senior Silverlight developer for consultancy Intergen Ltd. in New Zealand, says Microsoft has “done a great job so far” with the beta. He’s particularly impressed with the tooling support for Silverlight 4 in Visual Studio 2010. “I like the idea that the design view is now interactive and that you can use it for things you’d nor-mally do in Blend. I also love the improved support for XAML in the code view. It seems snappier and has a bit more help for those of us that like writing their own XAML,” he explains.

Klug’s one concern: That Microsoft sometimes focuses too much on “drag-and-drop functionality that few developers will want to use in real projects.”

Ben Dewey is a senior software developer at twentysix New York who has worked with Silverlight and WPF for years. He says

Silverlight 4 offers .NET developers a seam-less experience. “There’s really nothing that stops me in my daily life and makes me realize I’m not working directly with the .NET Framework. Everything I’m used to working with on a daily basis is there. I do a lot of LINQ stuff and all the LINQ features are available to me,” Dewey says.

Coupled, LooselyOne thing Silverlight 4 will certainly promote is the use of loosely coupled architectures. Silverlight employs the Model-View-View Model (MVVM) architectural pattern, which is based on the Model-View-Controller (MVC) pattern in ASP.NET MVC. MVVM eliminates “code behind” from the View layer so visual elements can be effectively managed by designers, while developers address the code logic in the View Model.

The separation of concerns enforced by MVVM can make for much more manageable and maintainable application code. Goldfarb says the ascendance of application lifecycle management and test-driven development has made such patterns vitally important.

Telerik RadGridView shows off the extended databinding capabilities in the Silverlight Designer for Visual Studio 2010.

“There’s really nothing that stops me in my daily life and makes me realize I’m not working directly with the .NET Framework. Everything I’m used to working with on a daily basis is there.”

Ben Dewey, Senior Software Developer, twentysix New York

16 VISUAL STUDIO MAGAZINE · February 2010 · VisualStudioMagazine.com

Page 19: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

Untitled-1 1 1/13/10 1:41 PM

Page 20: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

Dewey says the MVVM implementation in Silverlight 4 is “very clean,” but he worries there’s room for confusion as developers new to the approach struggle with Silverlight. “It’s kind of a disconnect. The samples are all code-behind, but best practices are all MVVM. It’s not trivial to make that conversion,” Dewey cautions.

He singles out Silverlight’s support for Managed Extensibility Framework (MEF), noting that it lets developers extend application interfaces using components that are discovered and compiled at runtime. “The loosely coupled kind of ability to do this is nice; these architectures that are separated but can get kind of discovered and compiled at runtime. It’s kind of cool,” Dewey says.

Another resource for Silverlight developers is WCF RIA Services. “WCF is the foundational glue for all our communication protocols,” says Microsoft’s Goldfarb. WCF RIA Services gives Silverlight devel-opers a way to implement—across tiers—common scenarios such as validation and databinding.

Peter Vogel, principal of PH&V Information Services and a fre-quent contributor to VSM, calls WCF RIA Services “the big story” of Silverlight 4. “Effectively, it reduces Web Services to what it should be: plumbing. The goal is to make creating distributed Web Service applications as easy as creating Access applications,” Vogel says.

Telerik’s Anglin says the value of WCF RIA Services boils down to one word: productivity. “If productivity is your primary driver and you’re doing a relatively standard line-of-business application, then the tradeoff is greatly in your favor in terms of the amount of time [WCF RIA Services] is going to save you and the features it will deliver under budget,” Anglin says. “The WCF Services layer—the automation of that—really is the productivity story here.”

Dewey, however, warns that WCF RIA Services isn’t for every project. “We put it all in for an application that didn’t really need it and ended up fighting it the whole time. There’s too much hand holding and too much code generation for my personal preference,” Dewey says. “If you’re doing a simple CRUD [create, read, update and delete] application I think it works great. Once you get out of the realm of a one-tier CRUD application, I don’t think it works well.”

The Mobile StoryIf Silverlight 4 has a weak flank, it’s the lack of a well-articulated mobile vision.

“This is where I think Flash today is better than Silverlight. The Adobe strategy has been pretty powerful in terms of making connec-tions with different platforms,” says Al Hilwa, program director for Application Development Software at IDC. “I think that actually the Silverlight team will probably have better support for devices in the next couple years.”

Hilwa also looks at developments like Microsoft adding support in Silverlight 4 for the Google Chrome browser as a sign that Microsoft “will not let anyone stop them.”

Microsoft’s Goldfarb says the company will provide detailed mobile guidance for Silverlight development at the MIX10 event in

Las Vegas, March 15-17. He says Microsoft is looking to support a variety of mobile platforms—including the Google Android, the Research In Motion BlackBerry and the Apple iPhone—and that Silverlight will provide a uniquely compelling developer experience for cross-platform applications.

“We’ll have Silverlight running on [many] devices. It’s the same code, it’s the same tool—it’s identical. The work involved is literally customizing the front-end UI for the devices themselves and for the keyboard, and then taking advantage of platform-specific exten-sions,” Goldfarb says. “You’ll have the ability to optimize for the unique characteristics of the device itself.”

The rapid turnover of the Silverlight code base is also cause for con-cern. There have been four iterations of Silverlight released, including the Silverlight 4 beta, since Silverlight 1.0 went final in April 2007. Silverlight 4 is expected to go live in the first half of 2010. The heady pace may not suit larger companies that rely on stable platform releases.

“Enterprises don’t typically like to live on the bleeding edge,” says Anglin. “Certainly, people I talk to in the community would like to see a leveling-off of the pace.”

“It’s a careful balance we have to find,” responds Goldfarb. “The speed and innovation is a market-introduction pace.”

Goldfarb says Silverlight 4 includes a Quirks Mode that provides full compatibility for Silverlight 3 applications running in the newest runtime. Backwards-compatibility for older Silverlight apps will be a feature of future Silverlight runtimes “ad infinitum,” he says.

Concerns about platform updates aside, Goldfarb says Silverlight has earned a series of key wins over the past year, including a financial visualization app integrated into Bloomberg terminals and a factory operations-automation app developed by Rockwell Automation Inc.

Silverlight

The SnapFlow application, demoed at PDC, shows how trusted Silverlight applications can read and write files to a system’s MyDocuments, MyMusic, MyPictures and MyVideos folders, and access devices via COM automation.

“A lot of what they delivered at PDC in Silverlight 4—improved access to the local fi le system, the ability to print in Silverlight, the ability to access the clipboard—all of these things are core

line-of-business functions.” Todd Anglin, Chief Evangelist, Telerik Inc.

18 VISUAL STUDIO MAGAZINE · February 2010 · VisualStudioMagazine.com

COVER STORY

Page 21: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

“These deployments were all done on the latest version of Silverlight, Silverlight 3. That was a big inflection point. That was where these capabilities were really turned on,” Goldfarb says.

Getting up to SpeedWhen it comes to selling Silverlight development, Microsoft preaches the benefits of a common tool stack, familiar languages and a matured .NET skill set. Still, dev shops looking to move to Silverlight 4 face a learning curve.

Forrester’s Hammond says developers may struggle as they delve into the realm of service-based and RESTful architectures employed by Silverlight. “I can’t just take the skills I learned with VB6 and VB.NET and run,” he says. “Fortunately, it’s not as big as the jump from procedural to object-oriented programming.”

Dev shops that intend to deliver Silverlight apps over the wire also need to avoid needless calls to redundant libraries or use of custom code that duplicates functionality in the base runtime, says twentysix New York’s Dewey. He says the first thing he does with Silverlight projects is review references, which often point to packages and libraries that aren’t needed for the app and result in increased down-load size. He singles out references to system.net and system.web.browser. His advice for streamlined app delivery: “Do everything you can with the Silverlight toolkit and the stuff that’s in the box.”

Infragistics’ Beres urges developers to start working with VS2010 right away, and to fully understand how app data is accessed and

designed to avoid running into a wall after moving to Silverlight 4. Telerik’s Hutnick, meanwhile, warns developers that finding useful, up-to-date coding help for Silverlight can require detective skills.

“It comes down sometimes to following the right people on blogs or on Twitter,” says Hutnick, who recommends Jesse Liberty’s Silverlight Geek blog (http://blogs.silverlight.net/blogs/jesseliberty) as well as Brad Abrams’ blog for information about WCF Services (http://blogs.msdn.com/brada/default.aspx). John Papa’s blog on Silverlight (http://johnpapa.net) is another useful destination.

“As a new developer, if you’re not aware of these guys you might get lost trying to find new information,” Hutnick says.

Other resources include the newly launched Silverlight Web site at Microsoft.com/Silverlight, as well as the Silverlight developer community site at Silverlight.net.

Ultimately, the single most important bit of advice might come from Forrester’s Hammond, who takes a big-picture view of the chal-lenge facing dev shops.

“I think the biggest thing is to really look at a rich Internet application client as your default choice, and then force your developers to justify why you need to go beyond that,” Hammond says. “Basically say, ‘unless you give me a compelling reason, we’re going with RIAs because they’re easier to deploy and give us cross-platform capability, and give us a better user experience for our users, who are increasingly mobile.’” VSM

Michael Desmond ([email protected]) is editor in chief of VSM.

Media■ Webcam and microphone support■ Multicast streaming■ Output protection and offline digital rights management support■ Updates to IIS Media Services and IIS Smooth Streaming, which

will enable the 2010 Winter Games on NBCOlympics.com■ Back-end support for IIS Media Services on the iPhone

Business Applications■ Printing support■ Rich-text editor (supports multiple languages, left-to-right text

and copy/paste)■ Right-click and mouse wheel support■ Implicit styling■ Drag/drop support■ Bidi and right-to-left support for global applications■ HTML hosting (can host plug-in controls like Flash video)■ Commanding and Model-View-View Model (MVVM) controls

Data and Networking Functionality■ Databinding improvements■ UPD multicast support■ REST enhancements through ADO.NET services■ Updates to Windows Communication Foundation RIA Services

(formerly .NET RIA Services)

Beyond the Browser■ New sandboxed features (windowing APIs, notification pop-ups)■ Introduces “trusted applications”■ Custom window chrome■ Utilizes local file system■ Uses cross-site networking■ Enables a full-screen keyboard■ Provides hardware device access■ Provides access to Windows 7 APIs

SOURCE: MICROSOFT

New in Silverlight 4The new features in Silverlight 4 are extensive and span the gamut from rich media playback to improved databinding and enhanced local system resource access. Here’s a rundown of new features in the Silverlight 4 beta.

“We’ll have Silverlight running on [many] devices. It’s the same code, it’s the same tool—it’s identical. The work involved is literally

customizing the front-end UI for the devices themselves and for the keyboard, and then taking advantage of platform-specifi c extensions.”

Brian Goldfarb, Director, Development Platforms and Tools Group, Microsoft

VisualStudioMagazine.com · February 2010 · VISUAL STUDIO MAGAZINE 19

Page 22: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

ILLU

STR

ATIO

N B

Y RY

AN

ETT

ER

20 VISUAL STUDIO MAGAZINE · February 2010 · VisualStudioMagazine.com

ILLU

STR

ATIO

N B

Y SH

UTT

ERST

OCK

In every codebase, there are the dark corners and alleys you fear. Code that’s impossibly brittle; code that bites back with regression bugs; code that when you attempt to follow, will drive you mad.

Ward Cunningham created a beautiful metaphor for the hard-to-change, error-prone parts of code when he likened it to financial debt. Technical debt prevents you from moving forward, from profiting, from staying “in the black.” As in the real world, there’s cheap debt, debt with an interest lower than you can make in a low-risk financial instrument. Then there’s the expensive stuff, the high-interest credit card fees that pile on even more debt.Technical debt is a drag. It can kill productivity, making maintenance annoying, difficult, or, in some cases, impossible. Beyond the obvious economic

downside, there’s a real psychological cost to technical debt. No developer enjoys sitting down to his computer in the morning knowing he’s about to face impossibly brittle, complicated source code. The frustration and helplessness thus engendered is often a root cause of more systemic problems, such as developer turnover—just one of the real economic costs of technical debt.

Every codebase I’ve worked on or reviewed contains some measure of technical debt. One class of debt is fairly harmless: byzantine dependencies among bizarrely named types in stable, rarely modified recesses of your system. Another is sloppy code that is easily fixed on the spot, but often ignored in the rush to address higher-priority problems. There are many more examples.

Flawed code is a lot like fi nancial debt. It drags you down and consumes resources that would otherwise go to profi t-making ventures. Here’show to avoid getting caught in the technical debt trap. BY DAVID LARIBEE

AGILE TECHNIQUES TO PAY BACK TECHNICAL DEBT

Using

Content provided by MSDN Magazine, Microsoft’s premier publication for developers.

Page 23: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

VisualStudioMagazine.com · February 2010 · VISUAL STUDIO MAGAZINE 21

FEATURE

ILLU

STR

ATIO

N B

Y SH

UTT

ERST

OCK

Page 24: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

22 VISUAL STUDIO MAGAZINE · February 2010 · VisualStudioMagazine.com

FEATURE Technical Debt

This article outlines a workflow and several tactics for dealing with the high-interest debt. The processes and practices I’ll detail aren’t new. They are taken straight from the Lean/Agile playbook.

The Case for Fixing DebtTechnical debt works against your goals because it slows you down over time. There’s a well-known visualization called the cost of change curve (see Figure 1), that illustrates the difference between the 100-percent-quality-test-driven approach and the cowboy-coder-hacking-with-duct-tape approach.

The cost of change curve illustrates that high quality, simple, and easy to follow designs may cost more initially, but incur less tech-nical debt—subsequent additions and modifications to the code are less costly over time. In the quality curve (blue), you can see the initial cost is higher, but it’s predictable over time. The hack-it curve (red) gets a lower cost of entry, but future development, mainte-nance, and the total cost of owning a product and its code becomes ever more expensive. Simply put, technical debt will decrease the throughput of your team over time.

Systems ThinkingIn order to fix technical debt, you need to cultivate buy-in from stakeholders and teammates alike. To do this, you need to start thinking systemically. Systems thinking is long-range thinking. It is investment thinking. It’s the idea that effort you put in today will let you progress at a predictable and sustained pace in the future.

Perhaps it’s easiest to explain systems thinking with an analogy. I live in downtown Atlanta, Georgia, in a quaint little neighborhood called Inman Park. I’m mostly very happy there. I reserve, however, some irritation related to the seemingly complete ignorance of urban planning. The streets in Atlanta are byzantine, maze-like, madness-provoking. When you miss your turn, you can’t simply loop back. If you do, you’ll be sent on a spiraling path to who-knows-where. There seems to be little rhyme or reason to the planning of roads in this otherwise very pleasant corner of the world.

Contrast this with the orderly streets and avenues of Manhattan in New York City (most of it, anyway). It’s as if a Marine Corps drill instructor designed the city. Avenues stretch the length of the island, north to south, and streets form tidy, latitudinal markers down its length. Furthermore, both streets and avenues are named

in numerical sequence: First Avenue, Second Avenue, 42nd Street, 43rd Street and so on. You’ll rarely walk more than a block in the wrong direction.

What are the root causes for the difference between Atlanta and New York City in this dimension of comparison?

In Atlanta the streets were formed by cattle wearing down paths. You heard me right, cattle paths. Some need arose to frequently move between the urban center and the suburbs, at which point some cowboy thought, “Golly, wouldn’t it be easiest to turn these here cattle paths into roads?”

The New York State Legislature applied vision and forethought to the design of the ever-growing and largest city in the state. They chose the gridiron plan, with orderly, predictable streets and avenues. They were thinking of the future.

This story gets to the essence of systems thinking. While legislative processes are slow, investment in time and commitment to vision pays the greatest dividend for the lifetime of a system. True, you’ll have to deal with crazy cabs on the mean streets of Manhattan, but you’ll be able to find your way around in a matter of days. In Atlanta, it’s been a year of getting lost, and I thank the system thinkers responsible for the Global Positioning System (GPS) each and every day.

Products over ProjectsThe idea that you have a development team that completes a project then throws it over the wall to a maintenance team is fundamentally flawed. Make no mistake, you are working on a product and if it suc-ceeds, it’s going to live a long, long time.

If you have even a couple of years of experience as a professional developer, you’ve probably experienced the increasing gravity effect. You develop a piece of software that isn’t meant to last or be compli-cated or change. And six months later, what are you doing? Modifying it? Extending it? Fixing bugs?

Useful software has a sometimes-nasty habit of sticking around for a very long time. It’s up to you to pick the metaphor you want to roll with. Will you tend a forest of beautiful California Redwoods, living entities enduring the centuries and reaching the highest heights, or will you allow the relentless Kudzu vine to starve your forest of light?

Basic WorkflowNo matter the shop, my sense is that the basic workflow for tackling technical debt—indeed any kind of improvement—is repeatable. Essentially, you want to do four things:

1. Identify where you have debt. How much is each debt item affecting your company’s bottom line and team’s productivity?

2. Build a business case and forge a consensus on priority with those affected by the debt, both team and stakeholders.

3. Fix the debt you’ve chosen head on with proven tactics.4. Repeat. Go back to step 1 to identify additional debt and hold

the line on the improvements you’ve made.It’s worth mentioning, for the software process nerds out there that

this workflow is adapted from a business management approach called the Theory of Constraints (ToC) created by Eliyahu Goldratt (goldrattconsulting.com). ToC is a systems-thinking model that pro-

Technical debt is a drag. It can kill productivity, making maintenance

annoying, diffi cult, or, in some cases, impossible.

Rapid-but-Untested Coding

Time109876543210

01

2

3

4

5

6

7

8

9

10

Simple, Test-Driven Designs

Cost

Figure 1. Cost of change curve.

Page 25: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

VisualStudioMagazine.com · February 2010 · VISUAL STUDIO MAGAZINE 23

FEATURE

vides a framework for improving the overall throughput of the system. This is a gross simplification, but ToC is predicated on the idea that a system (a manufacturing facility, for example) is only as productive as its biggest bottleneck. Value, such as a feature request or automobile or any sellable item, is conceived of, designed, produced and deployed. A feature may be requested by a customer, internal or external, and that feature flows through your business (the system), transforming from an idea to a tangible result. What happens when these features pile up in front of your quality assurance team? What happens when there’s more demand for development than a development team can fulfill? You get a bottleneck and the whole system slows down.

It’s likely you have many areas of debt—many bottlenecks—in your codebase. Finding the debt that slows you down the most will have the greatest net effect on increasing your throughput. Understanding, then tackling debt and resulting improvements as a team—as a system—is the most effective way to make positive change, because more eyes and hands on the code equates to less risk and better designs.

Identify Areas of DebtIt’s important that you be able to point at the problem areas. If you haven’t been keeping track of them on a wiki or a shared list or in code comments, your first task is to find the debt.

If you’re working on a team, I suggest calling a meeting to develop a concrete list of the top areas of debt in your code. An exhaustive list isn’t important. Focus on capturing the big-ticket items. This meeting is your first opportunity, as a leader on your team, to start forging consensus. A more-than-simple majority of members should agree and understand an item for it to make the list.

Once you have the list, make it durable. Create a wiki topic, write it on a whiteboard (with “DO NOT ERASE” written prominently in one corner), or whatever works in your situation. The medium you choose should be visible, permanent and easy to use. It should be in your face on a regular basis. You need to return to this list and groom it. Human beings have a limited amount of short-term memory, so I suggest keeping a list of between five and nine of the most bothersome items. Don’t worry so much about keeping an inventory—important items will surface again if they’re really, well, important.

Using Metrics to Find Trouble AreasSometimes it’s hard to find debt, especially if a team is new to a code-base. In cases where there’s no collective memory or oral tradition to draw on, you can use a static analysis tool such as NDepend (ndepend.com) to probe the code for the more troublesome spots.

Tools are, at best, assistive or perhaps even a second choice. Tools won’t tell you what to do—but they will give you inputs to decision-making. There is no single metric for code debt, but people who work on a product day in and day out can surely point to those dark corners that cause the most pain. Static analysis tools will tell you where you have implementation debt. Sadly, they will not tell you where you have debt due to factors like poor naming, discoverability, performance and other more qualitative design and architectural considerations.

Knowing your test coverage (if you have tests) can be another valu-able tool for discovering hidden debt. If there’s a big part of your system that lacks solid test coverage, how can you be certain that a change won’t

have dramatic effects on the quality of your next release? Regression bugs are likely to appear, creating bottlenecks for QA and potential embarrassment and loss of revenue due to customer-found defects.

Use the log feature of your version control system to generate a report of changes over the last month or two. Find the parts of your system that receive the most activity, changes or additions, and scru-tinize them for technical debt. This will help you find the bottlenecks that are challenging you today; there’s very little value in fixing debt in those parts of your system that change rarely.

Human BottlenecksYou might have a bottleneck if there’s only one developer capable of dealing with a component, subsystem, or whole application. Individual code ownership and knowledge silos (where “Dave works on the Accounts Receivables module”—now there’s a painful memory), can block delivery if that person leaves the team or has a pile of other work to do. Finding places in your project where individual ownership is happening lets you consider the benefits and scope of improving the design so other individuals can share the load. Eliminate the bottleneck.

There are tremendous benefits that derive from the eXtreme Pro-gramming practice of collective ownership (extremeprogramming.org/rules/collective.html). With collective ownership, any developer on your team is allowed to change any code in your codebase “to add functionality, fix bugs, improve designs or refactor. No one person becomes a bottleneck for changes.”

Ah! There’s that word again, “bottleneck.” By enabling collective ownership, you eliminate the dark parts of your system that only a single programmer—who may walk off the job or get hit by a bus—knows about. There is less risk with a codebase that’s collectively owned.

In my experience, the design is also much better. Two, three or four heads are almost certainly better than one. In a collectively owned codebase, a team design ethos emerges and supplants indi-vidual idiosyncrasies and quirks.

I call collective code ownership a practice, but collective owner-ship is really an emergent property of a well-functioning team. Think about it—how many of you show up and work on “your code” versus code shared by an entire team? What are often called teams in soft-ware development are really workgroups with an assignment editor, where programming tasks are doled out based on who’s worked on a particular feature, subsystem or module in the past.

Prioritize as a TeamI’ve said before that it’s important you involve the whole team in efforts to improve. As an Agile Coach, I hold closely to the mantra that people support a world they help to create. If you don’t have a critical mass of support, an effort to foster a culture of continuous improve-ment can be very difficult to get off the ground, much less sustain.

Obtaining consensus is key. You want the majority of team members to support the current improvement initiative you’ve selected. I’ve used with some success Luke Hohmann’s “Buy a Feature” approach from his book Innovation Games (innovationgames.com). I’ll attempt a gross over-simplification of the game, and urge you to check out the book if it seems like something that’ll work in your environment.

Obtaining consensus is key. You want the majority of team members

to support the current improvement initiative you’ve selected.

Page 26: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

24 VISUAL STUDIO MAGAZINE · February 2010 · VisualStudioMagazine.com

FEATURE Technical Debt

1. Generate a short list (5-9 items) of things you want to improve. Ideally these items are in your short-term path.

2. Qualify the items in terms of difficulty. I like to use the abstract notion of a T-shirt size: small, medium, large or extra-large (see

“Estimating Improvement Opportunities,” this page, for more infor-mation on this practice).

3. Give your features a price based on their size. For example, small items may cost $50, medium items $100 and so on.

4. Give everyone a certain amount of money. The key here is to introduce scarcity into the game. You want people to have to pool their money to buy the features they’re interested in. You want to price, say, medium features at a cost where no one individual can buy them. It’s valuable to find where more than a single individual sees the priority since you’re trying to build consensus.

5. Run a short game, perhaps 20 or 30 minutes in length, where people can discuss, collude, and pitch their case. This can be quite chaotic and also quite fun, and you’ll see where the seats of influence are in your team.

6. Review the items that were bought and by what margins they were bought. You can choose to rank your list by the purchased features or, better yet, use the results of the Buy a Feature game in combination with other techniques, such as an awareness of the next release plan.

Sell the PlanNow that you’ve got a plan, it’s time to communicate the value of elimi-nating debt to your project sponsors. In reality, this step can happen in parallel with identification. Involve your customer from the very begin-ning. After all, development of the plan is going to take time, effort, and (ultimately) money. You want to avoid, at all costs, questions about whose time and dime you spent developing a cohesive plan.

Any successful and sustained effort to remove a large amount of debt absolutely requires the support of your project’s financiers and spon-sors. The folks who write the checks need to understand the investment you’re making. This can be a challenge; you’re asking people to think in long range, into the future, and to move away from the buy now, pay later mentality. The explanation “just because” simply doesn’t cut it.

The problem with this is that executives will inevitably ask, “Aren’t you professionals?” You might feel put against the ropes when probed along these lines. After all, weren’t they paying you, the pro, to deliver a quality product on time and in budget?

This is a tough argument to counter. I say, don’t bother. Have the courage and honesty to present the facts as they are. This seemingly risky approach boils down to human issues of accountability and trust.

Couch your argument like this: you’ve fielded successful software in the requested amount of time for a provisioned amount of money. In order to achieve this you’ve had to make compromises along the way in response to business pressures. Now, to go forward at a pre-dictable and steady rate, you need to deal with the effects of these compromises. The entire organization has bought them, and now it’s time to pay back.

Your next challenge is to prove to non-technical folks where the debt is causing the most damage. In my experience, business execu-tives respond to quantitative, data-driven arguments supported by

“numbers” and “facts.” I put numbers and facts in quotes because we all really know we’re living in a relative world and no single number (cyc-lomatic complexity, efferent coupling, lines of code, test coverage, what have you) sells a change. Compounding this difficulty, you’ll need to communicate the areas of biggest drain in economic terms: why is this slower than you’d like; why did this feature cost so much?

Evidence DEFEATS DoubtWhen building your case, there’s a useful tool from the Dale Carnegie management training system embodied in a pithy phrase, “evidence defeats doubt.” As is common with such management systems (and our discipline in general), the DEFEATS part is an acronym. I’ll detail some of the ways in which this applies to software development. Note, how-ever, that I’ve omitted the second E, which stands for Exhibit because it seems to repeat the first E, which stands for Example.

D is for Demonstration. There’s nothing better than show and tell and this is what the demonstration is all about. If you’re tracking your velocity, this should be easy. Show the dip over time (see Figure 2) while drawing the connection to increasingly inflexible and hard-to-change code. Once you sell, you need to keep selling.

If you’re using an Agile process such as Scrum or eXtreme Program-ming, customer feedback events are an essential practice. At the end of

Estimating ImprovementOpportunitiesI mentioned estimating debt items or improve ment opportuni-ties roughly in terms of T-shirt sizes. This is a common technique used in Agile development methodologies. The idea is that you’re collecting things in terms of relative size. The smalls go together as do the mediums, larges and so on.

It’s not super-important that you bring a lot of accuracy to the table here. Remember, these are relative measures and not commitments. You want to get a rough idea of the difficulty, and the theory is that after estimating a number of items, things will start to even out. Even though one medium item actually takes a pair of developers two weeks to complete while another takes a month, on average a medium will take about three weeks.

Over time, however, you’ll start to gather good examples of what a large or small item really is, and this will aid you in future estimates because you’ll have a basis of comparison. I’ve used several examples of the various sizes in the past as an aid for estimating a new batch of work to good effect.

This can be a tough pill to swallow for management. They’ll initially want to know exactly how long a thing might take and, truth be told, you might need to invest more time in a precise, time-based estimate.

—D.L.

Use the log feature of your version control system to generate a

report of changes over the last month or two. Find the parts of your

system that receive the most activity, changes or additions, and

scrutinize them for technical debt.

Page 27: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

FEATURE

VisualStudioMagazine.com · February 2010 · VISUAL STUDIO MAGAZINE 25

an iteration, demonstrate new features to your customer. While the quality and quantity of features will dip when you encounter the tech-nical debt tar pits and while you ramp up your improvement efforts, you should be able to demonstrate gains over time. Less debt means greater output and greater output yields more stuff to demonstrate.

As the idiom goes, before you criticize someone, walk a mile in their shoes. If you have a more-technical manager, encourage her to work with developers on some of the more difficult sections of the codebase to develop empathy for the difficulty of change. Ask her to look at some code. Can she follow it? Is it readable? There’s no quicker way to win your champion.

E is for Example. There’s nothing like a concrete example. Find some stories or requirements that were either impossible to com-plete because of technical debt, or created significant regression. Pick a section of code that’s unreadable, byzantine, riddled with side-effects. Explain how these attributes of the code led to a customer-found defect or the need for massive effort from QA.

Another powerful tool the Agile processes give you is the retrospec-tive. Choose a story that went south in the last couple of iterations and ask the question “why?” Get to the root cause of why this particular story couldn’t be completed, took twice as long as your average story, or spanned more than a single iteration. Often, inflexible software will be the culprit or perhaps you had to revert changes because regression bugs were insurmountable. If you find the last “why” ends up being a technical debt-related reason, capture the analysis in a short, direct form. It’s another feather in your cap, another point in your argument.

F is for Fact. Facts are very easy to come by. Did you release a project on time? What was the post-release defect rate? What is the team’s average velocity over time? Were customers satisfied with the software as delivered? These are the kind of facts you’ll want to bring to the business table, and I believe it’s these facts that speak most directly to business-minded.

Collaboration is a key element here. As a developer, you can more readily supply technical facts. Look for assistance from the people that own the budgets. Chances are they’ll have a much clearer pic-ture and easier access to the business facts that demonstrate the damage that technical debt is causing.

A is for Analogy. I find this especially important. Business people sometimes find software development confusing, even esoteric. If you go to your sponsors with talk of coupling and cohesion and Single Responsibility Principle, you stand a very good chance of losing them. But these are very important concepts in professional software development and, ultimately, it’s how you’re building a data-driven case for tackling debt. My suggestion is to avoid jargon and explain these items with an analogy.

You could describe coupling as a house of cards, for example. Tell your sponsors that the reason your velocity has dropped is because making change to the code is like adding a wall, ceiling, or story to an already established and very elaborate house of cards: a surgical operation requiring an unusually steady hand, significant time and patience, and is ultimately an uncertain and anxiety-provoking event. Sometimes the house of cards collapses.

When employing metaphor and simile, it’s a good idea to state you are doing so. Justify your analogy with a brief description of the more-technical concept you are trying to convey. Using the house of cards example, you might say, “this is the effect that coupling has on our ability to respond to change and add new features.”

T is for Testimonial. Sometimes hearing the same message from a third party can have a more powerful effect. This third party may

be an industry leader or a consultant. The reason their word might go farther than yours is that they’re perceived as an objective expert.

If you don’t have the money to hire an outside consultant, consider collecting anecdotes and insight freely available from industry thought leaders. While generic testimonials about so-called best practices are unlikely to seal the deal, they will add to the gestalt of your overall argument.

S is for Statistics. Numbers matter. There’s a common phrase in management: “If you can’t measure it, you can’t manage it.” I’m not sure this conventional wisdom applies wholly, but you can certainly present a case. Coupling and complexity are two metrics that can be used to show a root-cause relationship between a declining throughput (how much work is being delivered) and a codebase increasingly calcified with debt. I find that composite statistics are usually the best bet here; it’s much easier to understand the importance of code coverage if you can overlay a code coverage metric that decreases over time with a decrease in velocity, thus implying, if not showing, a relationship.

Appoint a LeaderYour efforts to procure a green light for fixing technical debt will go a lot longer with an effective leader, a champion who can communi-cate in business terms and who has influence with the decision makers in your organization. Often, this will be your manager, her director, the CTO, the VP of Engineering, or someone in a similar position of perceived authority.

This brings up an interesting chicken and egg problem. How do you sell this person? The process of “managing up” is a developer’s responsibility, too. Your first challenge is to sell the seller. How exactly do you do that? Evidence defeats doubt!

Next StepsSo far I’ve covered identifying debt as a team and building a case for fixing that debt. I’ll reiterate: consensus among your team and buy-in with your customers are key factors in these steps.

Make the steps small and don’t invest a lot of time. The first time you identify debt, it will necessarily take longer than when you iterate over new opportunities for improvement, but when you build your case for management, only include those items you plan to work on. Keeping an eye on productivity can be a huge energy saver. VSM

Dave Laribee coaches the product development team at VersionOne. He is a frequent speaker at local and national developer events and was awarded a Microsoft Architecture MVP for 2007 and 2008. He writes on the CodeBetter blog network at thebeelog.com.

0

1

2

3

4

5

6

7

JulyJan Feb Mar Apr May Jun

Figure 2. Tracking development velocity.

Page 28: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

Untitled-1 1 1/19/10 2:41 PM

Page 29: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

Untitled-1 1 1/19/10 2:42 PM

Page 30: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

Give your users an effective way to visualize and analyze their data

so they can make more informed decisions and solve business problems.

By subscribing to the ESRI® Developer Network (EDNSM), you have access to the complete ESRI

geographic information system (GIS) software suite for developing and testing applications on

every platform. Whether you’re a desktop, mobile, server, or Web developer, EDN provides the

tools you need to quickly and cost-effectively integrate mapping and GIS into your applications.

Subscribe to EDN and leverage the power of GIS to get more from your data. Visit www.esri.com/edn.

ESRI®

Developer Network Integrate Mapping and GIS into Your Applications

Copyright © 2009 ESRI. All rights reserved. The ESRI globe logo, ESRI, EDN, and www.esri.com are trademarks, registered trademarks, or service marks of ESRI in the United States, the European Community, or certain other jurisdictions. Other companies and products mentioned herein may be trademarks or registered trademarks of their respective trademark owners.

Project4 12/7/09 11:21 AM Page 1

Page 31: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

AS

P.N

ET

4

</Language Lab>YO U R CO D E S O U RC E

{ PRACTICAL ASP.NET }

IN THIS SECTION: Practical ASP.NET · 29 // Ask Kathleen · 34 //////////////

The QueryExtenderExtend runtime sorting and fi ltering of data with ASP.NET 4’s QueryExtender, which provides a single interface for DataSources. BY PETER VOGEL

As far as ASP.NET developers are concerned, the Microsoft .NET Framework 3.0 and 3.5 were effectively “no upgrade” releases, with the exception of two controls: the DataList and Pager. The .NET Framework 4, on the other hand, offers a number of new features aimed directly at a key issue for ASP.NET developers building business applications and managing data. The most interesting is the QueryExtender, which does two things. First, it substantially extends what filtering and sorting you can do with the LinqDataSource and the EntityDataSource. Second, it makes the two DataSources look alike when it comes to specifying what data you want.

The LinqDataSource didn’t provide much runtime flexibility when it came to retrieving data at runtime based on the user’s input—you had to make most of your decisions at design time. The solutions you could apply were primarily procedural and code-driven: there wasn’t a powerful, declarative, codeless option available. When you could take action at runtime, LinqDataSource and EntityDataSource required very different solutions.

The QueryExtender simplifies data management by providing a single declarative syntax for filtering data, regardless of DataSource. You just add the QueryExtender to your page, tie it to a DataSource and specify which options in the QueryExtender you want to take advantage of. You can sort the output from your DataSource and filter it based on the content of the user’s entries on the page. Any DataView attached to the DataSource will reflect the results of your settings in the QueryExtender.

Figure 1 shows a QueryExtender page with a GridView and a DetailsView both tied to a LinqDataSource. The results in the GridView are filtered by the values that the user enters into the text boxes on the screen. The data is sorted by options selected in the QueryExtender.

In theory, the QueryExtender supports both the LinqDataSource and the EntityDataSource. In practice … not so much. For the QueryExtender to work with a DataSource, the DataSource must implement the IQueryableDataSource and—as of beta 2—only the LinqDataSource supports the interface. In the sample application in the download for this article, I’ve included a selection of DataSources that you can use to test for compatibility with the QueryExtender as .NET 4 rolls out.

Sorting with the QueryExtenderAs of beta 2, there’s no visual designer for QueryExtender and the control doesn’t appear in Visual Studio 2010’s Toolbox. If you want to experiment with the QueryExtender, you’ll need to do it in Source View. Your first step is to add the QueryExtender to a page and specify the DataSource to extend using the QueryExtender’s TargetControlId property. This example ties a QueryExtender to a DataSource called LinqDataSource1:

<asp:QueryExtender ID="QueryExtender1" runat="server" TargetControlID="LinqDataSource1">

The simplest way to use the QueryExtender is to have it sort data. You can do that just by adding the OrderByExpression element inside the QueryExtender. This example sorts the data returned by the DataSource in descending order using the CourseNumber property on the objects returned by the DataSource:

<asp:QueryExtender ID="QueryExtender1" runat="server" TargetControlID="LinqDataSource1"> <asp:OrderByExpression DataField="CourseNumber" Direction="Descending" /></asp:QueryExtender>

If, at this point, you find that you’re getting an “unknown server tag” message, you’ll need to add this tag to your web.config file inside the controls element inside the pages element:

<pages> <controls> <add tagPrefix="asp" namespace="System.Web.UI.WebControls.Expressions"

VisualStudioMagazine.com · February 2010 · VISUAL STUDIO MAGAZINE 29

Figure 1. The results in the GridView are limited by the user’s entries into the text box to show only courses beginning with the word “Developing.”

Page 32: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

{ PRACTICAL ASP.NET }

AS

P.N

ET

4

assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

To sort by additional fields, you can add ThenBy tags within the OrderByExpression element. This example sorts the data by Descrip-tion when there are two elements with the same CourseNumber:

<asp:OrderByExpression DataField="CourseNumber" Direction="Descending"> <asp:ThenBy DataField="Title" Direction="Ascending" /></asp:OrderByExpression>

The usual limitations on sorting very large fields still apply: You can’t, for instance, sort on SQL Server Text fields.

Filtering Data by RangeBeyond just sorting your data, the QueryExtender lets you filter it by the value of fields retrieved through your DataSource. The easiest way to filter data is to use the RangeExpression element, which lets you specify a maximum and minimum value for any field in your results. You also supply parameters that specify where the high and low values come from.

In this example, the results are restricted by the CourseNumber field to values between 0 and 150, inclusive:

<asp:RangeExpression DataField="CourseNumber" MaxType="Inclusive" MinType="Inclusive"> <asp:Parameter Type="Int32" DefaultValue="0" /> <asp:Parameter Type="Int32" DefaultValue="150" /></asp:RangeExpression>

As with previous versions of DataSources, you can tie your high and low values to controls. With the QueryExtender, you do that by adding ControlParameter tags. This example ties the high and low range to two TextBoxes called HighCourseNumber and LowCourseNumber:

<asp:RangeExpression DataField="CourseNumber" MaxType="Inclusive" MinType="Inclusive"> <asp:ControlParameter ControlID="LowCourseNumber" PropertyName="Text" Type="Int32" /> <asp:ControlParameter ControlID="HighCourseNumber" PropertyName="Text" Type="Int32" /></asp:RangeExpression>

Other parameters support tying the RangeExpression to Session variables, entries in the QueryString, personalized values in the user’s Profile, and even to keys in the Route used to retrieve the page. You can mix and match parameters so that your low value is provided by a Parameter tag, while your high value comes from a ControlParameter tag. You can also use these parameters with other filtering elements inside of QueryExtender.

Incorporate as many RangeExpression elements as you want into your QueryExtender to filter your data by multiple fields. You can also provide more than just two parameters within a RangeExpression element—the RangeExpression just uses the highest and lowest values you provide.

Filtering on Properties and MethodsThe PropertyExpression and MethodExpression elements work very much like the RangeExpression element. The PropertyExpression

allows you to limit the data that will be passed to the DataView by specifying a value for a property. To filter the courses to the number of days each course takes, for instance, you can add one of the Parameter elements within the PropertyExpression and specify the name of the Property to test in the element’s Name attribute. This example finds all the courses with four in their Days property:

<asp:PropertyExpression > <asp:Parameter Type="Int32" DefaultValue="4" Name="Days" /></asp:PropertyExpression>

You can add multiple Parameter elements within a PropertyEx-pression or add multiple PropertyExpression elements within a QueryExtender. Either way, your criteria are ANDed together.

The MethodExpression provides a more flexible approach than the previous filters by allowing you to call LINQ queries embedded inside a method. For instance, you could extend the QueryExtender’s page with this method:

Public Shared Function GetCoursesByDays( _ ByVal Courses As IQueryable(Of Course), _ ByVal MinDays As Integer) As IQueryable(Of Course)

Return From c In Courses Where c.Days >= MinDays Select c

End Function

This function demonstrates the requirements for any filtering method that you want to use: It must be a shared/static method, it must accept a “by value” IQueryable object as its first parameter, and it must return an IQueryable object. Your method can accept any number of parameters after that first IQueryable parameter.

Once you’ve created your filtering method, you tie your method to the QueryExtender with the MethodExpression element. This example calls my sample method, passing three to the method’s MinDays parameter:

<asp:MethodExpression MethodName="GetCoursesByDays"> <asp:Parameter Type="Int32" Name="MinDays" Default Value="3" /></asp:MethodExpression>

The first parameter on the method called from the MethodExpression holds the objects returned by the DataSource. You must provide, within the MethodExpression, enough Parameter elements for all other parameters on the method. The order in which your Parameter elements appear doesn’t have to match the order of the parameters on the method.

If you’d like to put your filter method in a different class, you can do that also. You’ll need to add a Type attribute to your MethodExpression element with the name of your class. This example assumes that the method is on a class called FilterClass:

<asp:MethodExpression TypeName="FilterClass" MethodName="GetCoursesByDays"…

You’d think you could then move your filter class to another class library. But when I tried this, I got a message that the first

30 VISUAL STUDIO MAGAZINE · February 2010 · VisualStudioMagazine.com

Page 33: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

AS

P.N

ET

4

{ PRACTICAL ASP.NET }

parameter passed to the method must be a Linq.DataQuery object and wasn’t able to recover.

If you’re going to put your filter code in your page’s code file, use the CustomExpression element. It calls a method in your page, passing the usual event parameters: sender and e. Within the method you can retrieve any parameters that you’ve specified in the CustomExpression element from the e parameter’s Values property. The e parameter also has a Query property that provides the data to filter and which accepts the result of your filtering code. This example assumes that the CustomExpression element has defined a parameter called MinDays and uses a LINQ query to filter the result:

Protected Sub QueryMethod( _ ByVal sender As Object, _ ByVal e As _ System.Web.UI.WebControls.Expressions.Custom-ExpressionEventArgs)

e.Query = From c In e.Query.Cast(Of Course)() _ Where c.Days >= Convert.ToInt32(e. _ Values("MinDays")) _ Select c

End Sub

The CustomExpression element needs to be told the name of the method to call, which you provide in the element’s OnQuerying attribute. This example specifies the method shown above and

uses a Parameter tag to define the MinDays parameter that my method requires:

<asp:CustomExpression OnQuerying="QueryMethod"> <asp:Parameter Name="MinDays" Type="Int32" Default Value="3" /></asp:CustomExpression>

Searching on Text StringFor many developers, the SearchExpression element will be the most useful part of the QueryExtender. The SearchExpression provides a variety of ways to search on strings, checking for strings that begin with, end with or contain the user’s text.

Like the other filter elements, SearchExpression allows you to tie the QueryExtender to multiple criteria sources using various Parameter elements. This example filters results going to the DataView using the content that the user enters into a TitleTextBox control. I’ve used the StartsWith option in the SearchType attribute so that I’ll match Titles that begin with whatever the user types in:

<asp:SearchExpression DataFields="Title" SearchType="StartsWith"> <asp:ControlParameter ControlID="TitleTextBox" PropertyName="Text" Type="String" /></asp:SearchExpression>

Empty controls are normally ignored by the SearchExpression. You can, however, incorporate empty controls into your search by

VisualStudioMagazine.com · February 2010 · VISUAL STUDIO MAGAZINE 31

Page 34: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

AS

P.N

ET

4{ PRACTICAL ASP.NET }

treating them as Nulls: Just set the SearchExpression element’s ConvertEmptyStringToNull attribute to true.

When working with strings you need to consider case and culture-sort rules. The ComparisonType attribute on the Search-Expression element lets you sort with and without case sensitivity, or even by using the Unicode numeric values of the characters.

Two additional elements that you can use with QueryExtender—ControlFilterExpression and DynamicFilterExpression—are supported only in ASP.NET Dynamic Data Web sites, but I’ll leave that for another article.

Working with CodeThe various expression tags are represented as System.Web.UI.WebControls.Expressions.DataSourceExpression objects in your code. You can retrieve the DataSourceExpressions in your QueryExtender by looping through them. The following example iterates through the DataSourceExpression in a QueryExtender looking for CustomExpression objects. When the code finds a CustomExpression, it loops through the DataSourceExpression’s Parameters collection looking for basic Parameter objects so that it can set the Parameter’s DefaultValue:

For Each dse As DataSourceExpression In _ Me.QueryExtender1.Expressions If TypeOf dse Is CustomExpression Then ce = CType(dse, CustomExpression) For Each parm As Parameter In ce.Parameters If TypeOf parm Is System.Web.UI.WebControls. _ Parameter Then parm.Type = TypeCode.Int32 parm.DefaultValue = "3" End If Next End IfNext

You can also request just the DataSourceExpressions of a particular type by using the OfType method on the QueryExtender’s Expressions collection. This example retrieves all the CustomExpression parameters before looping through them:

Dim ces As System.Collections.Generic.IEnumerable( _ Of CustomExpression)ces = Me.QueryExtender1.Expressions.OfType( _ Of CustomExpression)()For Each ce As CustomExpression In ces …

For a very dynamic search page, you can add and remove DataSourceExpressions from a QueryExtender at runtime. You can even add a QueryExtender to your page from code. I can add an OrderByExpression to a QueryExtender on the page by creating a System.Web.UI.WebControls.Expressions.OrderBy-Expression object and setting its properties. I can also add ThenBy objects to my SortExpression. Once I’ve got the OrderByExpression built, I add it to the Expressions collection on the QueryExtender, as shown in this example:

Dim ob As New OrderByExpressionob.Direction = SortDirection.Descendingob.DataField = "Days"Dim tb As New ThenBy

tb.DataField = "Title"tb.Direction = SortDirection.Ascendingob.ThenByExpressions.Add(tb)Me.QueryExtender1.Expressions.Add(ob)

You can also remove a DataSourceExpression using the RemoveAt method (passing the position of the DataSourceExpression to remove) or the Remove method (passing a reference to the DataSourceExpression to remove). With either method, asking for a DataSourceExpression that doesn’t exist raises an error. You can use the Contains method on the Expressions collection to check to see if a particular DataSourceExpression is present.

With one exception, adding other DataSourceExpressions in code follows the same pattern as SortExpression. The exception is the CustomExpression, where you have to wire up your event method to the Querying event, as this code does:

Dim ce As New CustomExpressionAddHandler ce.Querying, AddressOf QueryMethodDynamicMe.QueryExtender1.Expressions.Add(ce)

In Visual Basic there’s no need to declare the variable with the WithEvents keyword. While, generally speaking, order doesn’t matter when adding to the Expressions collection, the Insert method does allow you to add DataSourceExpressions at specific points in the collection.

A Strategic ExtensionThere are some features that I’d like to see added to the Query-Extender. It would be great if the QueryExtender also worked with the SqlDataDataSource and the ObjectDataSource. For dynamic runtime solutions, it would be convenient if DataSourceExpressions could be enabled and disabled in addition to being removed and added. And I’d love to have more flexibility than just ANDing them together when it comes to combining filtering expressions.

But the QueryExtender is more than just a useful tool—it’s a reflection of two of Microsoft’s strategic intents in data access. First, the QueryExtender extends the declarative model that Microsoft is moving toward in data access. As with SQL, the QueryExtender allows you to declare what you want rather than have to specify the individual procedural steps required to get there. Second, the QueryExtender continues the process of providing a single interface to data. The point of DAO, ADO and ADO.NET was that you shouldn’t care what database engine you’re working with; the point of LINQ is you shouldn’t even care whether your data is coming from an RDBMS. In the same way, the QueryExtender provides a single interface for declaratively selecting the data you—or, more importantly, your users—want, regardless of the DataSource. The QueryExtender is a strategic tool in addition to being a useful one. VSM

Peter Vogel ([email protected]) is a principal in PH&V Information Services, specializing in ASP.NET development with expertise in SOA, XML, database and UI. His most recent book, “rtfm*: The Little Book on How to Write So You’ll Actually Get Read” (PH&V Information Services, 2008), is on writing effective user manuals; his blog on technical writing can be found at rtfmphvis blogspot.com.

GO ONLINE

Go to VisualStudioMagazine.com/VogelA0210 to read and download the sample code for this article.

32 VISUAL STUDIO MAGAZINE · February 2010 · VisualStudioMagazine.com

Page 35: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

New in

Version 2010:

• SysML support

• WSDL 2.0 editing,

conversion, mapping

• Enhanced XBRL support

• JSON editing & conversion

• And much more...

Untitled-30 1 1/4/10 12:57 PM

Page 36: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

Sil

ver

ligh

t an

d M

EF

{ ASK KATHLEEN }

</Language Lab>

Digging Deeper into Silverlight and MEFSilverlight applications based on the Managed Extensibility Framework and generalized user interfaces don’t require hand coding every screen.BY KATHLEEN DOLLARD

Last month I covered how to use the DataForm in the Silveright Toolkit to create a generalized UI with a single set of generalized user controls, producing an application from different business entities (“Mastering Silverlight,” January 2010). As with many programming challenges, the devil is in the details, and I skipped a view model, patterns for using Managed Extensibility Framework (MEF) and some rather ugly gotchas when working with the DataForm. In this column I’ll cover these issues, and next time I’ll cover persistence using Windows Communication Foundation (WCF) services. You can find more information on the Model-View-View Model (MVVM) in one of my previous columns (“Applying Model-View-View Model in Silverlight,” September 2009). Because this month’s column relies heavily on MEF, you might want to review some of my other columns on the subject (“Working with MEF,” April 2009, “Getting Current on MEF,” October 2009, and “Stable Composition in MEF,” November 2009).

One of the shortcuts I took in last month’s column was to flatten or denormalize the data structure by including the customer name in the invoice class. While that’s one approach to passing data across a service boundary to Silverlight, other approaches are more common. This month, I’ll use a relational approach for parent data and include the CustomerId in the invoice data. This requires a lookup mechanism to display the customer name. I’ll use this to illustrate one benefit of a view model: The data in the view model will enhance the model, including calculated and lookup fields.

Programmers new to MEF often overlook that there are two reasons to include classes in an MEF container. Allowing alternative implementations is one reason. But more importantly, a class’s imports won’t be satisfied unless the instance is created through the MEF container. You generally instantiate the class with the MEF container using the export/import pattern. I’ll show how to leverage this with a contract pattern for logical entities. Logical entities are groups of classes that work together to provide functionality; examples include Customer and Invoice entities.

Last month’s sample application included five separate projects: the server-side Web, the Silverlight application, common utilities, common contracts and business classes. See “Organizing Your Application,” p. 38, for an overview of factors driving project organization. This month I added two more projects: business contracts and view models. Separating the business contracts from the infrastructure contracts clarifies the difference, encourages experimental spiking and allows reuse.

As you develop MEF architectures, you’ll find sets of functional parts that work together to supply the full behavior for each logical

entity. For example, Invoice, Customer and Product entities may each include a business class, a service class, a view model and other classes. “Services” in this month’s column will refer to singleton classes managing behavior, not WCF services.

A good way to organize these classes is to supply a non-generic interface that’s task-based and a target type via MEF metadata: for example, an IViewModel interface with an IInvoice target type. The target type (IInvoice) is effectively a token that identifies the entity.

The non-generic interface allows retrieval where the type is known only by its name. The functionality of the interface may need to know the target type, in which case a derived interface can supply more type specificity:

Public Interface IViewModel ...Public Interface IViewModel(Of T) ...

Types may include more than one export.Providing a token that identifies the entity as a whole simplifies

later operations. This brings up a question: What exactly is a logical entity, such as an Invoice? If you use the full set of currently defined properties, you exclude the possibility of an abbreviated set of columns representing the entity. As the functional entity will eventually include extensions such as validation and authorization, it’s valuable to keep abbreviated objects part of the entity family. Using the full set of columns would also present challenges when columns are added or deleted because the interface changes would affect much of your application. The token could be an empty interface, but I prefer an interface that contains the properties that would always be part of the entity: the primary key and the human-friendly alternate key if one exists.

This splits the business contract into two pieces:

Public Interface IInvoice Inherits Contracts.ICoreBiz Property InvoiceId() As Int32 Property InvoiceNumber() As StringEnd InterfacePublic Interface IInvoiceStandard Inherits IInvoice Property CustomerId() As Int32 ' More fields as needed ReadOnly Property LineItems() As IList( _ Of IInvoice LineItem)End Interface

A custom export attribute can specify the task contract and the target type. Using a custom export is synonymous with using an Export attribute and a Metadata attribute. In this case, the BizService custom export attribute exports the IBizService interface and provides IInvoice as the target type:

<BizService(GetType(IInvoice))> _

34 VISUAL STUDIO MAGAZINE · February 2010 · VisualStudioMagazine.com

Page 37: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

{ ASK KATHLEEN }

VisualStudioMagazine.com · February 2010 · VISUAL STUDIO MAGAZINE 35

Public Class InvoiceService Implements IBizService(Of IInvoice)

Different Ways to Retrieve MEF PartsCode in different parts of your application needs to retrieve parts based on the token. There are several scenarios for retrieval, many of which are likely to be included in your application. Code may want one instance or want to be able to create many new instances. It may know the specific type, the type as a generic or only knows the task/service type by name. The last is especially interesting because it allows generalized code.

The Import attribute imports one part when the containing instance is created. Imports must be public in Silverlight because Silverlight doesn’t allow reflection access to private members:

<Import()> _ Public _customers As CustomerViewModel

PartCreator is unique to Silverlight and creates a factory that supplies new instances of the underlying part as requested:

<Import()> _ Public _creator As PartCreator(Of CustomerViewModel)

You can learn more about MEF behavior with generics in “Using Generics with MEF,” p. 37. Because MEF exports the type as it exists at runtime, if either of these imports uses generics, the import contract will be the closed generic. If ViewModelBase—which has a generic argument of TViewModel constrained to IViewModel—and CustomerViewModel inherit from ViewModelBase and implement IViewModel, then both of the following imports work if there’s an export in the container for IViewModel (Of CustomerViewModel):

<Import()> _ Public _customers As IViewModel( _ Of T) <Import()> _ Public _creator As PartCreator( _ Of IViewModel(Of T))

Parts retrieved using the generic IView-Model contract will expose only properties and methods of that contract, not of the underlying type. This style is very useful for code in base classes, but not sufficient to access specific properties and methods of sibling view models.

Generalized code, such as generalized user interfaces, requires creating parts when only the name of the type is known. For example, the short type name of the token may be retrieved from the navigation query:

_bizClassName = NavigationContext. _ QueryString(argName) _searchForm = _searchFactory. _ GetItem(_bizClassName)

The search factory retrieves a class with the non-generic task contract ISearch and a target type named bizClassName. The search factory must first retrieve the target type based on the class name, and then filter the full collection of ISearch parts using LINQ.

Retrieving a type based on a class name is not trivial in Silverlight. You can’t just grab a set of assemblies and iterate through them. I solved this by providing a contract named IBizContractAssemblyMarker. Placing the marker contract on a class in the assembly exposes it to the TypeRetriever class:

<Export(GetType(Common.IBizContractAssemblyMarker))> _Public Class BizContractAssemblyMarker Implements Common.IBizContractAssemblyMarkerEnd Class

TypeRetriever contains an ImportMany for these markers. It looks for requested types within the assemblies where the markers reside:

For Each marker In bizClassAssemblyMarkers Dim assembly = marker.Value.GetType.Assembly Dim q = assembly.GetTypes.Where( _ Function(t) t.Name = name) If q.count > 0 Then Return q.First End If Next

Sil

ver

ligh

t an

d M

EF

Page 38: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

Sil

ver

ligh

t an

d M

EF

{ ASK KATHLEEN }

Unique factories for each task type, such as the _searchFactory, become tedious, so I created a generalized solution employing generic tricks that you can find at VisualStudioMagazine.com/Dollard0210, along with an explanation on my blog.

After importing an ITargetTypeRetriever (_retriever), parts following the task type/entity token target type pattern can be retrieved:

_viewModelMany = _retriever.GetItem( _Of IViewModelMany)(targetType, False)

The final Boolean attribute specifies whether a default value should be used if available. A default value is the task type with a target type of null (Noting in Visual Basic). This allows functionality such as edit or search to be generalized with the default or specialized to the entity.

Different parts of your application may retrieve parts in different ways based on the information available and on the level of access required.

Implementing the View ModelThe view model provides abstraction between the view and the model, allowing them to independently change. This is especially appropriate with the heavy use of data binding that occurs in a generalized UI. Binding is not only to the data fields, but also the general state of the object, such as whether it’s read-only.

The view models also provide lookup values and a calculated field. Most view model properties directly wrap the corresponding model properties:

Public Property InvoiceNumber() As String Get Return Model.InvoiceNumber End Get Set(ByVal value As String) Model.InvoiceNumber = value End Set End Property

The lookup fields need a bit more work. Implementations of both IViewModel and the IViewModelMany are non-shared. Using the IViewModelMany implementation would be inefficient because it would result in multiple copies of the list of customers or products. A new interface allows a simplified implementation exposed as a shared part:

<ViewModelLookup(GetType(ICustomer))> _<Export(GetType(IViewModelLookup(Of ICustomer)))> _<PartCreationPolicy(CreationPolicy.Shared)> _Public Class CustomerViewModelLookup Inherits ViewModelManyBase(Of ICustomer, _ CustomerViewModel) Implements IViewModelLookup(Of ICustomer)

The IViewModelLookup interface contains a LookupDisplay method which returns a display string for a passed id. My implementation creates an empty CustomerViewModelMany:

<Import()> _ Public _list As CustomerViewModelMany Private _isFilled As Boolean

The LookupDisplay method fills the customer list if needed, finds the matching customer id and returns the customer name:

Public Function LookupDisplay(ByVal id As Int32) _ As String _ Implements IViewModelLookup.Lookup If Not _isFilled Then _list.RetrieveMany(Nothing) _isFilled = True End If Dim customer = (From c In _list Where _ c.CustomerId = id).FirstOrDefault If customer IsNot Nothing Then Return customer.CustomerName End If Return "Customer ID not found: " & CStr(id) End Function

I just grabbed the entire collection to illustrate the approach. You can provide a more sophisticated strategy if needed. This code is designed for synchronous operations, and I’ll return to it next time in relation to Silverlight persistence behavior and asynchro-nous operations.

Solving Issues with DataForm and MEFThe DataForm mechanism for scrolling through records works well, but adding and deleting items needs tweaking. By default, DataForm’s delete operation simply removes the item from the collection. We need to mark items as deleted and update the database, either immediately or later in a transaction or batch. The DataForm.DeletingItem event lets you specify deletion behavior and optionally cancel deletion:

Private Sub DataForm_DeletingItem(ByVal sender _ As Object, ByVal e As CancelEventArgs) Dim current = CType(DataForm.CurrentItem, _ IViewModel) current.Delete() End Sub

Adding items is more problematic. By default, DataForm only lets you add items if the collection is of a type that has a parameterless constructor in scope. If MEF parts are created using a constructor, their imports won’t be satisfied. While SatisfyImports can be called in some situations, it can’t be used on parts that have an

The view model provides abstraction between the view and the model, allowing them to independently change. This is especially appropriate with the heavy use of data binding that occurs in a generalized UI.

36 VISUAL STUDIO MAGAZINE · February 2010 · VisualStudioMagazine.com

Page 39: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

{ ASK KATHLEEN }

export attribute, and that attribute is required for other MEF construction. Therefore, it’s essential that parts be created using the MEF container and not directly through constructors.

The DataForm relies on the contained collection to do much of its work. When working with ordinary collections, the DataForm provides a view, which is a wrapper for your collection. DataForm uses the PagedCollectionView wrapper unless your collection supports ICollectionView and IEditableCollectionView.

Of course, you could implement these interfaces on your collection, but this is not a trivial undertaking—and changes to PagedCollectionView to support MEF are relatively small and

USING GENERICS WITH MEFThere’s been some confusion about combining Managed Extensi-bility Framework (MEF) with generics. Because many people are aren’t sure what an open generic is, the statement “MEF doesn’t support open generics” has sometimes led to the assumption that MEF lacks capabilities that it does, in fact, possess.

An “open generic” is one that doesn’t have its generic arguments defi ned. This can be a little confusing, because a generic that’s open in your source code is often resolved or closed when your application runs: public class Derived : Base<IInvoice> { } public class Base<T> { } public class Test { private Base<ICustomer> x; }When the application runs, a concrete class for Base is constructed with IInvoice replacing T. A separate concrete class is constructed for the type declared as the fi eld x with ICustomer replacing T. Separate concrete classes are created for each unique type argument used by your application.

The generic class Base also exists in your application as an open generic, and you can use refl ection to construct a concrete class from it. However, you can’t export an open generic type and have the standard MEF container construct the concrete class for you. Thus, MEF doesn’t support open generics.

However, MEF defi nitely supports imports that contain constructed generic parameters. By the time the import is resolved, the generic argument has been supplied and the concrete class constructed: public class Derived : Base<IInvoice> { } [Export(<someContract>)] public class Base<T> { [Import()] private IFoo<T> foo; }In this case, when the MEF container instantiates a Derived instance, it also resolves the base class import for foo. The contract is the namespace-qualifi ed name of the constructed type—the namespace-qualifi ed name of IFoo<IInvoice>. Another part within the MEF container must explicitly export this contract, or composition fails: [Export(typeof(IFoo<IInvoice>))] public class InvoiceFoo { }The requirement for the export with the explicit closed generic is sometimes inconvenient. You must provide a class with the explicit export, even if this means defi ning derived classes with nothing more than an inheritance declaration and an MEF export attribute. If this becomes a problem in your application, Glenn Block posted a GenericCatalog that extends MEF to construct parts at from an open generic. You can fi nd this at www.codeplex.com/mefcontrib. —K.D.

Page 40: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

Sil

ver

ligh

t an

d M

EF

{ ASK KATHLEEN }

provided in this article’s accompanying download. I changed the CanConstructItem method to check for MEF exports using a new MefSupport class. I also changed AddNew to call MefSupport, as well. To be consistent with the PagedCollectionView, the new MefSupport class is written in C#. It contains similar Create and CanCreate static methods. Each receives the target type of the inner collection as a parameter. It uses reflection to create a MethodInfo object for a private generic method within the class, construct the closed generic method with the passed target type and invoke the method:

static internal bool CanCreate(Type type){ var methodInfo = typeof(MefSupport).GetMethod( "CanCreateInternal", BindingFlags.Static | BindingFlags.NonPublic ); var genericMethod = methodInfo. MakeGenericMethod(new Type[] { type }); return (bool)genericMethod.Invoke(null, null);}

The private method declares a local variable with the generic argument of the target type:

static private bool CanCreateInternal<T>(){ var x = new MefSupportInternal<T>(); return x.CanCreate();}

The nested MefSupportInternal class includes an import for a PartCreator of the type argument T, which is the target type passed to the CanCreate method. The constructor calls SatisfyImports, allowing MEF to resolve the PartCreator. If it’s successful, CanCreate returns true and Create returns the requested type:

public class MefSupportInternal<T> { [Import(AllowDefault=true)] public PartCreator<T> _creator;

public MefSupportInternal() { PartInitializer.SatisfyImports(this); }

public bool CanCreate() { return _creator != null; }

public object Create() { return _creator.CreatePart().ExportedValue; } }

To use the custom PagedCollectionView, wrap your collection before passing it to the DataForm:

Me.DataContext = New PagedCollectionViewMef(_ viewModelMany)

A couple of other changes: The DataAnnotations attributes fail as you cross multiple boundaries—such as providing the view model layer—so they no longer work. I’ll return to this issue in a future column. Rather than directly instantiating a DataForm, I wrapped a DataForm in a user control for a consistent appearance with handcrafted user controls.

You can download the sample application to explore these details further. While there are a number of challenges, the payoff is an application that you can build quickly and evolve during development and the remainder of the project lifecycle. VSM

Kathleen Dollard is the chief technologist for AppVenture (www.appventure.com). She has been a Microsoft MVP for 11 years and is a member of the INETA Speaker’s Bureau. Dollard has worked extensively with application code generation and is the author of “Code Generation in Microsoft .NET” (Apress, 2004). She speaks at dozens of conferences and user groups each year, and is also active in the Northern Colorado .NET SIG, Denver Visual Studio User Group, Northern Colorado Architect’s Group and IASA Denver.

GO ONLINE

Go to VisualStudioMagazine.com/Dollard0210 to read and download the sample code for this article.

38 VISUAL STUDIO MAGAZINE · February 2010 · VisualStudioMagazine.com

ORGANIZING YOUR APPLICATIONHow many projects should your application contain? It’s a tough question. Project/assembly boundaries provide primary enforce-ment of dependencies. But what drives dependency organization? The guidelines I use are:

• Separate platforms, such as .NET and Silverlight, require separate projects

• Multi-language projects require separate assemblies for each language (such as C#, VB or F#)

• Tiers or logical layers should be in separate projects• Utility functionality and common base classes should be in

separate projects for reuse and to avoid circular dependencies• Interfaces that are used as contracts to decouple projects

should be in separate projects to ensure eff ective decoupling• Code dependent on technology features, such as accessing

data, should be in separate projects• Infrastructure code should be in projects separate from your

application code• Long-lived utility functionality, such as extension methods,

should be in separate projects• If the application is segmented into functional modules,

such as General Ledger and Inventory, these should be in separate projects

• Functionality that may be replaced as a whole should be in separate projects

• Contracts that may be used by only a subset of other parts within your application should also be in a separate projects

• Testing should be in separate projectsThese guidelines are not unique to Managed Extensibility

Framework (MEF), but MEF leads you to better consider dependencies and isolation, often leading to a more granular breakdown of your application. I have 20 projects in one business application, and I currently have 34 projects for the CodeRapid code generator because it’s explicitly designed for extensions—more extensions mean more projects. I don’t recommend 100 projects with a million lines of code in a single solution because Visual Studio gets a little moody, but one of the side changes of MEF is likely to be more granular project organization.

Projects generally have a one-to-one relationship with assemblies/DLL fi les, and the project design aff ects how you want to deploy your application. This can be a secondary factor because

.NET off ers tools to combine logical assemblies in DLL fi les. —K.D.

Page 41: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

Advertiser Page

/n Software Inc. 7www.nsoftware.com

Altova 33www.altova.com

Aspose C4www.aspose.com

dtSearch 37www.dtsearch.com

ESRI 28www.esri.com

GrapeCity FarPoint C3www.fpoint.com

IdeaBlade 17www.ideablade.com

Infragistics C2, 1, 11www.infragistics.com

Inish Technology Ventures Limited 31www.inishtech.com

LEAD Technologies, Inc. 5 www.leadtools.com

TechExcel, Inc. 9www.techexcel.com

VSLive! 26, 27http://vslive.com/

Wayside Technology Group, Inc 2www.waysidetechnology.com

Wiley Publishing / Wrox Books 35www.wiley.com

Editorial IndexAdobe Systems Inc. 15www.adobe.com

Apple Inc. 18, 40www.apple.com

Citrix Systems Inc. 40www.citrix.com

dynaTrace Software 13www.dynatrace.com

Google Inc. 18, 40www.google.com

Infragistics 16www.infragistics.com

Intergen Ltd. 16www.intergen.co.nz

Magenic Technologies Inc. 10www.magenic.com

Novell 16www.novell.com

Research In Motion Ltd. 18www.rim.com

Rockwell Automation Inc. 18www.rockwellautomation.com

Telerik Inc. 10, 15www.telerik.com

VisualStudioMagazine.com · February 2010 · VISUAL STUDIO MAGAZINE 39

Advertising Sales Ad Index

EastMatt Morollo VP, Publishing Phone: [email protected]

WestChris KourtoglouRegional Sales ManagerPhone: [email protected]

National Accounts DirectorWilliam SmithPhone: [email protected]

Microsoft Account ManagerDanna VedderPhone: 253-514-8015dvedder@11 05media.com

Director, Print ProductionJenny Hernandez-AsandasPhone: 818-814-5289Fax: [email protected]

Production CoordinatorSerena BarnesPhone: [email protected]@1105media.com

Media KitsDirect your Media Kit requests to Matt Morollo, VP Publishing, 508-532-1418 (phone), 508-875-6622 (fax), [email protected] GO TO

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

ID StatementVisual Studio Magazine (ISSN 1537-002X) is published monthly by 1105 Media, Inc., 9201 Oakdale Avenue, Ste. 101, Chatsworth, CA 91311. Periodicals postage paid at Chatsworth, CA 91311-9998, and at additional mailing offi ces. Complimentary subscrip-tions are sent to qualifying subscribers. Annual subscription rates for non-qualifi ed 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 2166, Skokie, IL 60076-7866, email [email protected] or call toll free (888) 768-8759, fax number 847-763-9564. International calls 847-763-9135. POSTMASTER: Send address changes to Visual Studio Magazine, P.O. Box 2166, Skokie, IL 60076-7866. 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, 230 California St. Suite 302, San Francisco, CA 94111.

Legal DisclaimerThe information in this magazine has not undergone any formal testing by 1105 Media, Inc. and is distrib–uted 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 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 develop-ments in the industry.

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

Media KitsDirect your Media Kit requests to Matt Morollo, VP Publishing, 508-532-1418 (phone), 508-875-6622 (fax), [email protected]

ReprintsFor single article reprints (in minimum quantities of 250-500), e-prints, plaques and posters contact:PARS InternationalPhone: 212-221-9595E-mail: [email protected]/QuickQuote.asp

List RentalThis publication’s 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: [email protected]; Web: www.meritdirect.com.

Page 42: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

40 VISUAL STUDIO MAGAZINE · February 2010 · VisualStudioMagazine.com

What can Microsoft do to preserve the relevance of Windows—and the crucial revenue stream that derives from it? As client software moves to the Web and server software moves to the cloud, what’s left for a client OS that’s designed to run local applications that talk to on-premises servers?

To fi nd the inspiration for what ought to be in Windows 8, 9 and 10, I’ve been looking very hard at the virtual applications feature found in Windows 7 and its version of Windows Virtual PC (WVPC). Here’s what I’ve found.

Virtual applications execute on WVPC guest instances that are running Windows XP, Windows Vista or Windows 7. Virtual applications actually merge into the host’s desktop session, including the taskbar and system tray. They can be run directly from the host’s Start menu and can access fi les on the host’s physical disk drives.

The virtual apps feature allows for backward compatibility for software that will only run on an older OS, like XP. But the real impact of the feature is that it makes available an application without requiring it to be locally installed. This is great for beta versions of new software, as you can run them on your “real” PC and avoid the residue that often remains after an uninstall. It also means virtual applications run in a segregated environment, causing minimal impact on the host or on other guests—available memory permitting. And because virtual apps are made possible by a combination of WVPC and Remote Desktop, the guest image could, one day, be running on another machine.

Virtual Is the New PhysicalI would love to run every app as a virtual app. But to do so, I’d need to run multiple virtual machine (VM) images simultaneously, which would use a ton of memory; inhibit intercommunication between apps, including even clipboard sharing; mess up extended graphics modes; and likely cause a host of other issues. Plus, every time I wanted to add a new app, I’d need to build a new image of Windows to install it into. For each image, I’d need to license it, install security patches within it, run anti-malware on it and so on.

But what if I had an operating system built specifi cally to handle all this? It could, with hardware hypervisor assistance, provision new image instances on the fl y; allow them to share memory; be patched and protected in unison; facilitate drive and device sharing between them; manage a global clipboard; and eliminate graphic display shortcomings. And the notion of remote instances, including cloud-based ones, could be a core scenario.

In this OS, the accommodation of guest instances wouldn’t be a special a trick; it would be the normal way of running an application. The guest instance would be analogous, in many ways, to what a window is today. With that in mind, this special OS could, perhaps, be the future version of Windows. Let’s call it Windows New.

Windows New would look a bit like Citrix. But because Citrix’s environment today requires a special server—and its client sits on top of Windows itself—Windows New would be more integrated, stable, simple and economical. Windows New would also look a bit like the Google Chrome OS. After all, Chrome is a slimmed-down, Web-based operating system that’s built to launch applications rather than run them. But Chrome wants to relegate your application experience to the browser and HTML. Windows New, while accommodating browser applications, would instead let you stick with Windows applications, while greatly reducing their deployment and provisioning impact.

Bridging the Generation GapWindows New would leverage the Internet without imposing the Web or diminishing the client PC. It would best today’s Windows, Android and Mac OSes, as well as tomorrow’s Chrome OS. It would leverage the hypervisor, display, processing and memory-management power of today’s PCs, rather than demoting them to dumb terminals.

Windows New would embrace virtualization and the cloud, while preserving the client application capabilities that users still want—and that Microsoft and its OEM partners rely upon. Windows New would still accommodate AJAX and rich Internet application apps too, not to mention capabilities like Windows Media Player and Media Center. Windows New would be a modern, relevant, high-value product, not just another upgrade to an OS that was designed for personal computing in the 1980s. And it would be all this while still drawing on that very important heritage.

I’m convinced Windows needs to transform in a profound way, without abandoning its past and core competency. Windows New is one path to that destination. Would you buy it? Would you develop for it? Let me know what you think. VSM

Andrew J. Brust ([email protected]) is chief of new technology for consultancy twentysix NewYork, as well as a Microsoft regional director and MVP. He’s also the co-author of “Programming Microsoft SQL Server 2008” (Microsoft Press, 2008).

</Redmond Review>Windows New

BY ANDREW J. BRUST

Page 43: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

Untitled-4 1 1/11/10 2:36 PM

Page 44: Silverlight Ascendantpdf.101com.com/VSMMag/2010/70045069/VSM_1002DG.pdf · FEBRUARY 2010 Volume 20, No. 2 Silverlight Ascendant. Untitled-7 2 1/8/10 3:36 PM. Infuse your team with

Project3 10/29/09 9:20 AM Page 1