inside the tools and technologies - 1105 mediapdf.1105media.com/vsmmag/2011/jan.pdf · redmond...

46
Inside the tools and technologies .NET developers need to thrive in the year to come. PLUS Expose Silverlight App Interfaces with MEF .NET Component Suites Reviewed JANUARY 2011 Volume 21, No. 1 VisualStudioMagazine.com

Upload: others

Post on 05-Jul-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

Inside the tools and technologies .NET developers need to thrive in the year to come.

PLUS Expose Silverlight App

Interfaces with MEF.NET Component Suites Reviewed

JAN

UARY

201

1

Volu

me

21, N

o. 1

VisualStudioMagazine.com

Page 2: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

Using Quince™, you and your team cancollaborate on the user interface usingwireframes, designs and examples.

Then use NetAdvantage® UI controls,like the map control used here, to bringthe application to life quickly & easily.

...

............................................................................................

.......................................................................

Untitled-7 2 11/10/10 10:59 AM

Page 3: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

From start to finish, Infragistics gives you the tools to createimpressive user experiences that'll make end users happy!

SEE HOW WE USE THE TOOLS TO CREATE THIS KILLER APP AT INFRAGISTICS.COM/IMPRESS

Infragistics Sales 800 231 8588 • Infragistics Europe Sales +44 (0) 800 298 9055 • Infragistics India +91 80 4151 8042 • @infragistics

..............................................................................................................................

...

Untitled-7 3 11/10/10 10:59 AM

Page 4: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

programmersparadise.com866-719-1528

Your best source for software development tools!

Prices subject to change. Not responsible for typographical errors.

®

programmers.com/textcontrol

Download a demo today.

NewServicePack!

Professional EditionParadise #

T79 02101A02$1,220.99

• .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, multipleundo/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.

ActiveReports 6by GrapeCity

The de facto standard reporting tool forMicrosoft Visual Studio.NET

• Fast and Flexible reporting engine• Flexible event-driven API to completely

control the rendering of reports• Wide range of Export and Preview formats

including Windows Forms Viewer, WebViewer, Adobe Flash and PDF

• XCopy deployment• Royalty-Free Licensing for Web and

Windows applications

Professional Ed.Paradise # D03 04301A01 $1,310.99

NEWVERSION

6!

programmers.com/grapecity

programmers.com/vSphere

VMware vSphere Essentials Kit BundlevSphere Essentials provides an all-in-onesolution for small offices to virtualize threephysical servers for consolidating and managing applications to reduce hardwareand operating costs with a low up-frontinvestment. vSphere Essentials includes:

• VMware ESXi and VMware ESX (deployment-time choice)

• VMware vStorage VMFS• Four-way virtual SMP• VMware vCenter Server Agent• VMware vStorage APIs/VCB• VMware vCenter Update Manager• VMware vCenter Server for Essentials

for 3 hosts Paradise #

V55 85101C02

$446.99

programmers.com/embarcadero

Embarcadero RAD Studio XEby EmbarcaderoEmbarcadero RAD Studio XE is a comprehensiveapplication development suite and the fastest way to visually build GUI-intensive, data-drivenapplications for Windows, .NET, PHP and the Web. RAD Studio includes Delphi®, C++Builder®,Delphi Prism™, and RadPHP™; providing powerfulcompiled, managed and dynamic language support, heterogeneous database connectivity, rich visual component frameworks, and a vast 3rd party ecosystem – enabling you to deliver applications up to 5x faster across multipleWindows, Web, and database platforms.Paradise #

CGI 15401A01 $1,383.99

NEWRELEASE!

programmers.com/sparxsystems

Enterprise ArchitectCorporate EditionVisualize, 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.

1-4 Licenses Paradise #

SP6 03101A02$182.99

programmers.com/LEAD

LEADTOOLS Document Imaging SDK v17.0by LEAD TechnologiesLEADTOOLS Document Imaging has every compo-nent you need to develop powerful image-enabledbusiness applications including specialized bi-tonalimage processing, document clean up, annota-tions, high-speed scanning, advanced compression(CCITT G3/G4, JBIG2, MRC, ABC), andWin32/64 binaries for C/C++, .NET, Silverlight,WPF, WCF, & WF. Available add-ons include:• Multi-threaded OCR/ICR/OMR/MICR/

Barcodes (1D/2D)• Forms Recognition/Processing• Print Capture and Document Writers• PDF, PDF/A and XPS

Paradise # L05 03301A01 $2,007.99

programmers.com/vmware

VMware Workstation 7VMware Workstation 7 is the gold-standard virtualization software for desktop and laptopcomputers, with the richest feature set andbroadest platform support available. VMwareWorkstation enables users to create and hostmultiple virtual machines on a single desktop,expanding the power of desktop systems for IT administrators; software development andtest engineers; technical sales, training and support staff; and PC enthusiasts.

VMware Workstation transforms the way technical professionals develop, test, demo, and deploy software. Workstation’s innovativefeatures for VMware environments help toreduce hardware cost, save time, minimize risk, and streamline tasks that save time and improve productivity.

for Linux & Windows

Paradise # V55 22301A04

$149.99

programmers.com/microsoft

Microsoft Visual StudioProfessional 2010 Upgrade by MicrosoftUpgrade to Microsoft Visual Studio 2010Professional — the integrated environment thatsimplifies creating, debugging and deployingapplications. Unleash your creativity and bringyour vision to life with powerful design surfacesand innovative collaboration methods for devel-opers and designers. Work within a personalizedenvironment, targeting a growing number of platforms, including Microsoft SharePoint andcloud applications and accelerate the codingprocess by using your existing skills. Integratedsupport for Test-First Development and newdebugging tools let you find and fix bugs quicklyand easily to ensure high quality solutions.

with MSDNSingle userParadise #

M47 40201B02

$488.99

New Intel Visual Fortran Compilerby IntelIntel® Visual Fortran Composer XE2011 includes the latest generation of Intel®

Fortran compilers, Intel® Visual Fortran CompilerXE 12.0 for Windows. Intel® Fortran Composer XE is available for Linux and Mac OS X. Thispackage delivers advanced capabilities for development of application parallelism and winning performance for the full range of Intel®

processor-based platforms and other compatibleplatforms. It includes the compiler’s breadth ofadvanced optimization, multithreading, andprocessor support, as well as automatic proces-sor dispatch, vectorization, and loop unrolling.

for Windows Single (SSR)Paradise # I23 86101E03 $263.99

programmers.com/intel programmers.com/microsoft

Microsoft SQL ServerDeveloper Edition 2008 R2 by MicrosoftSQL Server 2008 Developer enables developers to build and test applications that run on SQL Server on 32-bit, ia64, andx64 platforms. SQL Server 2008 Developerincludes all of the functionality of EnterpriseEdition, but is licensed only for development,test, and demo use. The license for SQLServer 2008 Developer entitles one developerto use the software on as many systems as necessary. For rapid deployment into production, instances of SQL Server 2008Developer can easily be upgraded to SQLServer 2008 Enterprise without reinstallation.

2-bit/x64 IA64 DVDParadise #

M47 31101A04

$41.99

programmers.com/idm

IDM UltraEdit The #1 Best Selling Text Editor in the World

by IDMUltraEdit is the world’s standard in texteditors. Millions use UltraEdit as the ideal text/hex/programmers editor on any platform — Windows, Linux, or Mac!

Features include syntax highlighting for nearly any programming language; powerful Find, Replace, Find in Files, and Replace in Files; FTP support, sort,column mode, hex, macros/scripting,large file handling (4+ GB), projects,templates, Unicode, and more.

Named User 1-24 Users Paradise #

I84 01201A01$59.95

NEWRELEASE!

Win an iPadPlace an Order for Software (or Hardware) with Programmer’s Paradise and You’ll be Entered for a Drawing to Win an iPad Wi-Fi 32GB.

Just Use the Offer Code TRWD01When You Place Your Order On-line or with Your Programmer’s Paradise Representative.

Untitled-2 1 12/13/10 4:19 PM

Page 5: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

VisualStudioMagazine.com · January 2011 · VISUAL STUDIO MAGAZINE 3

14

January 2011 // Volume 21 // No. 1

Michael Desmond, Editor in Chief, Visual Studio Magazine

FEATURES14 .NET Survival Guide

VSM editors and experts explore the tools and technologies that will shape the direction of .NET development over the year to come.BY MARK MICHAELIS, MICHAEL DESMOND, KATHLEEN RICHARDS & PETER VOGEL

30 Measuring Test Effort Progress with EVMAn important part of a software testing—or coding—effort is the ability to measure progress. One way for doing this is a technique called Earned Value Management (EVM). Find out how easy it is to apply EVM to your own projects.BY JAMES MCCAFFREY

33 Using MEF to Expose Interfaces in Your Silverlight MVVM AppsManaged Extensibility Framework lets you expose interfaces and classes in your Silverlight apps without having to expose the real implementation. See how it works.BY SANDRINO DI MATTIA

DEPARTMENTS6 Letters to the Editor

8 DevInsight VSTOOLBOX, VSINSIDER

VSToolbox: Developer Express DXperience ASP.NET PAGE 8

VSToolbox: Infragistics NetAdvantage for .NET: Windows Client Suite PAGE 9

VSInsider: A Look at Silverlight 5 PAGE 12

COLUMNS3 Frameworks BY MICHAEL DESMOND

40 Redmond Review BY ANDREW BRUST

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

Line-of-Business Dev in 2011With all the activity around mobile and Web technologies, it’s easy to think that Microsoft might take its eye off the ball in the area of line-of-business (LOB) development. However, according to Rob Sanfi lippo, analyst for research fi rm Directions on Microsoft, business developers actually have a lot to look forward to in 2011.

BizTalk 2010, launched in October, provides new ways to expose LOB functionality beyond the fi rewall via Windows Azure AppFabric Connect.

“This service can reduce the development burden by allowing Windows Workfl ow Foundation activities to be dropped into a workfl ow designer and tied into LOB applications through BizTalk adapters,” Sanfi lippo wrote in an e-mail interview.

“Workfl ows can be hosted and managed with less effort now using Windows Server AppFabric hosting.”

The upcoming SQL Azure Reporting Services will also enable remote access to LOB data stored in the cloud or on-premises.

Offi ce 2010 Business Connectivity Services (BCS) also earned mention. Sanfi lippo said the new Duet Enterprise product, which links SAP LOB applications to Offi ce via SharePoint BCS, illustrates how BCS can link diverse data sources.

“Duet itself is not new, but its use of BCS is, and since Duet Enterprise could fi nd a decently sized customer base, it will be a notable step toward legitimizing the BCS technology,” Sanfi lippo wrote.

One technology we might see less of in 2011, according to Sanfi lippo, is Windows Presentation Foundation (WPF). “With the introduction of out-of-browser support in Silverlight 3, WPF may have lost a lot of its remaining loyalists.”

What are your dev plans for 2011? E-mail me at [email protected]. VSM

Page 6: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

4 VISUAL STUDIO MAGAZINE · January 2011 · 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.

REDDEVNEWS.COM

Microsoft Unveils Silverlight 5 Beta FeaturesBY KATHLEEN RICHARDSSilverlight 5 offers improvements targeted at premium media experiences and enterprise apps, according to Microsoft. The public beta is slated for the fi rst half of 2011.

RedDevNews.com/Richards0111

Redmond Diary: SQL Azure FederationBY ANDREW BRUSTExplicit sharding support, or “Federation,” is expected in SQL Azure in 2011. With Federation, SQL Azure gains a highly popular feature of so-called document-oriented NoSQL databases, which claim

“Internet scalability.” Federating two notions of scale in one product seems representative of the Windows Azure approach overall: cloud computing with enterprise values.

RedDevNews.com/Brust0111

PHP Developers Get SQL Server, SQL Azure InsightsBY DAVID RAMELMicrosoft hosted 17 PHP developers from several countries at a SQL Server JumpIn! Camp. Database experts helped the developers, who worked on 10 representative projects, incorporate Windows, IIS, SQL Server and SQL Azure support into their apps.

RedDevNews.com/Ramel0111

ADTMAG.COM

Salesforce.com Announces Multi-Platform Enterprise Cloud DatabaseBY JEFFREY SCHWARTZDatabase.com, the underlying infrastructure for the Salesforce.com Sales Cloud, Service Cloud and Force.com, is aimed at powering cloud, social and mobile apps running on the company’s namesake service.

ADTmag.com/Schwartz0111

7 Key Factors for Successful Agile DevelopmentBY DAVID RAMELExpert Lisa Crispin offers her top tips for successful Agile development and testing. Crispin and a colleague surveyed the Agile community to fi nd out the key to successful Agile development and testing. Learn what they found.

ADTmag.com/Ramel0111

Best Careers for 2011BY BECKY NAGELU.S. News & World Report released an unranked list of 50 “high opportunity” careers for the upcoming year. Despite long hours and tight deadlines, computer software engineer made the cut, along with systems analyst, network architect and help support.

ADTmag.com/Nagel0111

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.)

Online Contents

ID Statement Visual 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 subscriptions are sent to qualifying subscribers. Annual subscription rates payable in U.S. funds for non-qualifi ed subscribers are: U.S. $35.00, International $60.00. Annual digital subscription rates payable in U.S. funds for non-qualifi ed subscribers are: U.S. $25.00, International $25.00. 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. Interna-tional 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 IMS/NJ. Attn: Returns, 310 Paterson Plank Road, Carlstadt, NJ 07072.

Copyright Statement © Copyright 2011 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 Disclaimer The information in this magazine has not undergone any formal testing by 1105 Media, Inc. and is distributed without any warranty expressed or implied. Implementation or use of any information contained herein is the reader’s sole responsibility. While the information has been reviewed for accuracy, there is no guarantee that the same or similar results may be achieved in all environments. Technical inaccuracies may result from printing errors and/or new developments in the industry.

Corporate Address 1105 Media, 9201 Oakdale Ave. Ste 101, Chatsworth, CA 91311 www.1105media.com

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

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

List Rental This 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.

VISUALSTUDIOMAGAZINE.COM

Practical ASP.NET: Extending the ListViewBY PETER VOGELVogel moves beyond the basics of setting up a ListView in his follow-up column to

“Working with ListView.” Learn how to add data-bound controls, control headers and footers, and turn on updating.

VisualStudioMagazine.com/Vogel0111

Inside TFS: Coded UI Tests BY MICKEY GOUSSETGousset fi nishes out his four-part series on coded UI testing in Visual Studio 2010 with some useful tips and tricks. He offers tips for recording your test, adding new assertions and changing the time between actions.

VisualStudioMagazine.com/Gousset0111

DevExpress ASP.NET MVC ExtensionsBY MICHAEL DESMOND

.NET components and tools provider Developer Express Inc. introduces a suite of 30 cross-browser, ASP.NET Model-View-Controller (MVC) extensions. The extensions support ASP.NET MVC 2.0 and jQuery, and can be used in Visual Studio 2008 and Visual Studio 2010.

VisualStudioMagazine.com/Desmond0111

Page 7: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

Free 60 Day Evaluation!www.leadtools.com/vsm

(866) 530-3399

Silverlight: 100% pure Silverlight 3, 4 and Windows Phone Imaging SDK. Image Formats & Compression: Supports 150+ image formats and compressions

including TIFF, EXIF, PDF, JPEG2000, JBIG2 and CCITT G3/G4. Scanning: TWAIN & WIA (32 & 64-bit), auto-detect optimum driver settings for high speed

scanning. Viewer Controls: Win Forms, Web Forms, WPF, Silverlight, ActiveX and COM. Image Processing:

supporting region of interest and extended grayscale data. Document Cleanup/Preprocessing: Auto-deskew, despeckle, hole punch, line and

border removal, inverted text correction and more for optimum results in OCR and Barcode recognition. Barcode: Auto-detect, read and write 1D and 2D barcodes for multithreaded 32 & 64 bit

development. OCR/ICR/OMR: Full page or zonal recognition for multithreaded 32 and 64 bit

development with PDF, PDF/A, XPS, DOC, XML and Text output. Forms Recognition & Processing: Automatically identify and classify forms and extract

PDF & PDF/A: Read, write and view searchable PDF with text, images, bookmarks and annotations. Annotations: Interactive UI for document mark-up, redaction and image measurement

(including support for DICOM annotations). DICOM:

(including Encapsulated PDF/CDA and Raw Data). PACS: Full support for DICOM messaging and secure communication enabling quick implementation of any DICOM SCU

and SCP services. Medical Image Viewer: High level display control with built-in tools for image mark-up, window level, measurement,

zoom/pan, cine, and LUT manipulation. Medical Web Viewer Framework: Plug-in enabled framework to quickly build high-quality, full-featured, web-based

medical image delivery and viewer applications. Medical Workstation Framework: Set of .NET medical and PACS components that can be used to build a full featured

PACS Workstation application.3D: Construct 3D volumes from 2D DICOM medical images and visualize with a variety of methods including MIP, MinIP,

MRP, VRT and SSD. Multimedia: Capture, play, stream and convert MPEG, AVI, WMV, MP4, MP3, OGG, ISO, DVD and more. Stream from

RTSP Servers.DVD: Play, create, convert and burn DVD images. DVR: Pause, rewind and fast-forward live capture and UDP or TCP/IP streams.MPEG Transport Stream: With DVR for UDP and TCP/IP streams & auto-live support.

Develop your application with the

same robust imaging

technologies used by

Microsoft, HP, Sony, Canon, Kodak, GE,

Siemens, the US Air Force and

Veterans Affairs Hospitals.

VectorDICOM Medical

MultimediaBarcodeDocument

Silverlight, .NET, WPF, WCF, WF, C API, C++ Class Lib, COM & more!

Form Recognition & Processing

Install LEADTOOLS to eliminate months of research and programming time while maintaining high levels of quality, performance and functionality. LEADTOOLS provides developers easy access to decades of expertise in color, grayscale, document, medical, vector and multimedia imaging development.

Untitled-2 1 12/13/10 4:18 PM

Page 8: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

6 VISUAL STUDIO MAGAZINE · January 2011 · VisualStudioMagazine.com

Silverlight Reactions In our December cover story, “Silverlight Futures,” developers expressed their views about Redmond’s aggressive promotion of HTML5 and awkward disclosure of a shift in Silverlight strategy. VSM readers are divided on the use of Silverlight for business apps going forward.

My team is no longer pursuing the use of Silverlight for corporate line-of-business (LOB) apps because it won’t work with the hardware that our users want to use: iPads, iPhones and Android devices. If Scott [Scott Guthrie, Silverlight lead and corporate VP of the Microsoft Developer Division] comes out and says that Android will support Silverlight, then I might reconsider—but I’m not going to tell upper management they need to purchase a different device to get to an internal LOB app. ASP.NET 5 should target the HTML5 spec, and I see how Microsoft is trying to infl uence pieces of the CSS spec (tinyurl.com/29oj3xc) to set up its tooling to render HTML5-compliant output. That’s a good thing to see the company starting to do because the next refresh of the IDE hopefully will contain all that—and more CSS3/JQuery support—to justify the upgrade. D.

N.Y.

There’s a lot of focus on the things that HTML5 will bring that can already be done in Silverlight video/audio/animation—but what about the things it can’t do, such as read and write to a database? Anyone developing a business application will soon be lost with a pure HTML5 solution if they can’t do this. To me one of the many benefi ts of Silverlight is that I can code the majority in .NET and I don’t have to bother too much with HTML, JavaScript and so forth. Matt

Stoke-on-Trent, United Kingdom

I’ve supported Microsoft for years, but this shift on Silverlight has forced me into silence. I can’t say to management that they should invest in any Microsoft technology if Microsoft is going to allow internal squabbling to shift its emphasis like this. I still use Silverlight, but I don’t recommend it. I stay silent and let the other architects push their approaches. Silverlight’s future is uncertain.

Posted Online

“With HTML5 promising native support for video and animation ...” Could you please explain why this is at all relevant to application development? How many business applications have—or could have—video? Zero. Silverlight is steeped in animations, and this is all very supportive. But I’ve never heard any customer complain about the lack of animations in their applications, whereas people quickly complain about too-apparent animations. So again, what difference does HTML5 make for application development? What’s really relevant to application developers is speed of development and customizability. With its controls, templates and data binding, this is where Silverlight really shines. Marc

Beaverton, Ore.

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 Check out our events at VSLive.comWe’ll be in Vegas, at Microsoft HQ and in Orlando in 2011

VisualStudioMagazine.comJanuary 2011 • Volume 21 • No. 1

Editorial Staff Vice President, Doug Barney Editorial Director Editor in Chief Michael Desmond Executive Editor Kathleen Richards Managing Editor Wendy Gonchar Associate Managing Editor Katrina Carrasco

Tools Editor Peter Vogel

Contributing EditorsAndrew J. Brust, Ken Cox, Kathleen Dollard,

Roger Jennings, Joe Kunk, Jeff Levinson, Bill McCarthy, Karl E. Peterson,

Patrick Steele, Bill Wagner

Art Staff Creative Director Scott Shultz Art Director Joshua Gould

Production Staff Director, Print Production Jenny Hernandez-Asandas Production Coordinator Serena Barnes

Online/Digital Media Director, Online Media Becky Nagel Executive Editor, New Media Michael Domingo Site Administrator Shane Lee Designer Rodrigo Muñoz

Advertising/Sales VP, Publishing Matt Morollo Regional Sales Manager Chris Kourtoglou National Accounts Director William Smith Microsoft Account Manager Danna Vedder

President Henry Allain Vice President, Publishing Matt Morollo Director of Marketing Michele Imgrund Online Marketing Director Tracy Cook

President & Neal Vitale Chief Executive Offi cer Senior Vice President Richard Vitale & Chief Financial Offi cer Executive Vice President Michael J. Valenti

Senior Vice President, Abraham M. Langer Audience Development & Digital Media Vice President, Christopher M. Coates Finance & Administration Vice President, Erik A. Lindgren Information Technology & Application Development Vice President, Carmel McDonagh Attendee Marketing Vice President, David F. Myers Event Operations

Chairman of the Board Jeffrey S. Klein

REACHING THE STAFFStaff may be reached via e-mail, telephone, fax, or mail. A list of editors and contact information is also available online at VisualStudioMagazine.com. E-mail: To e-mail any member of the staff, please use the following form: [email protected] Offi ce (weekdays, 9:00 a.m. - 5:00 p.m. PT)Telephone 949-265-1520; Fax 949-265-152816261 Laguna Canyon Road, Suite 130, Irvine, CA 92618Framingham Offi ce (weekdays, 9:00 a.m. - 5:00 p.m. ET)Telephone 508-875-6644; Fax 508-875-6633600 Worcester Road, Suite 204, Framingham, MA 01702Corporate Offi ce (weekdays, 8:30 a.m. - 5:30 p.m. PT)Telephone 818-814-5200; Fax 818-734-15229201 Oakdale Avenue, Suite 101, Chatsworth, CA 91311

Visual Studio MagazineThe opinions expressed within the articles and other contents herein do not necessarily express those of the publisher.

Page 9: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

Untitled-1 1 11/10/10 3:05 PM

Page 10: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

8 VISUAL STUDIO MAGAZINE · January 2011 · VisualStudioMagazine.com

VSToolbox

BY PETER VOGELThe DXperience ASP.NET bundle includes almost every control an ASP.NET developer will need. The controls show that Developer Express Inc. (DevExpress) understands what developers want, even if the support for client-side code is odd.

A Visual Studio Magazine Readers Choice Award winner in our November issue, Developer Express DXperience ASP.NET offers a host of well-designed controls that support developers effectively. Not only does it include docking and menu controls as well as a grid, the suite also has a complete set of controls for creating scheduling applications, a spellchecker, a chart control and a report viewer. And there are still more goodies, besides.

Throughout the DXperience package, there’s evidence that DevExpress under-stands the needs of application developers. For instance, rather than dump the controls into one enormous tab, the additions to the toolbox are organized into sensible groups.

As another example, the ASPxSiteMap-DataSource lets you create or edit your site

map from the control’s SmartTag. The site map editor that pops up analyzes your site structure to create a default site map. You can then drag nodes around to customize the site map. It’s a minor feature, but it’s also a feature that’s always been missing from Visual Studio. Adding custom elements or attributes to the site map is not supported, however.

The ASPxGridView supports editing and deleting rows as well as inserting new rows. Additional options allow users to sort and filter rows by providing criteria at run time. Developers can also define groups within the grid to generate subtotals, which—along with the sorting and filtering features—provide users with a simple interactive reporting tool.

All of the DXperience controls provide an extensive client-side object model that can be manipulated from JavaScript. You can access all the client-side events for a control from a control’s SmartTag, which pops up a dialog box that lists all the events for a control with a skeleton function for each event. The code you write is then

added to attributes on the control and is inserted into your HTML when the page is requested. While this makes it convenient to both enter and find client-side, event-driven code (and protects you against changes in the control’s name), it also locks you off from the enhancements that Visual Studio has made to its support for JavaScript code.

Many controls include a template CSS stylesheet, which references the control’s CSS classes. You can incorporate that template’s entries into your site’s stylesheet hierarchy and modify it to apply your styles to those portions of the control’s HTML.

Given the number of controls involved, effective documentation is essential. By default, no Help support is installed on your computer—it must all be accessed over the Internet. A separate download will install the Help documentation on your computer. A link in the DevExpress menu entry will take you to the company’s Demo Center, which has a huge selection of demos, all with source code (the Help file includes numerous examples, too).

Not surprisingly, the first time you start Visual Studio after installing the package, you’ll find that you must wait while the package infrastructure initializes. Don’t panic! Subsequent startups will return to your normal experience—except that you’ll have all of these cool new controls at your fingertips. VSM

Peter Vogel ([email protected]) is the tools editor for VSM and a principal in PH&V Information Services, specializing in ASP.NET development.

DX

per

ien

ce

AS

P.N

ET

</DevInsight>

Accessible from the ASPxSiteMapDataSource, the Site Map Editor that’s included in the DXperience suite lets you generate a site map using drag and drop.

DXperience ASP.NET

Developer Express Inc.Web: devexpress.comPhone: 818-844-3383Price: $799Quick Facts: A large set of controls covering the needs of most ASP.NET developers in one packagePros: Throughout, the controls reveal an understanding of what developers need to build applicationsCons: Support for JavaScript client-side events doesn’t integrate well with Visual Studio

Inside Developer Express DXperience ASP.NETThe award-winning component suite is a powerful tool for ASP.NET app development.

Page 11: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

0810vsm_GrapeCity_Insert.indd 1 10/4/10 10:48 AM

Page 12: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

0810vsm_GrapeCity_Insert.indd 2 10/4/10 10:48 AM

Page 13: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

VisualStudioMagazine.com · January 2011 · VISUAL STUDIO MAGAZINE 9

BY PETER VOGELThere are almost 100 controls in the NetAdvantage for .NET: Windows Client suite from Infragistics. In addition to the usual controls (enhanced grids, listboxes, buttons and so on), you’ll find controls from a reporting dashboard (the UltraGauge) to a project management solution (UltraGanttView).

Lots of little things in the controls show attention to what matters to developers. For instance, you can quickly set the appearance of a control using its DisplayStyle property. The options on that control reflect the typical display styles a Windows developer would want, including presets that mimic every version of Office from XP to 2010.

Like any useful set of controls, the Infragistics controls reduce your need to write code for common tasks. To control data entry, for instance, you have an advanced masked edit control, but also dedicated controls for checking dates, numbers and currency. A validation control allows you to centralize error checking.

Some controls have no equivalent in the standard toolbox. The UltraCalcManager allows you to define a formula that takes its inputs from other controls on the form. When those controls change value, the UltraCalcManager recomputes the formula, putting the result in other controls. Because the UltraCalcManager is a control extender, you can use it with the basic controls that come with the Microsoft .NET Framework. The manager takes care of handling null/invalid entries and catching events, letting you concentrate on what matters: getting the formula right.

One drawback is organization. There are nearly 100 controls here, yet all of them are housed in a single tab. What’s worse, almost all the controls have names that begin with the same five letters—“Ultra”—which makes finding the control you want difficult. VSM

Peter Vogel ([email protected]) is the tools editor for Visual Studio Magazine and a principal in PH&V Information Services, specializing in ASP.NET development.

</DevInsight>

VSToolbox

The Suite-Free LifeIf you want to buy controls from Infragistics Inc. or Developer Express Inc., you have to buy a suite. But if all you need is a tree, why buy a forest? Smaller companies still sell single controls.

The fi rst third-party control that most ASP.NET developers buy is a replacement for the GridView (something that supports adding new rows, for instance). Axezz will sell you its AxpDataGrid for $145 (single developer license). On the Windows Forms side, PureComponents has the LightGrid control for Windows Forms, and you can buy 10 of its unlimited site licenses for the cost of the cheapest suite I’ve reviewed.

If you’re an ASP.NET MVC developer, you can also buy “just a grid” from Syncfusion Inc. The company’s Essential Grid sells for $900, which is about 33 percent less than the complete Developer Express suite. But Model-View-Controller (MVC) developers should also consider DevExpress ASP.NET MVC Extensions, which shipped in December and includes 30 controls. —P.V.

ToolTracker

Size Matters with Infragistics NetAdvantage for .NET: Windows Client SuiteThe suite continues to deliver tons of controls that Windows Forms developers want to use—but organization could be improved.

NetAdvantage for .NET: Windows Client

Infragistics Inc.Web: infragistics.comPhone: 800-231-8588Price: $995 (standard support), $1,995 (priority support)Quick Facts: An enormous collection of Windows forms controls that go far beyond the default controlsPros: Almost 100 controls, including controls for project management, reporting dashboards and scheduling that reduce coding for developersCons: No organization of the controls in the toolbox; finding the control you want (or if the control even exists) is a challenge

Don’t undervalue the suite because it has only a single gauge control. The control can switch between digital, linear and radial presets, which you can then customize.

Net

Adv

anta

ge

for

.NE

T

Page 14: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

Untitled-6 2 12/14/10 11:43 AM

Page 15: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

Untitled-6 3 12/14/10 11:43 AM

Page 16: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

12 VISUAL STUDIO MAGAZINE · January 2011 · VisualStudioMagazine.com

On Dec. 2, 2010, at the Silverlight Firestarter event, we unveiled Silverlight 5. It adds more than 40 new features and enables developers to create premium media experiences and deliver rich applications across browsers, desktops and devices. In the keynote we demonstrated a number of those features, and highlighted both the developer productivity Silverlight 5 provides and the great new user experiences it enables.

Premium Media ExperiencesWe’re seeing great adoption of Silverlight for premium media solutions. In the last few months we’ve seen companies like Canal+, TV2 and Maximum TV launch both live and on-demand Silverlight solutions. Silverlight 5 will enable media experiences to go even further by adding:

Hardware Video Decode: Silverlight 5 now supports GPU-accelerated video decode, which significantly reduces CPU load for HD video. Using Silverlight 5, even low-powered netbooks will be able to play back 1080p HD content.

TrickPlay: Silverlight 5 now enables variable speed playback of media content on the client with automatic audio pitch correction. This is great for training videos where you want to speed up the trainer while still understanding what he’s saying.

Improved Power Awareness: Prevents screensavers from kicking in while you’re

watching movies, while also allowing the computer to sleep when video isn’t playing.

Remote Control Support: Now built in to Silverlight 5, this allows users to control media playback with remote control devices.

Application DevelopmentSilverlight provides a rich application development environment that enables you to build great Web-delivered applications. Silverlight 5 delivers significant improvements for application development, including:

Data Binding and Model-View-View-Model (MVVM): Silverlight 5 delivers significant data-binding improvements that enhance developer productivity and provide better Silverlight/Windows Presentation Foundation (WPF) feature convergence. Developers can now debug data-binding expressions, set breakpoints on bindings and more easily determine errors. Implicit DataTemplates now allow templates to be created across an application to support a particular type by default. Ancestor RelativeSource bindings make it easier for a DataTemplate to bind to a property on a container control. Binding in style setters allows bindings to be used within styles to reference other properties. And a new DataContextChanged event is being introduced to make handling changes easier. Markup extensions also now support and allow code to be run at XAML parse time for both properties and event handlers, enabling cutting-edge MVVM support.

WCF RIA Services: Silverlight 5 now includes WS-Trust support. WCF RIA Services improvements include complex type support, better MVVM support and improved customization of code generation. The Silverlight 5 networking stack also supports low-latency network scenarios that enable more responsive app scenarios.

Text and Printing: Silverlight 5 delivers improved text clarity that enables crisper and cleaner text rendering, multi-column text flow and linked text containers, character and leading support, and full OpenType font

support. Silverlight 5 also includes a new Postscript Vector Printing API that provides programmatic control over what you print, and enables printing richer reports and documents. Pivot functionality—which enables developers to build amazing information-visualization experiences—will also be built in to the Silverlight 5 SDK.

Graphics: Silverlight 5 includes immediate- mode graphics support that enables developers to take full advantage of the GPU and enables accelerated 3-D graphics support. This new support facilitates much richer data visualization scenarios. Watch the keynote (tinyurl.com/2e4c8q7) to see some really eye-popping ones. 

Out of Browser: Silverlight 5 builds on the out-of-browser capabilities we introduced in previous versions. Out-of-browser applications can now create and manage child windows. Trusted out-of-browser applications can now also use P/Invoke capabilities to call unmanaged libraries and Win32 APIs. Enhanced Group Policy support enables enterprises to both lock down and open up the security sandbox capabilities of Silverlight 5 apps.

Testing Tools: We’re adding automated UI testing support for Silverlight applications with Visual Studio 2010. This makes it easy to test Silverlight applications, as well as automate the functionality of them.

Performance: Silverlight 5 supports faster application startup and provides 64-bit browser support. Silverlight 5 also integrates with the new Hardware Acceleration capabilities of Internet Explorer 9, and enables hardware acceleration in windowless mode.   

A Silverlight 5 beta will be available in the first half of this year, and the final release will ship in the second half of 2011. The final product and features included will be dependent on feedback and testing that comes from the beta process. VSM

Brad Becker is director of product management, Client Platforms, at Microsoft.

Sil

ver

ligh

t 5

</DevInsight>

VSInsiderA Look at Silverlight 5

BY BRAD BECKER

Page 17: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

Untitled-5 1 12/14/10 11:45 AM

Page 18: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

VSM COVER STORY

A look inside the critical technologies and tools that will shape .NET development over the next year.

BY MARK MICHAELIS, MICHAEL DESMOND, KATHLEEN RICHARDS & PETER VOGEL

Since the arrival of Visual Studio 2010 and the Microsoft .NET Framework 4 in April 2010, the pace of advancement in the .NET development space has been nothing short of torrid. Silverlight has continued to iterate at a near-frantic clip, even as Microsoft moved swiftly to mature disparate platforms like ASP.NET MVC, Windows Phone 7 and Windows Azure. From the handset to the cloud, developers face a dizzying array of choices and alternatives.

2011 will be a critical year for many dev shops, as they look to commit to the tooling Microsoft released the year before. Whether it’s wrestling with a move from Windows Forms to Windows Presentation Foundation (WPF) or Silverlight, or weighing the costs and benefits of shifting from LINQ to Entity Framework, the stakes involved in many of these decisions are incredibly high.

To help .NET developers cope, we look at seven distinct development areas and the technologies and trends shaping them in the year ahead.

14 VISUAL STUDIO MAGAZINE · January 2011 · VisualStudioMagazine.com

Page 19: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

Untitled-5 1 12/14/10 11:46 AM

Page 20: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

16 VISUAL STUDIO MAGAZINE · January 2011 · VisualStudioMagazine.com

.NET Survival Guide

Web and RIA DevelopmentBY PETER VOGEL

If you’re willing to sacrifi ce some productivity for enhanced control over your HTML and the benefi ts of TDD in the presentation layer, then

a move to ASP.NET MVC may be in order.

Microsoft’s latest announcements make it clear that, when it comes to delivering applications over the Web, the choices for the .NET devel-oper are ASP.NET and ASP.NET MVC. Silverlight may have a future in mobile development, but it’s no longer a primary platform for the Web.

If you’re happy with the auto-generated HTML and pre-packaged functionality of server-side controls (and don’t see the benefit of using Test-Driven Development [TDD] for your UI) then you are well-covered with ASP.NET. If you’re willing to sacrifice some pro-ductivity for enhanced control over your HTML and the benefits of TDD in the presentation layer, then a move to ASP.NET MVC may be in order. Call the two approaches “ASP.NET *.”

What new challenges await? In addition to becoming proficient in developing on the server using your choice of ASP.NET *, developers must know HTML5, JavaScript and Windows Communication Foundation (WCF). The reason for this change is that the future is moving away from the HTTP request/response cycle. The new para-digm involves sending lightweight Web service requests to the server and getting lightweight responses back. JavaScript manages both that conversation and integrating the calls with a UI written in HTML5 to produce the rich Internet application (RIA) that users are coming to expect. But this toolset isn’t just about enhancing the user experience: The more you can do at the client, the less you have to do at the shared resource that is the server, which directly addresses scalability.

While both groups will need to become familiar with HTML5, ASP.NET MVC developers will need to be more deeply involved. All ASP.NET * developers are going to need both client-side and server-side toolkits. That’s going to include knowing jQuery and, in all probability, some client-side testing tool.

WCF is the Microsoft platform-of-choice for developing Web ser-vices (though the old .asmx-based technology still works). Becoming familiar with WCF, especially when integrating with JavaScript calls, is critical. This will include being able to implement different levels of authorization and authentication, among other application develop-ment standards. While the WCF templates in Visual Studio take care

of many of the ugly details, ASP.NET * developers who know how to build high-performance WCF services will build better service- oriented architecture (SOA) applications than those who don’t.

Beyond the technologies involved, developers are also going to have to think architecturally, both about the relationship between the server and the client (think SOA) and what goes on inside the client. The browser is no longer (if it ever was) a passive client that receives and displays HTML. Rather than just being a “view,” the browser is now a client-side application that interacts with server-side resources.

The challenge in ASP.NET will be in working with server-side controls that have a rich client-side object model. In ASP.NET MVC, it’s about building up a toolkit of “pure” client-side objects that are as diverse, powerful and as easy to implement as the ASP.NET server-side controls.

All ASP.NET * developers will need to develop a rich set of pat-terns and best practices for developing client-side JavaScript code that works effectively in the .NET environment of choice. The same discipline that these developers apply in creating server-side applications is going to be required in the client—simply writing more and more functions isn’t going to be good enough any more.

If all this talk about client-side resources suggests that server-side development isn’t important, that’s not the intention. It’s just that the client-side development effort has become as important as what you put in your .aspx (and .svc) code files.

In SummaryWith Silverlight waning as a cross-platform Web development target, the future belongs to ASP.NET and ASP.NET MVC. Developers valuing TDD and close control over HTML code will favor MVC, but all will benefi t with mastering WCF and JavaScript.

Tool Box■ ASP.NET■ ASP.NET MVC■ JavaScript■ Windows Communication Foundation■ Silverlight■ HTML5

COVER STORY

Line-of-Business DevelopmentBY MICHAEL DESMOND

Silverlight 5, expected to release in beta form in the fi rst half of 2011, will provide improved WCF RIA Services and networking, including

the addition of WS-Trust security support.

Microsoft’s efforts to improve mobile, Web and cloud application development have captured a great deal of mindshare over the past year. Yet even as Microsoft pushes the boundaries of its developer tooling, the company’s focus on its core line-of-business (LOB)

Continued on Page 18

Page 21: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

Untitled-5 1 12/14/10 11:44 AM

Page 22: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

18 VISUAL STUDIO MAGAZINE · January 2011 · VisualStudioMagazine.com

developer community remains strong. The release of Visual Studio 2010 and the .NET Framework 4 in April significantly advanced Microsoft’s .NET tooling for LOB developers. The core develop-ment environment added the rich, WPF-based Editor and the Managed Extensibility Framework (MEF) for enabling extensions to the base IDE. The .NET Framework 4 included updated versions of the C# and Visual Basic languages, which added dynamic features, as well as new capabilities in WPF, WCF and Windows Workflow Foundation (WF).

Not far removed from the Visual Studio/.NET update, Microsoft released new versions of Office (2010), SharePoint (2010) and SQL Server (2008 R2). All three releases have a significant impact on developer decision making in the rich client space. For instance, Microsoft moved decisively to bring the SharePoint application development and deployment experience on par with traditional .NET programming. Likewise, the Business Connectivity Services (BCS) incorporated into Office and SharePoint 2010 have enabled rich data connectivity across diverse endpoints, easing a key limitation for building data-heavy productivity applications for these environments.

The most intriguing technology in the rich LOB dev space is undoubtedly Silverlight, which has evolved rapidly into a capable platform for business application development. Silverlight’s role as the Microsoft cross-platform runtime for Web application delivery may be changing, but it continues to gain on WPF as the premier target for XAML-based development on the desktop. Silverlight 5, expected to release in beta form in the first half of 2011, will provide improved WCF RIA Services and networking, including the addition of WS-Trust security support. It will also provide improved application performance, greater integration with local system resources both in and out of browser, and additional graphic enhancements such as hardware-based acceleration.

For dev managers, the question of WPF or Silverlight has largely been answered, as Silverlight has climbed the XAML feature stack to address the vast majority of application scenarios previously addressed only by WPF. Support for WCF RIA Services and rich OData integration gives Silverlight a mature and robust mechanism for handling data-heavy business apps. And the ability to share code across Web, Windows Phone 7 mobile and desktop Silverlight projects is very compelling. And, unlike WPF, Silverlight apps can run on Mac OS-based systems.

Microsoft has also moved to support LOB development via Visual Studio LightSwitch, a wizard-driven app building environment intended to enable power users and business analysts to produce manageable .NET code. While LightSwitch will have negligible impact on mainstream .NET coders, the tool provides a ramping point to take one-off or departmental information solutions and graduate them to the enterprise application stack.

In SummaryMajor updates to Visual Studio, .NET Framework, Offi ce and SharePoint in the past year have reshaped LOB app development. But the emergence of Silverlight as a mature conduit for robust XAML code could be a game changer in 2011 and 2012.

Tool Box■ Visual Studio 2010■ .NET Framework 4■ Silverlight/Windows Presentation Foundation■ SharePoint 2010■ Offi ce 2010■ Visual Studio LightSwitch■ SQL Server 2008 R2

Multi-Core and Parallel DevelopmentBY MARK MICHAELIS

Although not implicitly invoked, .NET Framework 4 provides signifi cant improvement

in the multithreading APIs available by intro-ducing two entirely new API sets: Task Parallel

Library (TPL) and Parallel LINQ (PLINQ).

In 2011 even low-end laptops come with two cores and, at the high end, eight and even 16 cores aren’t uncommon. Similarly, you would be hard-pressed to find a server that didn’t have at least support for two CPUs and a minimum of four cores in each CPU. In other words, the hardware today’s applications run on include multiple processors by default. Despite this fact, programming languages today don’t take advantage of the computing power implicitly. Whether you’re writing a WPF application or a command-line

console, the default is for your code to execute in a single thread. Admittedly, when hosting in IIS (or AppFabric), there will be multiple threads running for each session or call. Even so, any CPU-intensive task that your code engages in won’t be multi-threaded or executed asynchronously by default.

Although not implicitly invoked, the .NET Framework 4 provides significant improvement in the multithreading APIs available by introducing two entirely new API sets: Task Parallel Library (TPL) and Parallel LINQ (PLINQ). These APIs are so significant—both in the usability of the API and in the underlying implementation improvements—that access to the earlier .NET multithreading APIs (those from System.Threading) can essentially be ignored unless you’re required to support legacy platforms or code. The only exception worth mentioning is the API call to System.Threading.Thread.Sleep,

.NET Survival GuideCOVER STORY

Continued on Page 20

Page 23: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

Untitled-5 1 12/14/10 11:45 AM

Page 24: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

Untitled-3 2 12/2/10 10:47 AM

Page 25: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

Untitled-3 3 12/2/10 10:47 AM

Page 26: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

22 VISUAL STUDIO MAGAZINE · January 2011 · VisualStudioMagazine.com

but even this should be avoided where possible, as the milliseconds parameter is unlikely to remain accurate across myriad machines.

TPL provides a new primary threading class called System.Thread-ing.Tasks.Task that essentially replaces System.Threading.Thread for the vast majority of scenarios in the .NET Framework version 3.0 and 4. Even those running 3.0 have access to TPL and PLINQ through the unsupported release, by Microsoft, of the Reactive Extensions to

.NET. Similarly, PLINQ provides a compelling solution for executing LINQ to Objects (in memory queries that use LINQ with IEnumerable<T> rather than a LINQ provider that implements queries with IQueriable<T>). With only a call to the System.Thread- ing.Tasks.ParallelEnumerable.AsParallel extension method, LINQ queries are transformed to run in parallel.

One question that surfaces is: Why don’t the multithreaded APIs get invoked implicitly by the runtime or language compiler? The core reason is that there’s still a fundamental programming problem around race conditions and dead-locks: multithreading bugs. Without intentional thread synchronization, the likelihood of these bugs occurring is too high. This, combined with the complexity involved in testing for and reproducing multithreading bugs, makes both language and API designers shy away from multithreading implicitly.

The .NET Framework 4 does provide some new collection classes that support synchronization by default, but the complexities around even just knowing when to use these collections in place of their non-threadsafe cousins is still a niche skill. The result is that TPL and PLINQ are fantastic additions to the .NET Framework 4, but caution is still called for, and developers must expend significant effort to do quality multithreaded programming.

In SummaryTask Parallel Library and Parallel LINQ are signifi cant and important advancements in parallel programming, but the risks and challenges involved in creating multithreaded apps remains.

Tool Box■ Task Parallel Library (TPL)■ Parallel LINQ (PLINQ)■ System.Threading.ThreadPool■ System.Threading.Thread ■ Reactive Extensions to .NET (Rx) ■ Async language support

Mobile and Windows Phone 7BY KATHLEEN RICHARDS

Porting smaller versions of Silverlight 4 apps to Windows Phone and code sharing among

Silverlight applications is a benefi t to developers who are already familiar with the platform.

After a watershed year in 2010, .NET developers can finally put their programming skills to use to create and sell apps for the Windows Phone 7 platform, introduced last February and available in Windows Phones in the United States since early November. The Windows Phone 7 OS, which is built on the .NET Compact Framework, severs ties with Windows Mobile 6.x. Instead, it runs out-of-browser apps created with managed code in Silverlight for Windows Phone. Game developers can also use XNA Game Studio to develop or port games that leverage Xbox Live functionality.

If you decide to test your skills in mobile, this is your chance to get your app into the Windows Phone Marketplace using familiar tooling and programming skills (C#, Visual Basic and XAML) to build event-driven applications in Silverlight for Windows Phone. Microsoft has indicated that 3,000 apps—give or take—have already been accepted into the Windows Phone Marketplace.

Silverlight for Windows Phone is a subset of Silverlight 3 with added support for phone-specific functionality, such as gesture-aware controls, sensors, microphones and webcams, Microsoft Notification Service, Location Service and Software Input Panel through the Text-box control. Apps are hosted on the device—not inside the Internet Explorer mobile browser—so there’s no need for JavaScript, HTML DOM or the plug-in object reference.

The first Windows Phones are targeted at consumers. Expect to hear more about the enterprise next month when Steve Ballmer gives a keynote at the Mobile World Congress. The current platform features an Office hub with Excel, Word, OneNote, SharePoint integration and networking in Silverlight, with WCF, HttpWebRequest and WebClient. WCF and LINQ are supported in the .NET Compact Framework, but not from customized data sources.

Microsoft is expected to offer updates to the Windows Phone 7 OS starting this month. According to developers with access to previews, copy-and-paste functionality is expected in the first upgrade. Microsoft has indicated plans to broaden network sup-port beyond GSM to CDMA technology (Verizon and Sprint). Devices from HTC, Samsung, LG Electronics and Dell that run on GSM networks (AT&T and T-Mobile) started to ship during the 2010 holiday season.

Porting smaller versions of Silverlight 4 apps to Windows Phone and code sharing among Silverlight applications is a benefit to developers who are already familiar with the platform. Attention to details around parity—for example, IIS Streaming has a unique implementation on Windows Phone and behaves differently—and understanding hardware limitations can help to minimize migration issues. Windows Phone at launch supports hardware-accelerated H.264 video with digital rights management.

Despite different manufacturers, Windows Phones are designed to offer consistent user experiences based on Microsoft hardware specifications: Qualcomm 1 GHz Cortex/Scorpion (Snapdragon)

.NET Survival GuideCOVER STORY

Continued on Page 24

Page 27: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

DESIGNDesign Applications That Help Run the Business

Our xamMap™ control in Silverlight andWPF lets you map out any geospatialdata like this airplane seating app tomanage your business. Come toinfragistics.com to try it today!

Infragistics Sales 800 231 8588 Infragistics Europe Sales +44 (0) 800 298 9055 Infragistics India +91 80 4151 8042

@infragistics

Untitled-6 1 11/10/10 11:41 AM

Page 28: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

24 VISUAL STUDIO MAGAZINE · January 2011 · VisualStudioMagazine.com

processor, 256MB RAM, 8GB Flash, DirectX 9 acceleration and 5MP camera. Developers can additionally tap into interfaces and sensors that support standard phone functionality such as Bing mapping and search, A-GPS, accelerometer (tilt and motion) and camera. The location API works with Windows Azure cloud services.

Challenges for developers may arise from the smaller screen displays (800x480 resolution [WGA] at launch), lack of access to native code in the OS or data storage in SQL Server Compact Framework—part of the Windows Phone platform, according to Microsoft, but currently not surfaced for developers. Performance issues related to network connectivity, power management and memory usage also need to be taken into consideration.

Understanding the navigation framework and creative thinking around input mechanisms beyond the mouse and keyboard can increase your odds of success. Windows Phones support capacitive touchscreens with four contact points. If you’re not familiar with multi-touch (Touch.Frame.Reported), now’s the time to get started. Silverlight for Windows Phone supports a subset of the manipulation events in the Surface SDK.

Visual Basic for Windows Phone 7 Developer Tools was released in late November. The Visual Basic tools, which require Visual Studio 2010 Professional or higher, are targeted at Silverlight for Windows Phone development only—Visual Basic doesn’t support XNA. At press time, the Visual Basic templates for use in Visual Studio 2010 couldn’t be shared with Expression Blend.

With the shift in Microsoft Silverlight strategy, .NET developers’ mobile opportunities outside the Microsoft stack appear somewhat limited. Despite pleas from developers, Silverlight support on Android

has not materialized. Android 2.2 has supported Flash 10.1 since last July. The .NET community can develop applications in C# in Visual Studio 2010 for Android-based devices starting this year. MonoDroid, a Novell (now Attachmate) plug-in to Visual Studio, is under development; version 1.0 is expected sometime in 2011. MonoTouch, which offers a way to build .NET applications on the Mac for the Apple iPhone, iPod Touch and iPad, was released in 2009.

Delivering Web content and LOB apps that are easily consumed by a myriad of mobile devices is a reality facing more enterprises in 2011. Mobile Web development continues to gain immediacy with the growing popularity of feature-rich smartphones and tablets such as the Apple iPad, which now serve as the primary gateway to the Internet for much of the workforce.

In SummaryDevelopers who have stayed away from mobile app development and the mobile Web have no choice in 2011 but to prepare for the sea change ahead.

Tool Box■ .NET Compact Framework■ Silverlight for Windows Phone■ Expression Blend ■ Multi-touch ■ XNA Game Studio/XNA■ MonoDroid■ MonoTouch

Cloud and Software as a ServiceBY MARK MICHAELIS

Windows Azure AppFabric does require some application tweaks to make the jump, but as the technology improves, this pain point will

almost certainly diminish.

Cloud computing solutions vary considerably, yet claim superior privacy, security and scalability over on-premises deployments that also require the expense of an IT department to manage them. Different cloud approaches differ in implementation, however, with various models allowing for the renting of rack space, dedicated servers, virtual machine (VM) time and even application CPU time. This diversity of cloud computing solutions can be broken down into three primary categories, each building on top of the other:

• Infrastructure as a Service (IaaS): IaaS provides the hardware (rack space, servers, network connectivity, electrical power and so on) along with the base OS installation and (option-ally) database platforms. Customers with this level of service generally have remote access to the environment, along with the responsibility for all software-related installation, updates and configuration. Support for scalability is through the explicit requisitioning of additional hardware and then

configuration to manage and enable the scalability. Examples: Amazon Web Services and Windows Azure Virtual Machine Role

• Platform as a Service (PaaS): PaaS enables the deployment of applications into a hosting environment on which the appli-cations run. It includes automated service management with application-lifetime management, load balancing, platform patches and more, leaving only configuration of the app to the customer. PaaS allows the application to automatically scale to demand, so that even the concept of how many servers are executing the application is abstracted away.

Examples: Microsoft Azure AppFabric and ASP.NET Hosting • Software as a Service (SaaS): This is where an application

itself is hosted and customers subscribe to the functionality of the application. Although the application may be deployed across a myriad of devices and locations, the customer just sees it as a software application that’s available when needed.

Examples: Gmail, bing.com and Microsoft Office 365PaaS provides the ideal solution for developers working to enable

SaaS deployments for their organizations. PaaS enables focus on an app’s business value, rather than the necessary but auxiliary infra-

.NET Survival GuideCOVER STORY

Continued on Page 26

Page 29: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

DEVELOPRich Business Intelligence Applications in WPF and Silverlight

Infragistics Sales 800 231 8588 Infragistics Europe Sales +44 (0) 800 298 9055 Infragistics India +91 80 4151 8042

@infragistics

Robust Pivot Grids for WPF andSilverlight let your users analyze datato make key business decisions.Visit infragistics.com to try it today!

Untitled-6 1 11/10/10 10:57 AM

Page 30: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

26 VISUAL STUDIO MAGAZINE · January 2011 · VisualStudioMagazine.com

structure that hosts the app. PaaS also provides companies with the lowest level of commitment needed to provide SaaS to their customers.

There are some drawbacks to consider with PaaS, though these are growing less severe over time. First, there remains a significant level of complexity when it comes to managing connections to other applications that are still running on-premises. Providing secure access to intranet-based LOB systems is still non-trivial. Similarly, if data storage sizes are large, the costs of storage in the cloud can appear expensive.

PaaS platforms such as ASP.NET Hosting generally provide smooth migration of identical code from your own premises into the cloud. Windows Azure AppFabric does require some applica-tion tweaks to make the jump, but as the technology improves, this pain point will almost certainly diminish. In both cases, there’s an on-premises means for development testing prior to deployment, which is important because deploying to solutions such as Windows Azure is generally an order of magnitude slower than deploying to an on-premises server. This factor, coupled with the possibility that running in the cloud could expose discrepancies with the on-premises behavior, makes automated deployment (using Windows Azure SDK-provided Windows PowerShell cmdlets) an important time-saver in the ALM process.

There’s little doubt that for startup organizations, the cloud is an intriguing target for application development. However, cloud computing may not make sense for organizations that have con-siderable investment in their own datacenters. In either case, managers must factor in the on-premises costs of disaster recovery, IT support staff, security, scalability and highly available connec-tivity when making a decision.

In SummaryMicrosoft AppFabric and ASP.NET Hosting promise a seamless path for ASP.NET applications to reside both on-premises and in the cloud.

Tool Box■ ASP.NET Hosting ■ Microsoft Azure AppFabric■ SQL Azure (with OData support)■ Azure Service Bus■ Software as a Service■ Windows Communication Foundation

Data Access TechnologiesBY MARK MICHAELIS

Prior to the .NET Framework 4, gaps in the fi rst version of Entity Framework made it

a less-than-perfect solution. Microsoft has resolved many of those shortcomings with

the Entity Framework 4.

The frequency with which Microsoft has changed database access technologies is remarkable, with each new scheme offering the promise that .NET developers have finally arrived at a long-term solution. The core problem with the .NET Framework was that although there was a strong database access technology provider in ADO.NET, it failed to deal with the key pain point for developers: object-relational mapping (ORM). Specifically, how the data repre-sented in an object-oriented programming language such as C# or Visual Basic .NET serializes into a relational database. Although there were numerous solutions available in 2007, none truly dealt with the problem of eliminating the need for SQL and of SQL schema seeping into the client-side programming language.

Visual Studio 2008 and the .NET Framework 3.0 changed this situation radically. For the first time mainstream .NET development had a superb mechanism, in the form of LINQ, for programming the object-relational impedance mismatch. Although Visual Studio 2008 presented two database LINQ solutions—LINQ to SQL and the Entity Framework—Visual Studio 2010 addressed this ambiguity with the Entity Framework 4. Microsoft has essentially deprecated LINQ to SQL. Though Prominent ORM alternatives exist in

NHibernate and LLBLGen Pro, the Entity Framework 4 has emerged as the most logical data access target for .NET developers. This leaves developers with four prudent options when developing under the .NET Framework 4:

• Leave existing development on LINQ to SQL but search for an opportunity to migrate to the Entity Framework.

• Leave ADO.NET development in place, but capitalize on any opportunities to implement with the Entity Framework.

• Commit to using the Entity Framework by default for database-access development going forward, outside of exceptional cases.

• Consider widely deployed alternatives like NHibernate and LLBLGen Pro, which boast features and support that rival those of the ORM technologies coming from Microsoft.

Prior to the .NET Framework 4, gaps in the first version of the Entity Framework made it a less-than-perfect solution. Microsoft has resolved many of those shortcomings with the Entity Framework 4. Among the significant new features making the Entity Framework 4 a credible data access target:

• Foreign Key properties on entities allow for accessing data associated with foreign key relationships.

• Plain Old CLR Objects (POCO) can be generated, using online templates, so that no special entity framework deri-vation or attribution is required.

• Text Template Transformation Toolkit (T4) Code Generation enables deep customization of the entities that are generated

.NET Survival GuideCOVER STORY

Continued on Page 28

Page 31: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

EXPERIENCEBeautiful Data Visualizations That Bring Your Data to Life

Use our Motion Framework™ to see yourdata over time and give your users newinsight into their data. Visit infragistics.comto try it today!

Copyright 1996-2010 Infragistics, Inc. All rights reserved. Infragistics, the Infragistics logo and NetAdvantage are registered trademarks of Infragistics, Inc.Motion Framework is a trademark of Infragistics, Inc.

Infragistics Sales 800 231 8588 Infragistics Europe Sales +44 (0) 800 298 9055 Infragistics India +91 80 4151 8042

@infragistics

Untitled-6 1 11/10/10 10:57 AM

Page 32: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

28 VISUAL STUDIO MAGAZINE · January 2011 · VisualStudioMagazine.com

from the database, and the ability to even generate the data-base given a set of POCO objects.

• Lazy Loading, enabled by default, doesn’t load an entire object or its graph until the code actually uses it.

• Improved stored-procedure support, which is accessed through member functions on an entity, allows for such features as returning complex types from stored procedures.

• Enhanced support for entities that are disconnected from the Entity Framework context and possibly transferred across WCF boundaries—even with support for change tracking within the entity.

• Inclusion of interfaces like IObjectSet<T> that enable the development of mock data layers.

These new features, all of which are very significant to the vast majority of database development scenarios, provide a compelling

narrative for the Entity Framework 4. In addition, Microsoft continues to provide interim community technology previews of future enhancements slated for the Entity Framework.

In SummaryAfter some fi ts and starts, Microsoft has landed on a viable target for .NET data access in the form of Entity Framework 4.

Tool Box■ ADO.NET■ LINQ to SQL ■ Entity Framework ■ NHibernate■ LLBLGen Pro

Application Lifecycle DevelopmentBY MARK MICHAELIS

Even if a development team only needs a portion of the TFS suite, the individual pillars

certainly have a lot to off er.

Application Lifecycle Management (ALM) is a critical measure of a team’s maturity and development effectiveness. Even teams of only two and three can benefit from a good ALM process and the tools to support it. Fortunately, modern day development has some excellent tooling for all phases of ALM—both on the developer workstation side and on the server side—enabling data sharing between team members.

Not surprisingly, Microsoft offers excellent solutions at both locations. On the workstation, Microsoft leads the tooling with a well-

established, best-of-breed IDE in Visual Studio 2010. It not only includes a fantastic code editor, but also a strong suite of additional functionality (how much functionality varies depending on which Visual Studio SKU you purchase). Additions include unit testing, code coverage, coded UI testing, static code analysis, code metrics, performance profiling, architecture design tools and IntelliTrace.

With such a plethora of excellent tools to increase the quality, perhaps the most challenging part is having the discipline—especially with unit testing—to use them all. In spite of the vast list, there’s still room to consider additional third-party tooling such as TypeMock, NUnit, NDepends, Resharper, CodeRush, Reflector and other solutions.

Team Foundation Server (TFS) is well-established in the main-stream when it comes to sharing and collaborating with other team members. It includes several main pillars: source-code control, project tracking, automated build, collaboration software, reporting and ALM guidance (Capability Maturity Model Integration [CMMI], Agile and Scum are available via download).

As a group, TFS has one of the best offerings because of the inte-gration between each of the pillars. For example, when checking in

code you can associate a requirement (work item) with a set of code changes (changeset), triggering an automated build to verify the work and even reject the check (through gated check-in) if the build doesn’t succeed. Collaboration is supported through Microsoft SharePoint, which includes support for a knowledge base in the form of a wiki and provides a launching pad to access the SQL Server reporting system, allowing team members to review ALM quality for the team project. In summary, TFS offers a best-of-breed solution for the full suite of functionality with perhaps only one contender—a product from Atlassian Pty Ltd.—that matches the breadth of what’s available in TFS.

Even if a development team only needs a portion of the TFS suite, the individual pillars certainly have a lot to offer. However, teams willing to invest the time and energy in setup, configuration and integration may find they prefer to select from the plethora of alternative applications in the same space:

• Source-code control: Mercurial, GIT, Subversion • Project tracking: Bugzilla, TFS, Mantis, JetBrains • Collaboration: ScrewTurn Wiki, PHP Wiki, Cloud • Build server: TeamCity, Cruise or CruiseControlMost of these turnkey solutions have established mainstream

status in the industry. VSM

In SummaryVisual Studio 2010 and TFS offer a formidable array of tools and capabilities to support team-based development, with third-party tooling providing valuable ways to fi ll gaps.

Tool Box■ Team Foundation Server■ Visual Studio 2010

.NET Survival GuideCOVER STORY

Page 33: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

Agile Enriches, Not Replaces Waterfall

gile development methodologies have matured and moved into mainstream use, especially in enterprise software development, where business needs can change

quickly. According to the results of the TechExcel/1105 Media survey (with multiple responses allowed), 22 percent of teams are using an Agile development methodology. Another 46 percent used iterative methods, a generic description of many Agile approaches that combines frequent releases with regular feedback from users.

However, that doesn’t mean that traditional approaches have been cast away. The same survey found that over 40 percent of groups use a combination of traditional and Agile methods. This means that many teams aren’t bound to an established process, but rather adapt their approach depending on the needs of the project. For example, a more complex development effort may combine the planning inherent in a waterfall approach with the frequent releases and feedback of Agile.

Measuring success and improving current processes are also on the minds of application lifecycle professionals. A full 43 percent of those surveyed use results measurement to improve process, while others use post-mortem reviews, iteration retrospectives, ad hoc reviews, or other approaches to evaluate results and make improvements. Most use multiple methods, depending on the project and methodology.

Further, the future of development methods is less about orthodoxy and more about practical approaches. Development teams care about

what works for their unique circumstances, rather than adhering to the speci cs of a particular approach. Most lifecycle professionals believe that the development approach will be dependent upon the project.

A large percentage also believe that hybrids between Agile and traditional methods are a big part of their future. The focus on working code, and frequent user feedback, are attractive features of agile that could be applied to any project. But some projects, such as those with safety implications, need the type of command and control provided by traditional methods. Combining these approaches can make the team more responsive and more effective over the life of the project.

As development processes mature and adapt to unique project needs, respondents believe there will always be a need for ALM tools to address different methodologies within the same environment. It will always be necessary to track requirements, for example, whether those requirements are formal waterfall requirements or Agile user stories. A hybrid process won’t be effective unless there are ways to document and control the process, and to collect data and provide information about the state of the process and the application. Tools sharing a common platform that adapt seamlessly to the project methodology, with features that can be turned on and used depending on the project, will be increasingly important in a world where teams take a practical approach to delivering software.

Development teams blend traditional and agile techniques to meet the needs of individual projects.

For complete survey results or to nd out more about TechExcel’s agile solutions, please contact [email protected], call (800) 439-7782 or visit www.techexcel.com

ADVERTISEMENT

Untitled-4 1 12/9/10 1:45 PM

Page 34: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

30 VISUAL STUDIO MAGAZINE · January 2011 · VisualStudioMagazine.com

ILLU

STR

ATI

ON

BY

RYA

N E

TTER

In many software development environments, an important part of the overall software-testing effort is having the ability to measure the progress of the test effort. One technique for doing this is a project management technique called Earned Value Management (EVM).

EVM is a simple quantitative technique that can be used to measure the schedule progress—and optionally the budget progress—of any type of project, including a software-testing effort or some part of the overall effort. EVM had its origins in a 1962 initiative by the U.S. Department of Defense called PERT/Cost. Although EVM is simple to use and can be applied to test efforts of any size, based on my experience many software engineers incor-rectly believe that EVM is suitable for use only with large software development efforts.

In this month’s Test Run column I explain what EVM is, walk you through an example of using EVM to measure test-effort progress, and describe when to use EVM and when not to use it.

Preparing Earned Value ManagementThe best way to understand EVM is to walk through a concrete example. The first step in EVM is to break down the part of the testing effort you want to monitor into smaller tasks. In standard project management terminology these smaller tasks are usually called work packages, but in a software development environment, often they’re simply called subtasks.

Let me emphasize up front that breaking down a software testing effort, or any project for that matter, typically is the most difficult part of the EVM process.

Now let’s assume that you break down your test effort into five subtasks, labeled A through E, as shown in Figure 1. The level of detail, or granularity, you break your overall testing effort down to depends on many factors. As a general rule of thumb, in a software-testing environment, individual subtasks are often scoped so that each subtask requires roughly between four and 40 hours to complete.

The topology of the diagram in Figure 1 indicates that testing subtask A must be completed before B starts, and that subtasks C and D must both be completed before subtask E can start.

The next step in EVM is to estimate how much of the overall test resource allotment, or budget, is associated with each subtask. This is called the planned value (PV) for each subtask.

The example in Figure 2 (p. 32) assumes you have a total test budget of 350 units. PV units are most often measured in dollars (or Euros or rubles and so on). The absolute magnitude of cost units is unimport-ant, so the 350 total planned value in our example could represent $350 or $350,000. Besides monetary units such as dollars, the units of PV can also be arbitrary units that measure the cost in some way.

There are no magic formulas to determine the subtask PV, but it’s important to note that the accuracy of the schedule progress metrics produced by EVM depends entirely on the accuracy of your initial PV metrics. In Figure 2, you can see the PV estimates for subtasks A, B, C, D and E are 50, 60, 90, 80 and 70 respectively.

After estimating PV, the next step in EVM is to estimate how long each subtask will take, and then use these estimates to determine the

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

Figure 1 Mapping Subtasks for EVM

Subtask A Subtask B Subtask E

Subtask C

Subtask D

Measuring Test Effort Progress with EVM

An important part of a software testing—or coding—effort is the ability to measure progress. One way for doing this is a technique called Earned Value Management (EVM). Find out how easy it is to apply EVM to your own projects. BY JAMES MCCAFFREY

Page 35: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

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

Page 36: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

32 VISUAL STUDIO MAGAZINE · January 2011 · VisualStudioMagazine.com

finish time for each subtask. In Figure 2, I determined (using historical data, or previous experience, or some quantitative technique) that subtasks A, B, C, D and E are estimated to take 1, 2, 3, 1 and 2 days each. In this example, the units of time are days, but you can use hours or weeks or any measure as long as you’re consistent throughout the EVM analysis.

We start at time = 0, so if subtask A is estimated to take 1 day, it will finish at day 1. Subtask B would then begin at day 1 and require 2 days, ending at day 3. Notice that subtask E cannot begin until subtasks C and D both finish, which would be on day 6 (the larger of the finish times for C and D), and so would end at day 8.

Once you’ve determined what your software test effort subtasks are, and estimated their PV, durations and finish times, the next step is to create a table of cumulative PVs. You begin by constructing a table like the one shown in Figure 3. The leftmost column marks the end of each unit of time (in this example, days 1 through 8). The second column is the cumulative PV at the end of each day, which can be determined from the previous table of PV data.

At the end of day 1, subtask A should be completed and so the cumulative PV should be 50, the PV for A. At the end of day 2, no new subtasks are expected to be finished so the cumulative PV is still 50. At the end of day 3, subtask B should now be finished and so the cumulative PV should be 50 for subtask A plus 60 for subtask B = 110. In the same way the cumulative PVs at the end of days 4 through 8 can be determined.

Measuring Test Schedule ProgressLet’s suppose that your test effort unfolds as shown in the third column in the table in Figure 3. These activities represent what actually happens as opposed to what you expect to happen. The difference between what you had planned to accomplish (your PV) and what you actually accomplished is your earned value (EV).

So, at the end of day 1, subtask A started but did not finish as scheduled. Therefore the cumulative EV in column 4 is 0. At the

end of day 2, subtask A does in fact finish and so I earn 50 (the PV associated with A), and place that value in column 4. At the end of day 3, subtask B finishes and so the cumulative EV is 50 + 60 = 110. But at the end of day 4, no new subtasks finish and so the cumulative EV is still 110. At the end of each day, or whatever time unit you’re using, you update the cumulative EV column.

Your test effort schedule progress is easily read from the table in Figure 3. If the cumulative EV is less than the cumulative PV, then you’re behind schedule. If the cumulative EV is exactly equal to the cumulative PV, then you’re on schedule. And if the cumulative EV is greater than the cumulative PV, then you’re ahead of schedule (which, by the way, is not necessarily always a good thing).

EVM typically uses two specific metrics to quantify how much ahead, behind or on schedule your test effort is. The so-called schedule variance (SV) at any given point in time is simply the cumulative EV minus the cumulative PV. For example, in Figure 3, at the end of day 4, SV = 110 – 190 = -80 indicating the test effort is 80 cost units (typically dollars) of PV behind schedule. A negative SV indicates a project is behind schedule and positive SV indicates a project is ahead of schedule.

Because the absolute magnitude of SV depends on the units of PV, an alternative metric called the schedule performance index (SPI) is often used instead of SV. SPI is cumulative EV divided by PV. In my example, at the end of day 4, the SPI is 110 / 190 = 0.58.

This can be interpreted to mean that I have only earned 58 percent of my PV—in other words, I’m 42 percent behind my scheduled PV.

SPI values less than 1.00 mean the test effort is behind schedule, an SPI value of 1.00 means the test effort is exactly on schedule, and SPI values greater than 1.00 mean the test effort is ahead of schedule.

Wrapping UpAs you’ve seen in this column, monitoring software-test effort schedule progress with EVM is easy. However, as with any quanti-tative technique, your results are only as good as your initial data—in this case the PVs associated with each test effort subtask. EVM is a dynamic activity and you should revise your estimates as your test effort unfolds.

In the introduction to this column I mentioned that EVM can be used to measure both schedule progress and budget progress. Mea-suring schedule progress as I’ve explained here is a prerequisite for measuring budget progress. Measuring budget progress requires that you actively monitor how much of your resources you spend at the end of each time unit. This is typically more difficult than measuring your work progress, so measuring budget progress with EVM is often only used on larger software projects and will be the subject of a future Test Run column.

The EVM approach for measuring test effort schedule prog-ress I’ve presented here, which essentially is a paper-and-pencil technique, is well suited for small projects and projects being developed in an Agile environment. When developing large software projects, software tools are usually needed to manage the complexity introduced by the existence of hundreds or even thousands of test effort subtasks. VSM

Dr. James McCaffrey works for Volt Information Sciences Inc., where he manages technical training for software engineers working at the Microsoft Redmond, Wash., campus. He’s worked on several Microsoft products, including Internet Explorer and MSN Search. Dr. McCaffrey is the author of

“.NET Test Automation Recipes” (Apress, 2006) and can be reached at [email protected].

Day Cum PV Actual Activity Cum EV

1 50 A has started (but has not yet fi nished) 0

2 50 A has fi nished, B has started 50

3 110 B has fi nished, C and D have started 110

4 190 (no change) 110

5 190 (no change) 110

6 280 Both C and D have fi nished, E has started 280

7 280 (no change) 280

8 350 E has fi nished 280

Figure 3 Schedule Progress with Cumulative PV

Subtask Planned Value Duration (days) Finish (days)

A 50 1 1

B 60 2 3

C 90 3 6

D 80 1 4

E 70 2 8

Figure 2 Scheduling Subtasks

FEATURE Measuring Test Effort Progress with EVM

Page 37: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

VisualStudioMagazine.com · January 2011 · VISUAL STUDIO MAGAZINE 33

ILLU

STR

ATI

ON

BY

RYA

N E

TTER

While many developers may think of Silverlight as a Web-centric technology, in practice it has become a great platform for building any type of application. Silverlight has built-in support for concepts such as data binding, value converters, navigation, out-of-browser operation and COM Interop, making it relatively straightforward to create all kinds of apps. And when I say all kinds, I also mean enterprise apps.

Creating a Silverlight application with the Model-View-View-Model (MVVM) pattern gives you, in addition to the features already in Silverlight, the advantages of greater maintainability, testability and separation of your UI from the logic behind it. And, of course, you don’t have to figure all this out on your own. There’s a wealth of information and tools out there to help you get started. For example, the MVVM Light Toolkit (mvvmlight.codeplex.com) is a lightweight framework for implementing MVVM with Silverlight and Windows Presentation Foundation (WPF), and WCF RIA Ser-vices (silverlight.net/getstarted/riaservices) helps you easily access Windows Communication Foundation (WCF) services and databases thanks to code generation.

You can take your Silverlight application a step further with the Managed Extensibility Framework (mef.codeplex.com), also known as MEF. This framework provides the plumbing to create extensible applications using components and composition.

In the rest of the article I’ll show you how to use MEF to get central-ized management of the View and ViewModel creation. Once you have this, you can go much further than just putting a ViewModel in the DataContext of the View. All this will be done by customizing the built-in Silverlight navigation. When the user navigates to a given URL, MEF intercepts this request, looks at the route (a bit like ASP.NET MVC), finds a matching View and ViewModel, notifies the ViewModel of what’s happening and displays the View.

Getting Started with MEFBecause MEF is the engine that will connect all the parts of this example, it’s best to start with it. If you’re not familiar with MEF already, start by reading Glenn Block’s article, “Building Composable Apps in .NET 4 with the Managed Extensibility Framework,” in the February 2010 issue of MSDN Magazine (msdn.microsoft.com/magazine/ee291628).

First you need to correctly configure MEF when the application starts by handling the Startup event of the App class:

private void OnStart(object sender, StartupEventArgs e) {

// Initialize the container using a deployment catalog.

var catalog = new DeploymentCatalog();

var container = CompositionHost.Initialize(catalog);

// Export the container as singleton.

container.ComposeExportedValue<CompositionContainer>(container);

// Make sure the MainView is imported.

CompositionInitializer.SatisfyImports(this);

}

The deployment catalog makes sure all assemblies are scanned for exports and is then used to create a CompositionContainer. Because the navigation will require this container to do some work later on, it’s important to register the instance of this container as an exported value. This will allow the same container to be imported whenever required. Another option would be to store the container as a static object, but this would create tight coupling between the classes, which isn’t suggested.

Extending Silverlight NavigationSilverlight Navigation Application is a Visual Studio template that enables you to quickly create applications that support navigation using a Frame that hosts the content. The great thing about Frames is that they integrate with the Back and Forward buttons of your browser and they support deep linking. Look at the following:

<navigation:Frame x:Name="ContentFrame"

Style="{StaticResource ContentFrameStyle}"

Source="Customers"

NavigationFailed="OnNavigationFailed">

<i:Interaction.Behaviors>

<fw:CompositionNavigationBehavior />

</i:Interaction.Behaviors>

</navigation:Frame>

This is just a regular frame that starts by navigating to Customers. As you can see, this Frame doesn’t contain a UriMapper (where you could link Customers to a XAML file, such as /Views/Customers.aspx). The only thing it contains is my custom behavior, CompositionNavigation-Behavior. A behavior (from the System.Windows.Interactivity assembly) allows you to extend existing controls, such as a Frame in this case.

Figure 1 (p. 34) shows the behavior. Let’s take a look at what this CompositionNavigationBehavior does. The first thing you can see is that the behavior wants a CompositionContainer and a Composition-NavigationLoader because of the Import attributes. The constructor then forces the Import using the SatisfyImports method on the CompositionInitializer. Note that you should only use this method when you don’t have another choice, as it actually couples your code to MEF.

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

Using MEF to Expose Interfaces in Your Silverlight MVVM AppsManaged Extensibility Framework (MEF) lets you expose interfaces and classes in your Silverlight apps without having to expose the real implementation. See how it works. BY SANDRINO DI MATTIA

Page 38: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

34 VISUAL STUDIO MAGAZINE · January 2011 · VisualStudioMagazine.com

When the Frame is attached, a NavigationService is created and wrapped around the Frame. Using ComposeExportedValue, the instance of this wrapper is registered in the container.

When the container was created, the instance of this container was also registered in itself. As a result, an Import of Composition-Container will always give you the same object; this is why I used ComposeExportedValue in the Startup event of the App class. Now the CompositionNavigationBehavior asks for a CompositionContainer using the Import attribute and will get it after SatisfyImports runs.

When registering the instance of INavigationService the same thing happens. It’s now possible from anywhere in the application to ask for an INavigationService (that wraps around a Frame). Without having to couple your ViewModels to a frame you get access to the following:

public interface INavigationService {

void Navigate(string path);

void Navigate(string path, params object[] args);

}

Now, let’s assume you have a ViewModel showing all of your customers and this ViewModel should be able to open a specific customer. This could be achieved using the following code:

[Import]

public INavigationService NavigationService {

get; set;

}

private void OnOpenCustomer() {

NavigationService.Navigate(

"Customer/{0}", SelectedCustomer.Id);

}

But before jumping ahead, let’s discuss the SetContentLoader method in the CompositionNavigationBehavior. It changes the ContentLoader of the Frame. This is a perfect example of the support for extensibility in Silverlight. You can provide your own ContentLoader (that implements the INavigationContentLoader interface) to really provide something to show in the Frame.

Now that you can see how things start falling into place, the following topic—extending MEF—will become clear.

Back to Extending MEFThe goal here is that you can navigate to a certain path (be it from the ViewModel or your browser address bar) and the Composition-NavigationLoader does the rest. It should parse the URI, find a matching ViewModel and a matching View, and combine them.

Normally you’d write something like this:[Export(typeof(IMainViewModel))]

public class MainViewModel

In this case it would be interesting to use the Export attribute with some extra configuration, referred to as metadata (Figure 2 shows an example). In addition to the ViewModel interface, this attribute allows you to define a navigation path such as Customer/{Id}. Then it will process this path using Customer as Key and {Id} as one of the arguments. Here’s an example of how this attribute is used:

[ViewModelExport(typeof(ICustomerDetailViewModel),

"Customer/{id}")]

public class CustomerDetailViewModel

: ICustomerDetailViewModel

Before continuing, there are a few important things to note. First, your attribute should be decorated with the [MetadataAttribute] to work correctly. Second, your attribute should implement an interface with the values you’ll want to expose as metadata. And finally, mind the constructor of the attribute—it passes a type to the base constructor.

Figure 1 CompositionNavigationBehaviorpublic class CompositionNavigationBehavior : Behavior<Frame> { private bool processed; [Import] public CompositionContainer Container { get; set; }

[Import] public CompositionNavigationContentLoader Loader { get; set; }

public CompositionNavigationBehavior() { if (!DesignerProperties.IsInDesignTool) CompositionInitializer.SatisfyImports(this); }

protected override void OnAttached() { base.OnAttached(); if (!processed) { this.RegisterNavigationService(); this.SetContentLoader(); processed = true; } }

private void RegisterNavigationService() { var frame = AssociatedObject; var svc = new NavigationService(frame); Container.ComposeExportedValue<INavigationService>(svc); }

private void SetContentLoader() { var frame = AssociatedObject; frame.ContentLoader = Loader; frame.JournalOwnership = JournalOwnership.Automatic; }}

Figure 2 Creating the ViewModelExportAttribute[MetadataAttribute][AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]public class ViewModelExportAttribute : ExportAttribute, IViewModelMetadata {..public Type ViewModelContract { get; set; } public string NavigationPath { get; set; } public string Key { get; set; }

public ViewModelExportAttribute(Type viewModelContract, string navigationPath) : base(typeof(IViewModel)) {

this.NavigationPath = navigationPath; this.ViewModelContract = viewModelContract; if (NavigationPath != null && NavigationPath.Contains("/")) { // Split the path to get the arguments. var split = NavigationPath.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); // Get the key. Key = split[0]; } else { // No arguments, use the whole key. Key = NavigationPath; } }}

FEATURE MEF and Silverlight

Page 39: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

ement1); areaSeries Add(seriesElement2); areaSeries Add(seriesElement3); // Add series to the plot area plotArea Series Add(areaSeries); //page Elements Add( new LayoutGrid() ); // Add the page elements to the page AddEAement1); areaSerieies.AAdd(se(s rriesElement2t2); a) reaSeries.AdA d(seriesElement3); // Add series to the plot area plotArea.Series.Add(areaSeries); //page.Elemenem ts.Add( ddd( new ne LaLayyoutGrid() ); // A/ dd the page elements to the page AddEA

s, 240, 0); AddEAN1AN 3SupSup5(pa5(p ge.Elemeentnts, 480, 0); AdddUPCVersionA(page.Elemene ts, 0, 135); AddUPCVersionASup2(page.Elements, 240, 135); AdddUPCddUPCd CVerssionAionAo Sup5((page.Elemennts, t 480, 135); AddEAN8(page.Elements, 0,

.Elements, 480, 2270);; AddddUUPCVersionE(papage.Elementts, 0, 405); AddUPCVersionESuE p2(page.Elements, 240, 405); AddUPCVersionESup5(pageage.Ele.Elelemmments, 4s, 48800, 4405); // AAdd the page toe t the document document.Pages.Add(pa

CaptionAndRectanga lee(elemeements, “EAN/JA/JAN 13 Bar Codde”, x, y, 204, 99); BarCode barCode = new Ean13(“123456789012”, x, y + 21); barCode.ode.X +=X +X +=X + ((2004 -4 - baarCoode.GettSymbolWidth()h ) / 2; elements.Add(barCode); } private vovo

dRectangle(elemente s,, “EANEAN/JAN 13 Bar Car Code, 2 digit supplement”, x, y, 204, 99); BarCode barCode = new Ean13Sup2(“12 234556789678 0121212”, 2”, x, yy + 2+ 211); 1); barCoode.XX += (204 - barCode.GetSymbolWidth()) / 2; elements.Add((barC

ts, float x, float yy) { A{ AddCaCaptionAndRectanangle(elements, “EAN/JAN 13 Bar Code, 5 5 digit supplement”, x, y, 204, 99); BaB rrCodee barrCode == new Ean13SupS 5(“12345678901212345”, x, y + 21); ba

s.Add(barCode); } } pprivate te vooid AddUPCVPCVersiers onA(Group elements, float x, float y) {Add{ CaptionAndRectangle(elements, “, UPC VersVersVersVersion ionoi A Baar Cr Coode”, x, y,y, 204, 99);; BarCoode barCode = new UpcVersionA(“12345678901”, xx, y +

s.Add(barCode); } } pprivate te vooid AddUPCVPCVersiers onASup2(Group elements, float x, floato y) { AddCaptionAndRectangle(elementm ““UPCC Version E Bar Code, 2 digit supplement”, x, y, 204, 94 9); BarCoode od

21) ; barCode.X ++= (2= ( 04 - barba Code.GeetSymbymbolWidth()) / 2; elements.Add(barCode); e } private void AddUPCVersionASSSSuup5(up5(u Group elements,n float x, flfloaflo t VV

digit supplement”,t” xx, y, 22004, 99); BarCodeCode bbarCode = new UUpcVep rsionASuAS p5(“12343 567890112345”, x, y + 21); bbarCarCode.Xde.X += (204 - barCode.GetSymboom lWidth()) / 22; eelele

t x, float y) { AddCapdCaptionnAndRAnd ectangle(eleelemments, “EAN/JANN 88 Bar Code”,de”, xx, y, 204, 0 99); BarCode barCode = nnew Eew Ean8(an8(n8n8 “1 2345670”, x, y + 21); OpenFileileDiala og fileDie aloogoglo =

g.Filter = “Adobeob PDPDF fileess (*.pdf)|*.pdf|Alll FileFiles (*.*)|*.*”; if (fileDieD alog.SShowDiialog() == DialogResult.OK) { { pdfVpdfVf ieweewer.OpOpr.OpOpen (fifileDialogalog.FilleName, “”); } SaveveFileDialog saveFaveFileileDDialoog = neneww Sav

Dialog.Filter == “AdoAdobe PPDF fiDF files (*.pdff)|*.pdpdf|A|All Files (*.*)|*.*”;”; iff (saveFFileDialolog.Showh Dialog() ==DialoalogResgResRee ult..OK)OK) OK) { pdfVfVView .SSaveAsve (sav(saveFieFileDia

printer = pdfViewViewer.Per rinterr; pprinter.PriintWiW thDialog(); } elsee { MesssageBox.SShoww(“Please opeopen a n a fifile to pto p rintrinrint”)”); }OpenFin le DDialoog fileDieD alogalog = new OpenFileDDialog(); fileDiaDialog.og Tittle = e e = e “Opepen File Dl

les (*.*)|*.*|Addobe Pe PDF files es (*.p*.pdf)|*.pdddf”; if i (fifileDialog.ShowwDialalog() === DialogResult.ult OK) { { DynaDynamicPDFVDFVDFVDFViewiewewerClass test e = neew DynammiccPDFViewerClass((); PPDFPrinter ter pprinp ter er r = te= ttet st.OpenFFileFo

= File.ReadAAllByteBytes(@”C:\M:\MyDyDoc.pdff””); //u// sing System.Runntimme.Inttent ropServicces;GCHaGCHandlendledd gch=GCH= CHaananddla e.Aloc(conteents, GCHandleTTypee.Pinnedd); ) IIntntPtrPtr cooncontentsIntPtr = g

tents.Lengthh, “”);“”); A AddCaCaptioonAndReReectanglan ee(pageElementts, “BBBookkmark k Pagee E Elemelemeent:”nt:”, x,, y);; pa pagaapageEeEleemeents.Add(newtesw t Bookmookmaark(“Bookmarked TextTextt”, x + 55, y , y, yy ++ 2+ 20+ , pap rentre OutlO ine)); p) a

215, 10, Fonnt.TTimemesRomanma , 1010)); } prprrriivate vooid AddCiirclercle(GGro(G up paageElemeennnts,nts floafloat x,x floafloat yt y)t y) { / { /////Add/Add/A ss a circlt to the pap ge Eleemenmentenents AddCapdCapCaCadCaptiont AndRdRectae

Add(new Cirrcle(x e(x ++ 112.5f5f, y ++ 50f, 1007.5f, 300f, RgbColoolor.RRRed, RgbbbColor.Bor.Bluee,lue 2, LineL eStyylylly e.DaDae shLaLs rge))); } pprivate void AdA d FormatteeddTexxtAreea(Groupp paageElements, flofl aat x, fl float yy)) { ) // A// AAdds dds a fofoa rmatted textte a

mic</i><b>PDFPDF</b>/b>&tm; GGenerator vvv666.0 6 for ..NETNET has has a forrmattted ttetext arrea pea paaage a “ + “ “ele“ele“eleeeemmmentm . ThThis prroviddes rich fororm m atting ssuppupport for texext that appap eears in the doocumment. You have “ + “+ “compcompletlete conco trolol ove ovevever 8 r paragraph

left indentattionn, rigrighht indenentation, aligliggnnment, allollowing orphaaan linnes, aand whwhite ite “ + “spa“spaacece ppce pprereservata ion; 6 foont propropeerties: e <fonont fat f ce=’=’Timemes’>s’>font facece, <//fontt><font ppoinntSize=’6’>font “ + “s+ “size, </font>ont><fonont cocoocoot lor=lor=’FF0000’00’>c

2 line prpropertieses: le leading, ag ndd leaddinngg type.ype. TText can also be rootateeed.</d.</< p>”;p> FFororo mattmattmm edeedTeedTeTeextArx ea fformaormattedTTextAreArea = nnew FormattedTextTex Areare (formattat edHHtmll, x + 5, yy + 20, 215, 60, FonttFammily.Helveelvetictica, 9, fffalalsse);se);se);sssse) // // Sets the i

ddCaptionAAndReRectanct gle(e(pagepageElemeenntsnts, “F, “Fororrmarmattedtte TextT Areeae Page ElElemenement:”,t:”,,, x, y); y); y)y AddCAdddCddCA aptionAnAndReectangnglele(pageElements, “Formatm tedTextAx rea OverOv flflow TText:”, x x + 2279, y); pageElementments.Add(foormarmattedTTTextAxttAAtArea)r ; // CrCrer ate

tArea overflowFoowFormatrm tedTdTextAArea == foormamatteddTdt extArea.GettOveerflowwwFormatmatteddTTexextAxx rea(rerea(re x + x 28284, y +y 200); pageElements.Add(overflowFormattedTextAArea)); } pprivate vooid AddImage(Group p pagpageElementsents, float t x, flo, at yy) { ) { // // A/ dd

ents, “Imagee PagePage Elementen :”, xx, y); IImmagemage imaaage =ge new Imaage(SServvever.Mr.MapPattatth(“.h(“.“ ./I./Im./ agesages/DPDDFLogL o..png”), x + 112.5f, y + 50f, 0.24f); // Image is ssizzed and centeredd inn the rectangle immage.age SetBoundunds(21s(215, 5, 65 0); 0) image.VAVAAlign

ge); } privatte void oid AAddLabela (Group pp ppageageElememments, float x, flfloat y) { /// A/ Adds as aa llabel tel t to tht e pappap gegeElemenementts AddCaptionAndRectangle(pageElemenm ts, “LabLa el & PPageNummbeeringLabel Page EElemments:”, x,x, y); y) striing g laabelTextxt = = “= ““Lab

aain page numbumberinering: %%CP%%CP%%% ofof %%%T%%TP%%% pages.”; LLabel le abbel = nnew LLLew Laabel(labbelTeelTeeelTexxt, x + 5, y5 ++ 12, 220, 80, Font.TimesRoman, 12, Texe tAlign.C.Centter); label.Annglee = 8; PageNumbeeringgLabel pagepageNumLNumLabelab = nnnewew Pw Page

, 12, TeextAlxtAligign.CentC er); paga eEleementntntss.Ad.Addd(paageNumLabel));); p paggeElemenments.Addddd(d(label)); } } privprpp ate voidoid A AddLine(Group pageElements, float x, floao t y) { /// Addds aa line to thethe pageElements AdddCCaptionAndRAndRRectanngleglen (pagpag( a eeElemments

+ 5,+ y ++ 20, x + 220, y + 8080, , 3, RRgbbColor.Gr.G eeen)); pageElemmementss.n Add(d(d new w Linee(x ++ 22 2200, yy ++ 20, x + 5,+ 5, y + 80, 3, RgbColor.Green)); } private void AdddLLink((Grouup pageEElemments, float x, floaat yy) { // Adds ads a link toto thethhe pagp eEleEleemen

ynynamicPDF.com.m ”; AAddCaddCaptioptionAAnddnAndRectanglan e((pageElementts, “LLink PaPagege Elemment:nt:”, xx, y);y); LLabel llabela = new Label(text, x + 5, y + 20, 215, 80, font, 12,2 RggbCoolor.Blue)e); laabel.Underline = true;rue Link link =k = newnew LLinnk(x k(x ++ 5,5, y y ++ 20,

on(o “httpp://www.dynnamicppddf.coomm””))); pageEeElemments..Add(Ad labbeel);l); ppagepagpageElementsnts.AAdd(link); k) } prp ivatee void AddPath(Group pageElements, float x, float y) { // AAdds a path to the pageElemeents ceeTe.DynamicamicicPPDPDF.PagegeElemlemlements.PatP h

20,0 RgbgbbColor.Blue, RgbCRgbCoolor.RRedd, 22, LineStyeS lee.Solidd, true); pathhh.Su.SubbPaths.A.Adddd(new Lw LineSineSubPaubPath(x + 215, y + 40)); path.SubPaths.Add(new CurveToSToSubPPathh(x + 1+ 08, y + 80, x + 160,, y ++ 800)); path.SubSubPSubPathssssh .AAAd.Add(new(ne CurveS

ectecctanglangle(pageElemeents, “P“Path Ph Paage ge Element:””, x, yy);) pageEEleEleEE meentss.AdAdd(pad(path));th } pprivaate ve vooid AAddRectangle(Group pageElements, float x, float y) ororderede ddList = ordeo redLedList.GetOverFlowLo List((xx + x 5, y + 2+ 22000); AddCddCCCA aptiapa oonAndRect

2222 55, 1110); page.Eleements.Ats.Add(odd(ordrdrderr edList); x == 0; 0; y +=y ++=y + 118881 ; // CCCreaate e aan unorrderede lisist UnUnordderedList unorderedList = new Unoro deredList(x + 5, y +y + 220, 4400, 900, Font.Ht.Helvetica, 10); uuunoorderredListst.Itte.I ms.Amms Am dd(“ddd(“FruiFruFFFrFruF tss”); unorder

eree ies(); pieSeries.DaataLababel = da; plotArea.Seeriesess.AAd.Add(pieSSSeriesss);es ppieSeries.Elemelementss.AddAdd(27,7, “Website A”); pieSeries.Elements.Add.Ad (19, “Website e B”)); pieSerrieses.Elementmen s.Add(21, “WWebssite CC”); pieSpieSSerieeririees.Elemeneemmee ts[0s[0].Color = a

sess.Elemments[2].Color = auttogradient3;”unoro derreder ddSubLList2 == unoorderedList.Items[ms 1].SubLubLissts.AAddUnorderedSubList(); unorderedSubLu ist2.Items.Add(“dd(“Pottato”); unu ordeeredSubList2.Itemmms.A.Add(d(“Beaansansea ”);;; UUUnorU dereree dSubSu List subU

dSuedd bList(); subUnoUnorderedSubList.Items.As.AAdd(““d Lime”); subUUnorddereedSubList.Itemtems.Ads.Add(“Od(“Orangrange”);e” Unorderd edSubList sus bUnorderd edSue bList2 = unnorddereedSubLisLi t.Items[ms 1].SubLists.s.AddUAAddUd norrdereddeddSubLSubLbList(st ); ssubUnbUnu oorderedSe ub

na”aa ); UUnorderederedSubList subUnordo erededSubLSu ist3st3 = uunnorderredSubLSubList2.Itet ms[00].Su.SubLisLists.As.AddUnd orderedSSubList(); subUnoU rderedSudSubList3.Items.AAdd((“Swweet Potao to”)); UUnorderedSredSubLubLiL st sst ubUUnordrdeeredSdSredSdSubList4 st4st = ununorderedSu

ubLSuSu ist444.Ite.Items.Am dd(“String Bean”n”); s; subUnbUnordeereedSubbList4..Itemms.Addd(“Lima BeanBean”); subUsubUnnorderedSubList4.Items.Add(“Kidney Bean”e ); x += 279; pagpage.EElemenntts.Addd(unorderedListst); u); ; nordno eredreddLisst = = uunordn ereddreddLisst..GetG Overv Flo

e.e.Elemeentsen , “Unordered List Page Ege Elemment On verflverflow:””, x, y,, 2255, 110); page.Elemementsents.AddAdd(un(unorderedList); } private void AddTextFt ield(Group pageEeElemlemennts, flfloaat x, flooatt y) { TextFFielddield txt = new Tew extFextFieldeld(“txtfnafnaaame”,meme”,me”, x +x + 20, 20, y + y +

tteaa dTeextArea(formattedHtml, x ++ 5, 5 y ++ 20, 202 215,15 60, FontFFamilyy.Heelvetica, 9, ffalse)se ; /// SetSets ths the ine dent property formattedTextArea.Style.Paragraph.IndeIn nnt = 1188; AddCaptCap ionAndRendRectanaa gle(eg pagepageep ElemElemE ents, “FFormamormattedttedtedtedTeTextArearea P

atteatat dTeextArea Overflow TeeText:”, x + 27 9, y9, y); p; pageEgeElements.AAdd(formformattedTextAArea); a) // CCreatea ee an overflow formatted text area for the overflow text FoFormmattedTtedTextAxt reaMMaxaxLeLengthngth = 9 = 9= 9; txtxtxtxxt1.B1.Bordeded rCorColor =r = RgbCololoColoor.Br.BBlaack; txttxt1.Ba1 Ba

MaMMM ximuum Lengthgth”; p; ageEEgeEElemeements.nts.Add(Add(txttxt1); TTextFex ieldd txt2 = neew TeextField(“txxtf2namename”, xx + 3+ 30, y + 30, 150, 40); txt2.DefaultValue = “This is a TexxtFtFieldd whiichh goees tototot the nexxt lit liline ine iif thff t e text et et xceexceeds wds wididth”; ”; ttxt2.xt2.xt2xt2 MMMultMu iLinLine = e =

RgRR bCooolor.AliceBlueBluee; txt2.T2. oolTip == “M“Multiline”; ppageEElemennts.AAdd(ttxt2); AddCapCaptiont AndRAndRecctangle(pageElements, “TextField Form Page Element:”, x, x, y, 50450444, 8585); }; } prri vate voioidd AddComCCC boFibo eld(Group pap pageElgeElemeemenene ttts, ts float x, fl

, , y + 4000, 150,, 20 20)20); c; cb.Boro derCd olor = RgbColorr.BBlack; cb.BaackggrounndColor = RgbCRgbColoro .AliAliceBceBlue; cb.Font = Font.Helvetica; cb.FontSize = 12; cb.Itemsem .AAdd(“(“It(( em 1m 1”); ; ccb.IItemste .Add(“It““Item 2em 2”); ”); cb.Icb.Itemsems.Add(“Item 3em 3”)); cb.IItems

aaabbble”b ].SSeSeSeleleclected = true; cb.Edb itable = true; cb.ToToololTip = “Editable Coe Combo Box””; pa; pageElgeE emements.Add(cb); ComboBox cb1 = new ComboBox(“cmb1namame”, x + 303,030 y +y + 4440 40, 150, 200); c); cb1.Bb1.Bb1 ordeorderColrColoor = Rgbg Coloor.Blr.Br Br B ack;ack cb1.Bac

.F..FFFontontSize = 12; cb1.Items.Add(“Item 1”); cb1.Items.AAdd(“Item 2em 2”); ccb1.Items.Add((“Itemem 3”); cb1.Items.Add(“Item 4”); cb1.Items.Add(“Non-Editable”);”); cb111.Items[“NNon-Eon-Editable”].Selecteccc ed =ed = tru true; ce; cb1 Eb1.EEditable e = fa= f lse;se cb1.ToolT

eerrter.Coonvert(“http://www.google.com”, “Output.pdf”));Convverteer.Coonvert(GetDocD PathPath(“Do(“D cumentA.rtf”), “Output.pdf”);System.Diagnostics.Process..s SStartt(“Ot(“ uutpuutpuutputt.pdf”);”); AsyncCoConvernverrtter t aConaConvertverter =e newe AsyncCncConnverter(); aC

vveerted); aConverter.ConversionError += new ConversiionErroorEvventHHandler(aConveerteer_ConversionError); aConverter.Convert(@”C:\temp\DocumentA.rtA f””””, f , f @”C:C \temte p\OuO tputtputA.pdA.pdf”);f”); aCo aCoa nverter.Convert(ert @”C:\teme p\Dop\D cumentB

\Doc\D ummentC.rtf”, @”C :\temp\OutputC.pdf”); aConverrter.Coonverrt(“hhttp://www.yahoo.coo.com”, @”C:\Temp\yahoo.pdf”); ConvC ersionOptions ops optiontions = nneewnew new ew Conversise onOpOptiontionoo s(72s(720, 70, 720, 72, 7 true); ceTe.DynaDynamicPm DF.CDF.Conveon rsiorsion Con.Co

outpou ut.pdf”, optionso ); ceTe.DynamicPDF.Conversion.CConveerter.ConvCon ert(“C:\\temp\\\Documocument2.docx”, “C:\\temp\\op\ utput.pdf”, optiptoptioptiop ons)ons); s; stringing sampleHple tml m = “<“<htmlhtml><bo><bob dydy><p>This is s a very simplee HTMLHTMLHTHT strstrs ing iningin inclincincincludinud ng a g a g TT

( g[] g )

{{

pp

gg g ( p p )

[ ]

[ ]

pp y y yyp

HighhSecuSec rity securiturity y new w HighhSecuurityy(“OOwnerPassword”, “U“ serPassword”)

yy ppy

ees y yy

p

( p p )

pag p ( p pp )

p ()

}

Untitled-3 1 12/7/10 3:17 PM

Page 40: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

36 VISUAL STUDIO MAGAZINE · January 2011 · VisualStudioMagazine.com

FEATURE MEF and Silverlight

The class that’s decorated with this attribute will be exposed using this type. In the case of my example, this would be IViewModel.

That’s it for exporting the ViewModels. If you want to import them somewhere, you should be writing something like this:

[ImportMany(typeof(IViewModel))]

public List<Lazy<IViewModel, IViewModelMetadata>> ViewModels {

get;

set;

}

This will give you a list that contains all exported ViewModels with their respective metadata, allowing you to enumerate the list and maybe pick out only the ones of interest to you (based on the metadata). In fact, the Lazy object will make sure that only the ones of interest are actually instantiated. The View will need something similar:

[MetadataAttribute]

[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]

public class ViewExportAttribute :

ExportAttribute, IViewMetadata {

public Type ViewModelContract { get; set; }

public ViewExportAttribute() : base(typeof(IView)) {

}

}

This attribute allows you to set the contract of the ViewModel to which the View should be linked.

Here’s an example of AboutView:[ViewExport(ViewModelContract = typeof(IAboutViewModel))]

public partial class AboutView : Page, IView {

public AboutView() {

InitializeComponent();

}

}

A Custom INavigationContentLoaderNow that the overall architecture has been set up, let’s take a look at controlling what’s loaded when a user navigates. To create a custom content loader, the following interface needs to be implemented:

Figure 3 Custom INavigationContentLoader[Export] public class CompositionNavigationContentLoader : INavigationContentLoader { [ImportMany(typeof(IView))] public IEnumerable<ExportFactory<IView, IViewMetadata>> ViewExports { get; set; }

[ImportMany(typeof(IViewModel))] public IEnumerable<ExportFactory<IViewModel, IViewModelMetadata>> ViewModelExports { get; set; }

public bool CanLoad(Uri targetUri, Uri currentUri) { return true; }

public void CancelLoad(IAsyncResult asyncResult) { return; }

public IAsyncResult BeginLoad(Uri targetUri, Uri currentUri, AsyncCallback userCallback, object asyncState) { // Convert to a dummy relative Uri so we can access the host. var relativeUri = new Uri("http://" + targetUri.OriginalString, UriKind.Absolute);

// Get the factory for the ViewModel. var viewModelMapping = ViewModelExports.FirstOrDefault(o => o.Metadata.Key.Equals(relativeUri.Host, StringComparison.OrdinalIgnoreCase));

if (viewModelMapping == null) throw new InvalidOperationException( String.Format("Unable to navigate to: {0}. " + "Could not locate the ViewModel.", targetUri.OriginalString));

// Get the factory for the View. var viewMapping = ViewExports.FirstOrDefault(o => o.Metadata.ViewModelContract == viewModelMapping.Metadata.ViewModelContract);

if (viewMapping == null) throw new InvalidOperationException( String.Format("Unable to navigate to: {0}. " + "Could not locate the View.", targetUri.OriginalString));

// Resolve both the View and the ViewModel. var viewFactory = viewMapping.CreateExport(); var view = viewFactory.Value as Control;

var viewModelFactory = viewModelMapping.CreateExport(); var viewModel = viewModelFactory.Value as IViewModel;

// Attach ViewModel to View. view.DataContext = viewModel; viewModel.OnLoaded();

// Get navigation values. var values = viewModelMapping.Metadata.GetArgumentValues(targetUri); viewModel.OnNavigated(values);

if (view is Page) { Page page = view as Page; page.Title = viewModel.GetTitle(); } else if (view is ChildWindow) { ChildWindow window = view as ChildWindow; window.Title = viewModel.GetTitle(); }

// Do not navigate if it's a ChildWindow. if (view is ChildWindow) { ProcessChildWindow(view as ChildWindow, viewModel); return null; } else { // Navigate because it's a Control. var result = new CompositionNavigationAsyncResult(asyncState, view); userCallback(result); return result; } }

private void ProcessChildWindow(ChildWindow window, IViewModel viewModel) { // Close the ChildWindow if the ViewModel requests it. var closableViewModel = viewModel as IClosableViewModel;

if (closableViewModel != null) { closableViewModel.CloseView += (s, e) => { window.Close(); }; }

// Show the window. window.Show(); }

public LoadResult EndLoad(IAsyncResult asyncResult) { return new LoadResult((asyncResult as CompositionNavigationAsyncResult).Result); }}

Page 41: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

FEATURE

public interface INavigationContentLoader {

IAsyncResult BeginLoad(Uri targetUri, Uri currentUri,

AsyncCallback userCallback, object asyncState);

void CancelLoad(IAsyncResult asyncResult);

bool CanLoad(Uri targetUri, Uri currentUri);

LoadResult EndLoad(IAsyncResult asyncResult);

}

The most important part of the interface is the BeginLoad method, because this method should return an AsyncResult con-taining the item that will be displayed in the Frame. Figure 3 (p. 36)shows the implementation of the custom INavigationContentLoader.

As you can see, a lot happens in this class—but it’s actually simple. The first thing to notice is the Export attribute. This is required to be able to import this class in the CompositionNavigationBehavior.

The most important parts of this class are the ViewExports and ViewModelExports properties. These enumerations contain all exports for the Views and the ViewModels, including their metadata. Instead of using a Lazy object I’m using an ExportFactory. This is a huge difference! Both classes will only instantiate the object when required, but the difference is that with the Lazy class you can only create a single instance of the object. The ExportFactory (named after the Factory pattern) is a class that allows you to request a new instance of the type of object whenever you feel like it.

Finally, there’s the BeginLoad method. This is where the magic happens. This is the method that will provide the Frame with the content to display after navigating to a given URI.

Creating and Processing ObjectsLet’s say you tell the frame to navigate to Customers. This will be what you’ll find in the targetUri argument of the BeginLoad method. Once you have this you can get to work.

The first thing to do is find the correct ViewModel. The View Model-Exports property is an enumeration that contains all the exports with their metadata. Using a lambda expression you can find the correct ViewModel based on its key. Remember the following:

[ViewModelExport(typeof(ICustomersViewModel), "Customers")]

public class CustomersViewModel :

ContosoViewModelBase, ICustomersViewModel

Well, imagine you navigate to Customers. Then the following code will find the right ViewModel:

var viewModelMapping = ViewModelExports.FirstOrDefault(o => o.Metadata.

Key.Equals("Customers",

StringComparison.OrdinalIgnoreCase));

Once the ExportFactory is located, the same thing should happen for the View. However, instead of looking for the navigation key, you look for the ViewModelContract as defined in both the ViewModelExportAttribute and the ViewModelAttribute:

[ViewExport(ViewModelContract = typeof(IAboutViewModel))

public partial class AboutView : Page

Once both ExportFactories are found, the hard part is over. Now the CreateExport method allows you to create a new instance of the View and the ViewModel:

var viewFactory = viewMapping.CreateExport();

var view = viewFactory.Value as Control;

var viewModelFactory = viewModelMapping.CreateExport();

var viewModel = viewModelFactory.Value as IViewModel;

After both the View and the ViewModel have been created, the ViewModel is stored in the DataContext of the View, starting the required data bindings. And the OnLoaded method of the ViewModel is called to notify the ViewModel that all the heavy lifting

Page 42: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

38 VISUAL STUDIO MAGAZINE · January 2011 · VisualStudioMagazine.com

FEATURE MEF and Silverlight

has been done, and also that all Imports—if there are any—have been imported.

You shouldn’t underestimate this last step when you’re using the Import and ImportMany attributes. In many cases you’ll want to do something when creating a ViewModel, but only when everything has been loaded correctly. If you’re using an ImportingConstructor you definitely know when all Imports were imported (that would be when the constructor is called). But when working with the Import/Import-Many attributes, you should start writing code in all your properties to set flags in order to know when all properties have been imported. In this case the OnLoaded method solves this issue for you.

Passing Arguments to the ViewModelTake a look at the IViewModel interface, and pay attention to the OnNavigated method:

public interface IViewModel {

void OnLoaded();

void OnNavigated(NavigationArguments args);

string GetTitle();

}

When you navigate to Customers/1, for example, this path is parsed and the arguments are combined in the NavigationArguments class (this is just a Dictionary with extra methods like GetInt, GetString and so on). Because it’s mandatory that each ViewModel implements the IViewModel interface, it’s possible to call the OnNavigated method after resolving the ViewModel:

// Get navigation values.

var values = viewModelMapping.Metadata.GetArgumentValues(targetUri);

viewModel.OnNavigated(values);

When the CustomersViewModel wants to open a Customer Detail-ViewModel, the following happens:

NavigationService.Navigate("Customer/{0}", SelectedCustomer.Id);

These arguments then arrive in the CustomerDetailViewModel and can be used to pass to the DataService, for example:

public override void OnNavigated(NavigationArguments args) {

var id = args.GetInt("Id");

if (id.HasValue) {

Customer = DataService.GetCustomerById(id.Value);

}

}

The Final Chores If the View is a Page or a ChildWindow, the title of this control will also be extracted from the IViewModel object. This allows you to dynamically set the titles of your Pages and Child Windows based on the current customer.

After all these great things, there’s one last step. If the View is a ChildWindow the window should be displayed. But if the View-Model implements IClosableViewModel, the CloseView event of this ViewModel should be linked to the Close method on the ChildWindow.The IClosableViewModel interface is simple:

public interface IClosableViewModel : IViewModel {

event EventHandler CloseView;

}

Processing the ChildWindow is also trivial. When the ViewModel raises the CloseView event, the Close method of the ChildWindow gets called. This allows you to indirectly connect the ViewModel to the View:

// Close the ChildWindow if the ViewModel requests it.

var closableViewModel = viewModel as IClosableViewModel;

if (closableViewModel != null) {

closableViewModel.CloseView += (s, e) => {

window.Close();

};

}

// Show the window.

window.Show();

If the View isn’t a ChildWindow, then it should simply be made available in the IAsyncResult. This will show the View in the Frame. There. Now you’ve seen the whole process of how the View and ViewModel are constructed.

Using the Example CodeThe code download contains an MVVM application using this type of custom navigation with MEF. This article should’ve provided a good idea of how the sample works. For a deeper understanding, play with the code and customize it for your own applications. You’ll see how powerful and flexible MEF can be. VSM

Sa ndrino Di Mattia is a software engineer at RealDolmen and has a passion for everything that is Microsoft. He also participates in user groups and writes articles on his blog at blog.sandrinodimattia.net.

CODE DOWNLOAD AT VisualStudioMagazine.com/2011MEF

Page 43: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

APRIL 18–22, 2011LAS VEGAS, NEVADARIO ALL-SUITE HOTEL & CASINO

YOU ARE NOT A CODER: YOU ARE A CREATOR.

YOU TAKE AN IDEA AND MAKE IT A REALITY. You turn the

“impossible” into “possible.” You bring into being the applications

that your company relies on everyday.

Attend Visual Studio Live! for real-world education for creators

like you. Full-day intensive workshops. Practical how-to sessions.

Insightful keynotes from Microsoft MVPs. From Silverlight to

Sharepoint, Data Management to Visual Studio 2010, you’ll get

the training that will take your code to the next level.

REGISTER TODAYSAVE $300!USE CODE ADJAN

SUPPORTED BY:WWW.VSLIVE.COM/LV

PRODUCED BY:

Untitled-1 1 12/2/10 10:33 AM

Page 44: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

40 VISUAL STUDIO MAGAZINE · January 2011 · VisualStudioMagazine.com

Every once in a while, Microsoft toys with the idea of taking its dev tools cross-platform. But these fl irtations are typically accompanied by a fear of developer infi delity and often abandoned as a result. The mixed signals are, frankly, confusing. It’s time for Microsoft to get less fi ckle and decide which way it wants to go.

Cross-platform features can seem like a good idea at fi rst, only to produce ramifi cations that cause remorse. Case in point is Silverlight and its ability to run on Mac OS. Some at Microsoft love the idea that .NET can have reach similar to that of Flash, while others may fear that this fl exibility threatens Windows. It’s easy for us to be impatient and see Microsoft as waffl ing, but from Redmond’s point of view, I understand the equivocations.

This is not a new confl ict. During the beta period for an early version of Visual Basic, I remember fi nding Mac-specifi c functions in the documentation. But they were never implemented and the documentation entries were eventually removed. Another historical relic was a product (eventually acquired by Sun Microsystems) from a company called Chili!soft, that let classic ASP code run on non-Windows Web servers. Some developers and hosters used it, but Microsoft, despite tolerating it, never embraced the technology. The power was in our hands, but without Redmond’s blessing it seemed unworthy of our investment.

This issue isn’t going away; in fact, it’s more relevant than ever. Virtualization, the cloud and HTML5 each bring up the cross-platform question and blur the distinction between OSes. This creates confl icts, and Microsoft and its partners need to work through them.

Acquiring Minds Want to KnowOn Nov. 22, 2010, Novell was acquired by Attachmate. Novell also announced that a consortium of technology companies led by Microsoft funded about 20 percent of the $2.2 billion purchase price, and that the consortium was assuming ownership of various Novell intellectual property (IP) assets in return. What’s interesting is that the Novell Mono project (which encompasses an open source implementation of .NET on Linux) was not among the acquired assets. Mono goes to Attachmate instead.

Mono is sort of a modern-day Chili!soft ASP, and while Microsoft has warmed to Mono more than its Classic ASP forebear, the romance has been off-and-on. Similarly, MonoTouch and MonoDroid, which allow .NET developers to create applications in C# for the iOS (iPhone/iPad) and Android platforms, have received benign neglect

from Microsoft, at best. And if Microsoft has misgivings around Mono on the Mac, imagine how it feels about Moonlight, the Mono (that is, Linux) implementation of Silverlight.

If Microsoft didn’t adopt Mono from Novell, what IP assets did it acquire? I bet some of them will help ensure Linux runs well on Hyper-V. And if that’s true, then the Attachmate-Novell transaction is about broadening Microsoft’s cross-platform horizons anyway, so why give Mono the cold shoulder?

If Linux on Hyper-V is the present, then Linux on Windows Azure could be the near future. As the Windows franchise moves to the cloud, cross-platform capabilities enhance its value and it gets harder to see the platform game as zero-sum. Even on the client, HTML5 versatility makes Windows at once less proprietary and more compelling. The paradigm is shifting.

Think Outside the WindowMicrosoft must protect Windows, but it’s time for Redmond to consider the benefi ts of a cross-platform-friendly strategy, including cross-platform tools that enhance developer loyalty. Yes, it can be scary when people you love are away from home, but for the relationship to work there must be trust. Keep things interesting at home, and that’s where developers will want to be. Grant them freedom of movement (and the tools and languages that can move with them) when they need it and home is where they will return. The relationship will be stronger, richer and more fun.

There was a time when this sort of thinking was probably naïve. Microsoft needed to keep developers more captive to prevent Windows from being commoditized. Some companies, such as Apple, hew to that philosophy today. But the game is changing and the campaign playbook needs to change with it. The best platforms will have “big tent” planks, even as they accommodate their base constituency best. Microsoft seems to be moving to that strategy in fi ts and starts. Now it needs to pursue it without reservation. VSM

Andrew J. Brust is a Microsoft regional director and MVP, and coauthor of “Programming Microsoft SQL Server 2008” (Microsoft Press, 2008). A

frequent speaker at developer industry events, Brust is also cochair of the VSLive! family of conferences and a contributing editor to Visual Studio Magazine. Brust has been a participant in the Microsoft ecosystem for 15 years, and has worked closely with both the Microsoft Redmond-based corporate team and its field organization for the last six years.

If You Love Your Developers, Set Them Free

BY ANDREW J. BRUST

</Redmond Review>

Page 45: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

Untitled-14 1 10/7/10 3:47 PM

Page 46: Inside the tools and technologies - 1105 Mediapdf.1105media.com/VSMMag/2011/Jan.pdf · Redmond Diary: SQL Azure Federation BY ANDREW BRUST Explicit sharding support, or “Federation,”

Untitled-1 1 10/4/10 11:54 AM