msdn september 2014

108
magazine THE MICROSOFT JOURNAL FOR DEVELOPERS SEPTEMBER 2014 VOL 29 NO 9 Microsoft Azure Mobile Services.................... 18

Upload: -

Post on 21-Jun-2015

1.776 views

Category:

Technology


10 download

DESCRIPTION

مكتبة المصرف التجاري السوري

TRANSCRIPT

Page 1: MSDN September 2014

magazine

THE MICROSOFT JOURNAL FOR DEVELOPERS SEPTEMBER 2014 VOL 29 NO 9

Microsoft Azure Mobile Services....................18

0914msdn_CoverTip.indd 1 8/12/14 10:19 AM

Page 2: MSDN September 2014

0714msdn_CoverTip.indd 2 6/6/14 2:41 PM

Page 3: MSDN September 2014

magazine

THE MICROSOFT JOURNAL FOR DEVELOPERS SEPTEMBER 2014 VOL 29 NO 9

Soup to Nuts: From Raw Hardware to Cloud-Enabled Device Bruno Terkaly and Steven Edouard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

Introduction to Machine Learning Studio James McCaffrey . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

Creating a Location-Aware App with Geofencing Tony Champion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

Developing Your First Game with Unity and C#, Part 2 Adam Tuliper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

ASP.NET Web API Security Filters Badrinarayanan Lakshmiraghavan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

COLUMNSCUTTING EDGE A Look at ClearScript Dino Esposito, page 6

WINDOWS WITH C++ DirectComposition: Transforms and Animation Kenny Kerr, page 10

DATA POINTS Git: It’s Just Data! Julie Lerman, page 14

TEST RUN Winnow Classifi cation Using C# James McCaffrey, page 64

THE WORKING PROGRAMMER Fun with C#, Part 2 Ted Neward, page 70

MODERN APPS Build Universal Apps for the Windows Platform Rachel Appel, page 72

DIRECTX FACTOR Vertex Shaders and Transforms Charles Petzold, page 76

DON’T GET ME STARTED A Girl’s Road to Geekdom David Platt, page 80

Microsoft Azure Mobile Services....................18

Page 4: MSDN September 2014

Untitled-1 2 8/13/14 10:27 AM

Page 5: MSDN September 2014

Untitled-1 3 8/13/14 10:27 AM

Page 6: MSDN September 2014

"lightning fast" Redmond Magazine

"covers all data sources" eWeek

"results in less than a second" InfoWorld

hundreds more reviews and developer case studies at www.dtsearch.com

The Smart Choice for Text Retrieval® since 1991

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

Instantly Search Terabytes of Text

®

Ask about fully-functional evaluations

25+ fielded and full-text search types

dtSearch’s own document filters support “Office,” PDF, HTML, XML, ZIP, emails (with nested attachments), and many other file types

Supports databases as well as static and dynamic websites

Highlights hits in all of the above

APIs for .NET, Java, C++, SQL, etc.

64-bit and 32-bit; Win and Linux

dtSearch products:Desktop with Spider Web with SpiderNetwork with Spider Engine for Win & .NETPublish (portable media) Engine for LinuxDocument filters also available for separatelicensing

Printed in the USA

magazineSEPTEMBER 2014 VOLUME 29 NUMBER 9

MOHAMMAD AL-SABT Editorial Director/[email protected] SHARKEY Site Manager

MICHAEL DESMOND Editor in Chief/[email protected] LOW Features EditorSHARON TERDEMAN Features EditorDAVID RAMEL Technical EditorWENDY HERNANDEZ Group Managing Editor

SCOTT SHULTZ Creative DirectorJOSHUA GOULD Art Director

SENIOR CONTRIBUTING EDITOR Dr. James McCaffrey CONTRIBUTING EDITORS Rachel Appel, Dino Esposito, Kenny Kerr, Julie Lerman, Ted Neward, Charles Petzold, David S. Platt, Bruno Terkaly, Ricardo Villalobos

Henry Allain President, Redmond Media Group Michele Imgrund Vice President, Lead Services DivisionTracy Cook Director, Client Services & Webinar ProductionIrene Fincher Director, Audience Development & Lead Generation Marketing

ADVERTISING SALES: 818-674-3416/[email protected]

Dan LaBianca Chief Revenue Offi cerChris Kourtoglou Regional Sales ManagerDanna Vedder Regional Sales Manager/Microsoft Account ManagerDavid Seymour Director, Print & Online ProductionAnna Lyn Bayaua Production Coordinator/[email protected]

Neal Vitale President & Chief Executive Offi cerRichard Vitale Senior Vice President & Chief Financial Offi cerMichael J. Valenti Executive Vice President

Erik A. Lindgren Vice President, Information Technology & Application DevelopmentDavid F. Myers Vice President, Event Operations

Jeffrey S. Klein Chairman of the Board

MSDN Magazine (ISSN 1528-4859) 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. Annual subscription rates payable in US funds are: U.S. $35.00, International $60.00. Annual digital subscription rates payable in U.S. funds are: U.S. $25.00, International $25.00. Single copies/back issues: U.S. $10, all others $12. Send orders with payment to: MSDN Magazine, P.O. Box 3167, Carol Stream, IL 60132, email [email protected] or call (847) 763-9560. POSTMASTER: Send address changes to MSDN Magazine, P.O. Box 2166, Skokie, IL 60076. Canada Publications Mail Agreement No: 40612608. Return Undeliverable Canadian Addresses to Circulation Dept. or XPO Returns: P.O. Box 201, Richmond Hill, ON L4B 4R5, Canada.

Printed in the U.S.A. Reproductions in whole or part prohibited except by written permission. Mail requests to “Permissions Editor,” c/o MSDN Magazine, 4 Venture, Suite 150, Irvine, CA 92618.

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, Inc., 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, Jane Long, Merit Direct. Phone: 913-685-1301; E-mail: [email protected]; Web: www.meritdirect.com/1105

All customer service inquiries should be sent to [email protected] or call 847-763-9560.

Page 7: MSDN September 2014

Untitled-4 1 8/1/14 2:46 PM

Page 8: MSDN September 2014

msdn magazine4

A few months back we welcomed Lafe Low to the magazine as a features editor. Lafe has been a fi xture in the dev conference group at 1105 Media, helping shepherd the family of Visual Studio Live! and Live! 360 developer events. So when erstwhile Technical Editor David Ramel shuffl ed off to a new position with the Web editorial team at 1105 Media, Lafe was a natural choice to step into the gap.

Anyone who has met Lafe knows that the man is wired for 220. He brings amazing energy, humor and optimism to everything he does, and that perspective shines through in his work. So it should be little surprise to learn that Lafe took to his new role here at the magazine the same way he attacks the chutes at Tuckerman Ravine in New Hampshire—with an almost maniacal abandon.

Lafe’s arrival made me realize that MSDN Magazine has ties with the Live! 360 and Visual Studio Live! conferences that go back years. Senior Contributing Editor James McCaff rey was a frequent presenter at Visual Studio Live! events until about two years ago. Two other MSDN Magazine columnists—Ted Neward and Rachel Appel—are Live! 360 regulars today.

I asked McCaff rey about his experience at Visual Studio Live! and he said he valued presenting there because the events helped him recharge his (and I quote) “developer psychic energy.”

Says McCaff rey: “I speak at, and enjoy, offi cial Microsoft con-ferences like Build and TechEd, but many talks at those events are forward-looking and ‘vision’ messages—as they should be. Th e

talks at Visual Studio Live! give me practical information I can put to use immediately.”

Ted Neward has been writing Th e Working Programmer column in MSDN Magazine for more than four years now. He was presenting at Visual Studio Live! way back in 2004 (when it was owned by Fawcette Technical Publications), and he’s now a regular on the Live! 360 circuit. While Neward praises the technical content of the events, he says the real value is the opportunity for attendees to forge lasting professional relationships.

“I contend that any attendee that goes to a conference and doesn’t have a stack of business cards is an idiot,” Neward says, tongue planted only half in cheek. “Billy Hollis actually said it best: ‘Industry newbies, they go to conferences for the presentations. Veterans, they go for the people and the parties.’”

Th e next party takes place in Orlando, Nov. 17-21. Maybe you should meet (and party with) Ted Neward there.

Azure Insider Gets an UpgradeTh e eagle-eyed among you might notice a change with our regular Azure Insider column. Th e long-standing column has moved into the feature well, to appear as an ongoing feature series under the expert management of Bruno Terkaly and Ricardo Villalobos. I’ll let Ricardo take the mic, because he says it better than I:

“Considering the rapid and ongoing evolution of Microsoft Azure, it’s critical to get the inside view from the engineers building the platform’s infrastructure and services, as well as from those implementing solutions that address real-world scenarios. Based on the work and writing that we’ve done during the last two years for the Azure Insider column, cloud specialists worldwide will join our eff ort, collaborating with us in writing articles that will address common scenarios, off ering practical solutions based on their experiences. Some of the areas where we will focus our eff orts are high-scale database engines, global media distribution, scal-able sensor-based analysis, machine learning and multi-platform mobile support.”

Azure Insider is dead. Long live Azure Insider!

Six Degrees of Live! 360

© 2014 Microsoft Corporation. All rights reserved.

Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, you are not permitted to reproduce, store, or introduce into a retrieval system MSDN Magazine or any part of MSDN Magazine. If you have purchased or have otherwise properly acquired a copy of MSDN Magazine in paper format, you are permitted to physically transfer this paper copy in unmodifi ed form. Otherwise, you are not permitted to transmit copies of MSDN Magazine (or any part of MSDN Magazine) in any form or by any means without the express written permission of Microsoft Corporation.

A listing of Microsoft Corporation trademarks can be found at microsoft.com/library/toolbar/3.0/trademarks/en-us.mspx. Other trademarks or trade names mentioned herein are the property of their respective owners.

MSDN Magazine is published by 1105 Media, Inc. 1105 Media, Inc. is an independent company not affi liated with Microsoft Corporation. Microsoft Corporation is solely responsible for the editorial contents of this magazine. The recommendations and technical guidelines in MSDN Magazine are based on specifi c environments and confi gurations. These recommendations or guidelines may not apply to dissimilar confi gurations. Microsoft Corporation does not make any representation or warranty, express or implied, with respect to any code or other information herein and disclaims any liability whatsoever for any use of such code or other information. MSDN Magazine, MSDN, and Microsoft logos are used by 1105 Media, Inc. under license from owner.

Visit us at msdn.microsoft.com/magazine. Questions, comments or suggestions for MSDN Magazine? Send them to the editor: [email protected].

MICHAEL DESMONDEDITOR’S NOTE

“Billy Hollis actually said it best: ‘Industry newbies, they

go to conferences for the presentations. Veterans, they go for the people and the parties.’”

— Ted Neward

Page 9: MSDN September 2014

Since 1985, Melissa Data has provided the tools developers need to enhance

databases with clean, correct, and current contact data. Our powerful, yet

affordable APIs and Cloud services provide maximum flexibility and ease

of integration across industry-standard technologies, including .NET, Java, C, and

C++. Build in a solid framework for data quality and protect your

investments in data warehousing, business intelligence, and CRM.

A better way to build in data verification

• Verify international addresses for over 240 countries

• Enhance contact data with phone numbers and geocodes

• Find, match, and eliminate duplicate records

• Sample source code for rapid application development

• Free trials with 120-day ROI guarantee

Melissa Data.Architecting data quality success.

A better way to buildi d t ifi ti

Data Quality Tools for Developers

www.MelissaData.com 1-800-MELISSA

Address Verification

Phone Verification

Email Verification

Matching/Dedupe

Change of Address

Geocoding

Untitled-3 1 4/25/14 11:58 AM

Page 10: MSDN September 2014

msdn magazine6

Years ago, I was fascinated by the prospect of hosting the entire VBScript engine of Active Server pages within a Visual Basic application. I could create an astonishing proof of concept for a company willing to sell editorial content on CD that would reuse existing Active Server pages content just outside local or remote Web servers.

It was the late 1990s. Th ere was no Microsoft .NET Framework. Th ere was no HTML5. Only a few of us were actively exploring the depths of Dynamic HTML, yet hosting the scripting engine couldn’t have been easier. I had to reference an ActiveX control, publish my ActiveX objects within the scripting environment and I was ready to go.

More recently, a customer asked me about the most effective way to extract text fi les from SQL Server queries. Th at question was outside the usual range of topics I handle, so I was tempted to answer with something like, “Sorry, I don’t know.” However, I knew this customer was strong in database operations. I suspected there was more background behind the question.

Th e customer was regularly producing plain text fi les (mostly CSV and XML files) out of content stored in database tables within an instance of SQL Server. Th is annoyed its database staff , as requests were coming mostly from business with the usual urgency of busi-ness issues. There was no recurrent logic that could help create repeatable routines—at least in a SQL Server environment.

Ultimately, the customer was looking for a tool business people could program using easy script languages such as VBScript. Th e users needed controlled access to the databases for read-only pur-poses. Needless to say, the tool had to off er users a chance to easily create text fi les. Th is reminded me of the happy days of ActiveX and VBScript. I almost had a wave of regret when I heard about a relatively new library named ClearScript (clearscript.codeplex.com).

Integrate ClearScript into Windows Presentation FoundationClearScript lets you add scripting capabilities to a .NET application (as long as it uses the .NET Framework 4 or higher). ClearScript supports VBScript, JavaScript and V8. V8 is an open source JavaScript engine created by Google and integrated with Chrome. V8 has a high-performance JavaScript engine and fi ts well within multi-threading and asynchronous operation scenarios.

The net effect of adding ClearScript to a .NET application is you can pass JavaScript or VBScript expressions to the engine and they’ll be processed and run. Interestingly, you aren’t limited to using plain script objects such as arrays, JSON objects and primitive types. You can integrate external JavaScript libraries and script-managed .NET objects.

Once you’ve integrated ClearScript into an application, all that remains is to let the library know about the objects it can script. Th is means you publish your own objects in the context of ClearScript and let authorized users load and run existing scripts or write new ones.

If you want to add a layer of customization and let the user add pieces of his own logic without incurring the costs of change requests, then ClearScript is necessary, but it might not be suffi cient. Clear-Script is just one piece of the jigsaw puzzle. You might want to provide a way for the user to manage his own scripts. Also, you should create some ad hoc objects that simplify common tasks like creating fi les.

Here’s what I did to help a customer generate text and XML reports from a bunch of services exposed through a Web API back end. Th e main functional requirement was to let users create text fi les. For the proof of concept, I needed a shell application to host ClearScript. I opted for a Windows Presentation Foundation (WPF) application with a textbox to manually enter script code. Successive iterations added support for a default input folder and a UI to open/import existing script fi les. Figure 1 shows the WPF sample application in action.

A Look at ClearScript

CUTTING EDGE DINO ESPOSITO

Code download available at msdn.microsoft.com/magazine/msdnmag0914. Figure 1 A Sample Windows Presentation Foundation Application Hosting the ClearScript Engine

Page 11: MSDN September 2014

7September 2014msdnmagazine.com

Again, ClearScript is an open source project you can reference directly in your project by linking assemblies. You can also go through third-party NuGet packages, as shown in Figure 2.

Initialize ClearScriptYou’ll have to do some work before you can use the scripting engine programmatically. But at the end of the day, once it’s completely set up, the code in Figure 3 is all you need to trigger script code execution.

Th e Confi rm method belongs to the presenter class supporting the main view of the sample application. Trigger the method by any click on the Run button (visible in Figure 1). Th e SonoraConsole class you see referenced in the listing is just my own wrapper around the core classes of the ClearScript library.

Initializing the ClearScript engine takes place as the application starts up and is bound to the Startup event of the XAML Application class:

public partial class App : Application{ void Application_Startup(Object sender, StartupEventArgs e) { SonoraConsole.Initialize(); }}

Th e initialization can be as complex and sophisticated as you’d like, but it at least has to initialize the script engine of your selected language. You have to make the instance of the script engine available to the other parts of the application. Here’s one possible approach:

public class SonoraConsole{ public static void Initialize() { ScriptEngine = new VBScriptEngine() } public static ScriptEngine ScriptEngine { get; private set; } ...}

You might want to read from the confi guration fi le which script-ing language you should enable within the application. Th is is one possible confi guration schema:

<appSettings> <add key="language" value="vb" /></appSettings>

Once you have an instance of your chosen scripting engine ready, you can run any valid JavaScript (or VBScript) code. Th ere isn’t much you can do in a real-world scenario until you’re armed with these basic capabilities.

Add Scriptable ObjectsAll ClearScript engines expose a programmable interface through which you can add scriptable objects to the runtime environment. In particular, you use the method AddHostObject, like so:

ScriptEngine.AddHostObject("out", new SonoraOutput(settings));ScriptEngine.AddHostObject("xml", new XmlFacade());

Th is method requires two parameters. Th e fi rst parameter is the public name scripters will use to reference the object being pub-lished. Th e second parameter is just the object instance. Looking at the previous code snippet, in any JavaScript or VBScript you can use the name “out” to invoke any of the public methods available on the SonoraOutput interface. Here’s an example in JavaScript that references what’s shown in Figure 1:

var x = 4;out.print(x + 1);

As you may know, it’s a common practice in JavaScript to name mem-bers according to the camelCase convention. In .NET programming, the PascalCase convention is more common and also recommended. In my implementation of the SonoraOutput class, I deliberately opted to follow the JavaScript convention and called the method print instead of Print, as it would be the case in plain C# programming.

Based on my experience, there’s not much more you need to know and understand to get started on ClearScript. Most of the time, you can confi gure a ClearScript environment within a host application with the primary purpose of making available application-specifi c objects. More oft en than not, these are tailor-made objects wrapped around existing business objects and made nicer to use from within a script environment.

Th e primary users of a ClearScript environment are usually not full-time developers. They’re most likely people with some soft

public void Confirm(){ try { SonoraConsole.ScriptEngine.Execute(Command); OutputText = SonoraConsole.Output.ToString(); } catch(Exception e) { OutputText = e.Message; }}

Figure 3 Code to Trigger Script Code

Figure 2 You Can Install ClearScript via NuGet

Page 12: MSDN September 2014

msdn magazine8 Cutting Edge

development skills that would fi nd it unnecessarily complex and annoying to deal with the full details of .NET classes. ClearScript lets you expose large chunks of the .NET Framework directly to JavaScript and VBScript. I opted to have tailor-made objects designed for extreme simplicity. Here’s how you can publish in ClearScript a type instead of an object:

ScriptEngine.AddHostType("dt", typeof(DateTime));

When you reference a type, you’re giving users the power to program-matically create instances of that type. For example, the previous line of code adds the power of the .NET DateTime object to the scripting environment. Now, the following JavaScript code becomes possible:

var date = new dt(1998, 5, 20);date = date.AddDays(1000);out.print(date)

From within JavaScript code, you’re taking advantage of the full power of methods such as AddDays and AddHours. What if you want to get the diff erence between two dates? You can do something like this:

var date1 = new dt(1998, 5, 20);var date2 = date1.AddDays(1000);var span = date2.Subtract(date1);out.print(span.Days)

Th e TimeSpan object is handled correctly and the expression span.Days just returns 1000. Th is is due to the dynamic nature of the JavaScript language, which dynamically determines the object named “span” exposes a member named Days. If you want to create a Time-Span instance instead, you need to fi rst let the engine know it’s there.

To avoid exposing a million diff erent types, ClearScript lets you host an entire assembly. Th is is one possible approach:

ScriptEngine.AddHostObject("dotnet", new HostTypeCollection("mscorlib", "System.Core"));

Th e keyword dotnet now becomes the key to access any types and static members within mscorlib and System.Core. Creating a new date object takes a bit longer, but in return you can explicitly work with TimeSpan objects:

var date1 = new dotnet.System.DateTime(1998, 5, 20);var ts1 = new dotnet.System.TimeSpan(24, 0, 0);var ts2 = ts1.Add(new dotnet.System.TimeSpan(24, 0, 0));out.print(ts2.Days);

Th e JavaScript code snippet prints out the number 2, resulting from the sum of two distinct TimeSpan objects each counting for 24 hours. One thing that ClearScript doesn’t work well with is operator overloading. Th at just doesn’t exist. Th is means to sum

up dates or timespans, you have to use methods such as Add or Subtract. It also supports refl ection.

Generate the OutputTh e tool you see in Figure 1 must be able to display some results to the user. By default, the SonoraOutput object added to the Clear-Script engine just maintains an internal StringWriter object. All text processed by the print method is actually written to the underlying writer. Th e content of the writer is exposed to the outside world via the SonoraConsole class. Th is class is the sole point of contact between the ClearScript engine and the host application. Th e host application presenter just returns the content of the string writer through a property. Th at property is then bound to a TextBlock in the WPF UI. Th e method print writes to the UI via the string writer. Th e method clr clears the buff er and the UI.

Save to a Text FileMy customer only needed to create text fi les, mostly CSV fi les. Th is is relatively easy to achieve. All I did was create a fi le method and pass it some text content directly. I could also let it grab anything already printed to the screen and saved in the internal buff er. Th e most problematic aspect to deal with when it comes to fi les is naming and location. To make scripting really fast, it has to be trivially easy to create and retrieve fi les. I managed to have two default folders—one for input and one for output. I also assume that all fi les are TXT. If no fi le name is specifi ed, fi les assume a default name.

Th ese assumptions are possibly too restrictive for some scenarios, but my project was simply a proof of concept for a tool to produce fi les, not store them. As Figure 4 demonstrates, I could easily wrap the Xm-lWriter object into a nice component and create an XML fi le via script.

Wrapping UpWhat’s the point of creating an XML fi le via script? It’s actually the same as having script capabilities in some enterprise applications. You need script because you want to automate tasks. In some cases, creating ad hoc text or XML fi les is just what you need. Perhaps you can run queries on SQL Server and import them to CSV, but that requires administrative access to the production database and, more important, the appropriate skills. I would have trouble myself using xp_cmdshell to grab text files out of SQL Server queries. For a developer, it might not be diffi cult to arrange some ad hoc, easy-to-use objects that are ready-made for scripting.

My customer loved this idea as much as I loved using ClearScript. He asked me to add a lot more objects to the dynamic environment. I ended up adding a layer of inversion of control to confi gure objects to be loaded at startup. He’s also considering ClickOnce deployment across the company for when new tools are released.

DINO ESPOSITO is the co-author of “Microsoft .NET: Architecting Mobile Appli-cations Solutions for the Enterprise” (Microsoft Press, 2014) and the upcoming “Programming ASP.NET MVC 5” (Microsoft Press, 2014). A technical evange-list for the .NET Framework and Android platforms at JetBrains and frequent speaker at industry events worldwide, Esposito shares his vision of soft ware at soft ware2cents.wordpress.com and on Twitter at twitter.com/despos.

THANKS to the following technical experts for reviewing this article: Microsoft ClearScript Team Figure 4 Create an XML File via Script

Page 13: MSDN September 2014

DOMAINS | MAIL | HOSTING | eCOMMERCE | SERVERS

WordPress & Powerful App Platforms! Supports over 140 popular apps including WordPress, Drupal™, Joomla!™, TYPO3, and more

Security & version upgrade notifi cations Trial version available for all applications App Expert Support 1&1 CDN powered by CloudFlare™ and 2 GB guaranteed RAM for peak performance

Powerful Tools PHP 5.5, Perl, Python, Ruby 1&1 Mobile Website Builder NetObjects Fusion® 2013 included

Successful Marketing Facebook® advertising credits Listing in business directories 1&1 Search Engine Optimization 1&1 E-Mail Marketing Manager

State-of-the-Art Technology Maximum availability (Geo-Redundancy) 300 Gbit/s network connection

All Inclusive 1 FREE domain: .com, .net, .org, .biz, .info Unlimited Power: webspace, traffi c, mail accounts, MySQL databases Secure e-mail addresses with virus and spam protection Linux or Windows operating system

* Offer valid for a limited time only. The $0.99/month price refl ects a 12-month pre-payment option for the 1&1 Basic Hosting Package. Regular price of $5.99/month after 12 months. Some features listed are only available with package upgrade. Visit www.1and1.com for full promotion details. Program and pricing specifi cations and availability subject to change without notice. 1&1 and the 1&1 logo are trademarks of 1&1 Internet, all other trademarks are the property of their respective owners. ©2014 1&1 Internet. All rights reserved.

1and1.com1 (877) 461-2631

®

TRIAL30 DAY MONEY BACK GUARANTEE1 MONTH

FLEXIBLE PAYMENT OPTIONS1 CALL

SPEAK WITH AN EXPERT 24/71

NEW HOSTINGPOPULAR APPS - NOW EVEN BETTER!

Starting at

$0.99per month*

COMPLETEPACKAGESFOR PROFESSIONALS

Untitled-1 1 8/4/14 10:26 AM

Page 14: MSDN September 2014

msdn magazine10

DirectComposition visuals provide a lot more than just the off set and content properties I’ve illustrated in my last few columns. Th e visuals really come to life when you begin to aff ect them with transforms and animations. In both cases, the Windows compo-sition engine is a sort of processor and it’s up to you to calculate or construct the transform matrices, as well as the animation curves with cubic functions and sine waves. Th ankfully, the Windows API provides the necessary support with a pair of very complementary APIs. Direct2D provides great support for defining transform matrices, making light work of describing rotation, scale, perspective, translation and much more. Likewise, the Windows Animation Manager frees you from having to be a wizard at mathematics, allowing you to describe animations using a rich library of anima-tion transitions, a storyboard with key frames and loads more. It’s when you combine the Windows Animation Manager, Direct2D and DirectComposition into a single application that you can really experience the sheer power at your fi ngertips.

In my previous column (msdn.microsoft.com/magazine/dn759437) I showed how the DirectComposition API can be used along with Direct2D to get the best of both retained-mode and immediate-mode graphics. Th e sample project included with that column illustrated this concept with a simple application that lets you create circles, move them around, and control their Z-order quite simply. In this column I want to show you how easy it is to add some powerful eff ects with transforms and animation. Th e fi rst thing to realize is that DirectComposition provides overloads for many of its scalar properties. You might have noticed this if you’ve been following along over the last few months as I’ve explored the API. For exam-ple, a visual’s off set can be set with the SetOff setX and SetOff setY methods, as follows:

ComPtr<IDCompositionVisual2> visual = ...

HR(visual->SetOffsetX(10.0f));HR(visual->SetOffsetY(20.0f));

But the IDCompositionVisual interface IDComposition-Visual2 derives from also provides overloads of these methods that accept an animation object rather than a fl oating point value. Th is animation object materializes as the IDCompositionAnimation interface. For example, I could set a visual’s off set with one or two animation objects, depending on whether I need to animate one or both axes, like so:

ComPtr<IDCompositionAnimation> animateX = ...ComPtr<IDCompositionAnimation> animateY = ...

HR(visual->SetOffsetX(animateX.Get()));HR(visual->SetOffsetY(animateY.Get()));

But the composition engine is capable of animating far more than just a visual’s off set. Visuals also support 2D and 3D transfor-mations. A visual’s SetTransform method may be used to apply a 2D transform, given a scalar value:

D2D1_MATRIX_3X2_F matrix = ...

HR(visual->SetTransform(matrix));

Here, DirectComposition actually relies on the 3x2 matrix defi ned by the Direct2D API. You can do things like rotate, translate, scale and skew a visual. Th is aff ects the coordinate space the visual’s content is projected in, but it’s confi ned within two dimensional graphics with an X and Y axis.

Naturally, the IDCompositionVisual interface provides an over-load of the SetTransform method, but it doesn’t accept an animation object directly. You see, an animation object is responsible only for animating a single value over time. A matrix, by defi nition, consists of a number of values. You might want to animate any number of its members, depending on the eff ect you’d like to achieve. So, instead, the SetTransform overload accepts a transform object:

ComPtr<IDCompositionTransform> transform = ...

HR(visual->SetTransform(transform.Get()));

It’s the transform object, specifically the various interfaces derived from IDCompositionTransform, that provides overloaded methods that accept either scalar values or animation objects. In this way, you might define a rotation matrix with an animated angle of rotation, but a fi xed center point and axes. What you ani-mate is, of course, up to you. Here’s a simple example:

ComPtr<IDCompositionRotateTransform> transform = ...

HR(transform->SetCenterX(width / 2.0f));HR(transform->SetCenterY(height / 2.0f));HR(transform->SetAngle(animation.Get()));

HR(visual->SetTransform(transform.Get()));

The IDCompositionRotateTransform interface derives from IDCompositionTransform and represents a 2D transform that aff ects the rotation of a visual around the Z-axis. Here, I’m setting the center point to a fi xed value, based on some width and height, and using an animation object to control the angle.

So that’s the basic pattern. I’ve only described 2D transforms, but 3D transforms work in much the same way. Now let me illustrate more prac-tically by showing you how you can take the sample project included with my previous column and transform and animate it in various ways with the help of Direct2D and the Windows Animation Manager.

Illustrating transforms and animation in a print magazine does begin to push the limits of what can easily be grasped by staring

DirectComposition: Transforms and Animation

WINDOWS WITH C++ KENNY KERR

Page 15: MSDN September 2014

11September 2014msdnmagazine.com

at a static page. If you’d like to see it in action, check out my online course, where you can watch as it all comes to life (bit.ly/WhKQZT). To make the concepts a little more print-friendly, I’ll take the liberty of tweaking the sample project from my previous column to use squares rather than circles. This should make the various transforma-tions a little more obvious on paper. First, I’ll replace the SampleWindow m_geometry member variable with a rectangle geometry:

ComPtr<ID2D1RectangleGeometry> m_geometry;

Th en in the SampleWindow Create-FactoryAndGeometry method I’ll get the Direct2D factory to create a rectangle geometry instead of the ellipse geometry:

D2D1_RECT_F const rectangle = RectF(0.0f, 0.0f, 100.0f, 100.0f);

HR(m_factory->CreateRectangleGeometry( rectangle, m_geometry.GetAddressOf()));

And that’s all it takes. The rest of the app will simply use the geometry abstraction for rendering and hit testing as before. You can see the result in Figure 1.

Next, I’m going to add a simple message handler to respond to the WM_KEYDOWN message. In the SampleWindow Message-Handler method I’ll add an if statement for this:

else if (WM_KEYDOWN == message){ KeyDownHandler(wparam);}

As usual, the handler will need the necessary error handling to recover from device loss. Figure 2 provides the usual pattern of releasing the device resources and invalidating the window so the WM_PAINT message handler can rebuild the device stack. I’m also limiting the handler to the Enter key to avoid confusion with the Control key, which is used when adding shapes.

At this point, I’m ready to start experimenting with transforms and animations. Let’s begin simply with a basic 2D rotation trans-form. First, I need to determine the center point that will represent the Z axis, or the point around which to rotate. Because Direct-Composition expects physical pixel coordinates, I can simply use the GetClientRect function here:

RECT bounds {};VERIFY(GetClientRect(m_window, &bounds));

I can then derive the center point of the window’s client area, as follows:

D2D1_POINT_2F center{ bounds.right / 2.0f, bounds.bottom / 2.0f};

I can also rely on the Direct2D matrix helper functions to construct a matrix describing a 2D rotation transform of 30 degrees:

D2D1_MATRIX_3X2_F const matrix = Matrix3x2F::Rotation(30.0f, center);

And then I can simply set a visual’s transform property and com-mit the change to the visual tree. I’ll just apply this change to the root visual for simplicity:

HR(m_rootVisual->SetTransform(matrix));HR(m_device->Commit());

You can, of course, apply any number of changes to any number of visuals and the composition engine will take care of coordinating it all eff ortlessly. You can see the results of this simple 2D trans-form in Figure 3. You might notice some aliasing. Even though Direct2D defaults to anti-aliasing, it assumes the drawing will appear in the coordinate space in which it was rendered. The composition engine doesn’t have any knowledge of the geometry the com-position surface was rendered with,

so it has no way of correcting this. In any case, once animation is added to the mix, the aliasing will be short-lived and hard to spot.

To add animation to this transformation, I need to switch the matrix structure out for a composition transform. I’ll replace both the D2D1_POINT_2F and D2D1_MATRIX_3X2_F structures with a single rotate transform. First, I need to create the rotate transform using the composition device:

ComPtr<IDCompositionRotateTransform> transform;HR(m_device->CreateRotateTransform(transform.GetAddressOf()));

Keep in mind that even such seemingly simple objects must be discarded if and when the device is lost and recreated. I can then set the center point and angle using interface methods rather than a Direct2D matrix structure:

HR(transform->SetCenterX(bounds.right / 2.0f));HR(transform->SetCenterY(bounds.bottom / 2.0f));HR(transform->SetAngle(30.0f));

And the compiler picks the appropriate overload to handle the composition transform:

HR(m_rootVisual->SetTransform(transform.Get()));

Running this produces the same eff ect as in Figure 3, because I haven’t yet added any animation. Creating an animation object is simple enough:

ComPtr<IDCompositionAnimation> animation;HR(m_device->CreateAnimation(animation.GetAddressOf()));

void KeyDownHandler(WPARAM const wparam){ try { if (wparam != VK_RETURN) { return; }

// Do stuff! } catch (ComException const & e) { TRACE(L"KeyDownHandler failed 0x%X\n", e.result);

ReleaseDeviceResources();

VERIFY(InvalidateRect(m_window, nullptr, false)); }}

Figure 2 Scaffolding for Device Loss Recovery

Figure 1 Illustrating Transforms and Animation with Squares Instead of Circles

Page 16: MSDN September 2014

msdn magazine12 Windows with C++

I can then use this animation object in-stead of the constant value when setting the angle:

HR(transform->SetAngle(animation.Get()));

It gets more interesting when you try to confi gure the animation. Simple animations are relatively straightforward. As I mentioned earlier, animations are described with cubic functions and sine waves. I can animate this rotation angle with a linear transition, where the value progresses from 0 to 360 over 1 second by adding a cubic function:

float duration = 1.0f;

HR(animation->AddCubic(0.0, 0.0f, 360.0f / duration, 0.0f, 0.0f));

The third parameter of the AddCubic method indicates the linear coeffi cient, so that makes sense. If I left it there, the visual would rotate 360 degrees every second for eternity. I can decide to bring the animation to an end once it reaches 360 degrees, as follows:

HR(animation->End(duration, 360.0f));

Th e fi rst parameter of the End method indicates the off set from the beginning of the animation, regardless of the value of the animation function. Th e second parameter is the fi nal value of the animation. Keep this in mind because the animation will “snap” to that value if it doesn’t line up with the animation curve, and that would produce a jarring visual eff ect.

Such linear animations are easy enough to reason about, but more complex animations can become exceedingly complicated. Th at’s where the Windows Animation Manager comes in. Rather than having to call the various methods of IDCompositionAnimation to add sinusoidal and cubic polynomial segments, repeated seg-ments, and more, I can construct an animation storyboard with the Windows Animation Manager and its rich library of transitions. When that’s done, I can use the resulting animation variable to populate the composition animation. Th is involves a bit more code, but the benefi t is a great deal more power and control over your app’s animation. First, I need to create the animation manager itself:

ComPtr<IUIAnimationManager2> manager;

HR(CoCreateInstance(__uuidof(UIAnimationManager2), nullptr, CLSCTX_INPROC, __uuidof(manager), reinterpret_cast<void **>(manager.GetAddressOf())));

Yes, the Windows Animation Manager relies on COM activa-tion, so be sure to call CoInitializeEx or RoInitialize to initialize the runtime. I also need to create the transition library:

ComPtr<IUIAnimationTransitionLibrary2> library;

HR(CoCreateInstance(__uuidof(UIAnimationTransitionLibrary2), nullptr, CLSCTX_INPROC, __uuidof(library), reinterpret_cast<void **>(library.GetAddressOf())));

Typically, applications will hold on to these two objects for their lifetime as they’re needed for continuous animation and, specifi cally, for velocity matching. Next, I need to create an animation storyboard:

ComPtr<IUIAnimationStoryboard2> storyboard;HR(manager->CreateStoryboard(storyboard.GetAddressOf()));

Th e storyboard is what associates transitions with animation variables and defi nes their relative schedule over time. Th e story-

board is able to aggregate various transitions applied to diff erent animation variables; it ensures they remain synchronized; and it’s the storyboard that’s scheduled as a whole. Of course, you can create multiple story-boards to schedule independent animations. Now, I need to ask the animation manager to create an animation variable: ComPtr<IUIAnimationVariable2> variable;

HR(manager->CreateAnimationVariable( 0.0, // initial value variable.GetAddressOf()));

Once a storyboard is scheduled, the ani-mation manager is responsible for keeping the variable up-to-date so the app can request the eff ective value at any time. In this case, I’m simply going to use the animation variable to populate the composition animation with segments and then discard it. Now I can use the mighty transition library to create an interesting tran-sition eff ect for the animation variable:

ComPtr<IUIAnimationTransition2> transition;

HR(library->CreateAccelerateDecelerateTransition( 1.0, // duration 360.0, // final value 0.7, // acceleration ratio 0.3, // deceleration ratio transition.GetAddressOf()));

Th e transition will cause the animation variable to speed up and then slow down over the given duration until it comes to a rest at its fi nal value. Th e ratios are used to aff ect how relatively quickly the variable will accelerate and then decelerate. Keep in mind that the ratios combined can’t exceed a value of one. With the animation variable and transition ready to go, I can add them to the storyboard:

HR(storyboard->AddTransition(variable.Get(), transition.Get()));

Th e storyboard is now ready to be scheduled:HR(storyboard->Schedule(0.0));

Th e single parameter of the Schedule method tells the scheduler the present animation time. Th is is more useful for coordinating animation and coordinating with the composition engine’s refresh rate, but it will do for now. At this point, the animation variable is primed and I can ask it to populate the composition animation with curves:

HR(variable->GetCurve(animation.Get()));

In this case, it’s as if I called the composition animation, as follows:HR(animation->AddCubic(0.0, 0.0f, 0.0f, 514.2f, 0.0f));HR(animation->AddCubic(0.7, 252.0f, 720.0f, -1200.0f, 0.0f));HR(animation->End(1.0, 360.0f));

That’s certainly a lot less code than it took with the Windows Animation Manager, but making sense of that math isn’t that simple. Th e Windows Animation Manager also off ers the ability to coor-dinate and smoothly transition running animations, something that would be exceedingly diffi cult to do manually.

KENNY KERR is a computer programmer based in Canada, as well as an author for Pluralsight and a Microsoft MVP. He blogs at kennykerr.ca and you can follow him on Twitter at twitter.com/kennykerr.

THANKS to the following Microsoft technical experts for reviewing this article: Leonardo Blanco and James Clarke

Figure 3 A Simple 2D Transform

Page 17: MSDN September 2014

Untitled-1 1 10/13/11 11:25 AM

Page 18: MSDN September 2014

msdn magazine14

Source control in a data column? Ahh, but when that source con-trol is just one big database, it’s an invitation to some data-geeky fun. To be clear, you should know right up front I’m not writing about Git this month because I’m an expert. In fact, I’m writing about Git because I have struggled with it. My somewhat anemic GitHub profi le is testament to that fact. When the subject of Git comes up, I tend to change the subject for fear of my Git-lessness being discovered—as most of my developer friends interact with it without batting an eyelash.

While talking about my Gitless life recently with friend and local Ruby developer, Alan Peabody (github.com/alanpeabody), at a local hacker happy hour, he said to me, “But Julie, it’s just data.” Data? “Oooh, I love data! Tell me more!” Peabody described how Git relies on a database fi lled with key/value pairs, and then suggested that, rather than trying to use the available UI tools or what’s known as the “porcelain” commands for working with Git, I explore and play with the lower-level “plumbing” commands and APIs.

So Git has a database and accessible plumbing! Peabody’s advice absolutely inspired me. I’ve now spent some time exploring how Git works at a low level, how to read and write data representing repository activity, and how the different object types in Git relate to one another. I’m still far from expert but feel much more in control of my own activity on Git. More important, I’m having fun playing with Git and no longer fear it as a source of black magic.

If this path appeals to you, I recommend not missing the “Git Basics” and “Git Internals” chapters of the online “Pro Git” book by Scott Chacon (Apress, 2009) and available at git-scm.com/book.

I’m sure the Git database was pointed out to me before, but only in passing and while I was already overwhelmed by the learning curve. Now I plan to have a little fun with it. For the rest of this article, I’ll simply interact with the database and some code that it’s tracking and see how it aff ects the database that represents the repository.

Rather than starting with a new, empty repository, I’ll use an existing repository I’ve already been playing with: the very early work on Entity Framework 7 hosted at GitHub.com/aspnet/Entity Framework. Keep in mind this is a rapidly changing project at the time I’m writing this column, so the files I work with here might change.

I’ll execute the commands from Windows PowerShell, leveraging posh-git, which enhances the command-line experience with additional status information, color-coding and tab completion. You can fi nd instructions for setting this up in the download that accompanies this article.

Getting a Repository and Examining Git AssetsThe first step is to clone the existing repository, starting in my existing github folder and using the git clone command:

D:\User Documents\github> git clone git://github.com/aspnet/EntityFramework

By itself, this fi rst step elevated my Git skills! Git creates a new folder in my starting directory using the name of the repository, so I get D:\User Documents\github\EntityFramework. During the cloning process, if you open the EntityFramework folder in File Explorer as soon as it’s created, you’ll see that a .git subfolder is created fi rst. Th is is the repository and is what we call the git database. And Git is using this data to construct the source in what’s referred to as the working directory, that is, the rest of the EntityFramework folder.

Git: It’s Just Data!

DATA POINTS JULIE LERMAN

Code download available at msdn.microsoft.com/magazine/msdnmag0914.

Figure 1 The Solution Folder Created by Cloning the Repository, Including the Repository Itself in the .git Folder

Page 19: MSDN September 2014

15September 2014msdnmagazine.com

Once the operation is complete, the new folder, EntityFrame-work, looks much like any other Visual Studio solution folder except for one thing: the .git folder that is, itself, a complete copy of the cloned repository, including all branches. Notice its fi le struc-ture in Figure 1. In Git, a branch is just a pointer to a commit and a commit is a pointer to a snapshot of your working directory. Although a Git repository’s “main” branch is called master by default, that’s not a requirement. Th e EF team set their default branch to point to a branch they named dev. Using branches, you can modify and test code safely, before merging changes into other branches.

Th e rest of the EntityFramework folder contents represent the working directory. At some point, you tell Git to keep track of fi les you’ve added, changed or deleted in your working directory. Th is is referred to as “staging”—that is, the changes to these fi les are staged and ready to be committed. Staged changes are stored in the database and will remain there aft er you’ve committed them. Eventually, you push those changes up to the server. I won’t be dealing with that step in this article because my focus is on exploring the database activity. Th ere are many other concepts, such as trees and forking, references and headers that I’ll also ignore for this journey.

So what and where is this database? Is it a relational database like SQL Server or SQL CE? Nope. It’s a collection of files that represent Git objects. Each fi le is named with a hash and contains hashed contents. Remember that the database is a set of key/value pairs. The filename is the key that represents that object in the database, and its contents are the value. The collection of these objects comprises the database that represents the repository. Every key/value pair is stored in the .git/objects folder, and a master list of them is stored in a fi le called index. Th ere are other objects that keep track of the diff erent branches. It’s possible that many

fi les are just duplicated and never edited. Git has a way to point to those fi les rather than maintain separate copies, which keeps the Git database from bloating.

But there are no object files to be seen yet, because, initially, everything is compressed into a pack fi le along with its IDX coun-terpart. Th ese are in the PACK subfolder as shown in Figure 2.

What Does Git Know About My Code?Before I start editing, I want to take a look at what Git knows about my working directory and the repository. Th is means going back to Windows PowerShell and enabling posh-git to enhance my Git command-line experience. I start by changing directory to the EntityFramework folder (cd EntityFramework, just like the good old DOS days). Posh-git will see the .git subfolder and engage in the Windows PowerShell environment. Figure 3 shows my Windows PowerShell window now has the title posh~git and the prompt displays a status in yellow brackets—those are posh-git fea-tures. Currently, it indicates that my working directory is using the branch called dev, the main branch of the EF7 repository. When I cloned the repository, by default Git “checked out” this branch and that’s the version it put in my working directory. Th at’s really all that checking out means to Git. It builds the working directory from the designated branch. A fun exercise is to delete everything but the .git folder in File Explorer, then type “git checkout dev” in Windows PowerShell to see the directory contents get completely recreated. Unplug from the Internet if you want proof that it’s not coming from the server.

I can ask Git what it knows about my working directory with the git “status” command. All git commands start by addressing git, so type:

git status

It responds with the message:On branch devnothing to commit, working directory clean

Th at makes sense. I’m starting with a clean slate.

See How Git Responds to Editing Your Working Directory FilesNow it’s time to start banging on things to see this status change.

I’ll edit one of my favorite EF classes: DbContext.cs (which is in src\EntityFramework). I won’t even bother with Visual Studio. You can just use NotePad++ or your favorite text editor.

I added a comment at the top:// Julie was here

and saved.When I run git status again, the response

is now more interesting, as Figure 4 shows. Git sees that the fi le (noted in an unfortu-

nately hard-to-read red font) has changed, but it’s not staged. In other words, Git isn’t tracking it yet, but has compared the working directory files to its database to make that determination. Notice also the new prompt status for dev is +0 ~1 -0. Status displayed in red refl ects the working direc-tory, here indicating 0 new fi les, 1 modifi ed fi le and no deleted fi les.

Figure 2 You Won’t See Objects at First—They’re All Compressed into a PACK File

Figure 3 Windows PowerShell with posh-git Activated

Figure 4 Status After Modifying a File in the Working Directory (Red Font Indicates Working Directory Status)

Page 20: MSDN September 2014

msdn magazine16 Data Points

What about the database? If you look in File Explorer, you’ll see by its timestamp and size that the index fi le hasn’t changed. Noth-ing has changed in the objects folder, either. Th e Git database is unaware of the change in my working directory.

Dear Git, Please Track My File NowGit won’t track fi les until you tell it to. With typical porcelain com-mands, you just tell Git to add and it fi gures out which fi les to pull in. However, I’m going to use a plumbing command instead of the more common commands devs use with Git so I can be very explicit about each step I want to take. Note that the fi le path I type is case-sensitive:

git update-index --add src\EntityFramework\DbContext.cs

In response, the prompt’s status changes. It still says +0 ~1 -0, but the font is green now, not red, indicating this is the status of the index. Git is now tracking 0 new objects, 1 modifi ed object and 0 deleted objects, which are ready to be committed.

What about the Git index fi le and the objects folder?

Th e timestamp of the index fi le in the .git directory has changed. Th e fi le now has a notation that the object fi le that represents the DbContext.cs class has changed. Th is is how the status knows one modifi ed fi le is being tracked. For you Entity Framework coders, does this sound familiar? Th e index is akin to the EF DbContext, which tracks changes to your entities! DbContext knows when an object instance has been added or modifi ed or deleted. Th e index fi le is similar in this way.

But now you can see the object, too. Browse to .git/objects and you’ll see a new folder. If you edited in Visual Studio, you might see more, for example, if the project fi le changed. But I edited in Notepad++ and there’s just one new folder, named ae. In the folder is a fi le with a name that’s a hash, as shown in Figure 5.

Th is object is part of my database and overrides the object rep-resenting the DbContext.cs fi le that’s cached in the PACK fi le. Th at new object fi le contains a hash of the contents of DbContext.cs, including my change.

I can’t read it myself, but Git can. I’ll ask Git to display its entire contents with the cat-fi le command:

git cat-file -p aeb6db24b9de85b7b7cb833379387f1754caa146

The -p parameter requests a prettified listing of the text. It’s followed by the name of the object to list, which is a combination of the folder name (ae) and the file name. Git has shortcuts for expressing this object name.

A more interesting view is one that highlights the change. I can ask Git to show me what has changed in this branch (remember its name is “dev”) with:

git diff dev

Th e response, to which I’ve added line numbers for clarity, is shown in Figure 6.

Th is text is formatted using colored fonts that make it easy to distinguish the diff erent information. Notice that on line 8, there’s a dash (which is red), indicating I deleted a [blank] line. Line 9 begins with a plus sign, indicating a new line, and it’s displayed in a green font. If I added more objects to the index—for modifi ed or new fi les—they’d be listed here, as well.

Even though the index fi le is binary, I can also explore it. Th e git ls-fi les command is handy for listing all of the fi les represented by repository objects in the index fi le. Unfortunately, ls-fi les lists a combination of the cached index and the working directory, show-ing every fi le in my solution, so I have to dig through it to fi nd the fi les in which I’m interested. Th ere’s another git command, grep, that’s used for fi ltering. You can combine that with ls-fi les to fi lter the fi les. I’ll add grep (which is case-sensitive) and also ask ls-fi les to display the object name by using its -s (stage) parameter:

git ls-files -s |grep DbContext.cs

Including the stage parameter forces the output to contain a fi le-mode indicator (100664 means it’s a non-executable group-writable fi le) and the hash fi lename of the object with which it’s associated:

100644 aeb6db24b9de85b7b7cb833379387f1754caa146 0src/EntityFramework/DbContext.cs

Th ere’s much more to ls-fi les, but this is what I’m interested in at the moment—the fact that I can see how Git is mapping the object fi le to my working directory’s DbContext.cs fi le.

What Does Committing Do to the Git Database?Next, let’s see a bit of the eff ects of pushing objects from staged to committed. Remember that this commit happens only on your computer. Nothing gets committed directly to the original repos-itory on the server. Th e git commit command requires you add a note using the -m parameter. Keep in mind you’re committing all staged changes. I’ve made just one here:

git commit -m "Edited DbContext.cs"

Git responds by telling me the newly generated Git database name of the object (2291c49) that con-tains the commit information and what was committed. Th e insertion note is about what happened in the fi le—I added something: [dev 2291c49] Edited DbContext.cs 1 file changed, 1 insertion(+) D:\User Documents\github\ entityframework [dev]>Figure 6 Response to git diff Command

Figure 5 An Object Being Tracked by Git in Its Objects Folder

Git won’t track fi les until you tell it to.

Page 21: MSDN September 2014

17September 2014msdnmagazine.com

Notice the prompt is clean. Th e status now refl ects everything that’s happened since the last commit, which is nothing. I’m back to a clean slate.

What has happened in my database in response to the commit? I can tell that the index fi le wasn’t updated because its timestamp hasn’t changed.

But there are four new folders in the objects directory, each con-taining its own hash object. I use cat-fi le to see what’s in those fi les. Th e fi rst is a listing, similar to ls-fi les, of all the fi les and folders in the src\EntityFramework folder, along with their object names. Th e sec-ond is a list of all the objects in the src folder—that is, a list of the subfolders. Th ese, by the way, are “trees,” not “folders,” in git-speak. Th e third object contains a list of all the fi les and folders in the root EntityFramework folder. Th e fi nal object contains data that will be needed in order to sync to the server—my committer and author identity (my e-mail address), and one object for “tree” and another for “parent.” Interestingly, this fi nal object is the same object that was relayed in the response to the commit. It’s in a folder named 22 and its fi le name begins with 91c49.

All of these objects will be used for pushing up to the server repository when the time comes.

Have I Pwnd Git?In a way, I’ve taken ownership of Git by exploring things at a low level. I love explor-ing cause and eff ect as well as digging into plumbing. I’ve defi nitely lost my fear of Git’s magic, and playing around with it in this way has also serendipitously given me an under-standing of the command language and the beauty of working with Git at a low level. And it’s probably the most time I’ve ever spent in Windows PowerShell, too.

I have friends who are Git fanatics—like Cori Drew who jumped on Skype with me a number of times when I got confused by what I was seeing—and many more who use Git as though it’s the very air they breathe. Th ey tried to show me how Git works, but I initially gave up on it. Th is exercise defi nitely empowered me to learn more and benefi t from it, and to see how much more there is to learn. But it’s only my fascination with data and with banging on things to see how they react that got me to this point. And for that I am grate-ful for Alan Peabody’s inspiring suggestion.

Update: A week aft er I originally fi nished writing this article, I found myself using Git on two separate solo projects, branching and merging like an almost-pro! My own plunge was a great success and I hope yours will go just as well.

JULIE LERMAN is a Microsoft MVP, .NET mentor and consultant who lives in the hills of Vermont. You can fi nd her presenting on data access and other .NET topics at user groups and conferences around the world. She blogs at thedatafarm.com/blog and is the author of “Programming Entity Framework” (2010), as well as a Code First edition (2011) and a DbContext edition (2012), all from O’Reilly Media. Follow her on Twitter at twitter.com/julielerman and see her Pluralsight courses at juliel.me/PS-Videos.

THANKS to the following technical experts for reviewing this article: Cori Drew and Alan Peabody

Page 22: MSDN September 2014

msdn magazine18

There’s a new gold rush happening and it’s not about precious metals. It’s about building innovative devices for con-sumers and connecting them to the cloud. New Microsoft CEO Satya Nadella said last March that devices are “really uninteresting without the cloud.”

Th is makes sense. If the device is collecting information through sensors or cameras, how and where will you analyze this data? Aft er all, these low-end devices such as the Raspberry Pi have lim-ited compute power and storage space. Th e cloud fi lls this void and goes further by helping with security, device management and so on. So this month, we want to roll up our sleeves from both a hardware and soft ware perspective and learn what it takes to truly embrace this new computing paradigm.

Th e SmartDoor is the Internet of Th ings (IoT) product we’ll build from the ground up. We will eventually attach a doorbell, a camera and a

Raspberry Pi computing device (see Figure 1). Th e idea is that someone arrives at your doorstep and rings your doorbell. Once they press the doorbell, the device automatically takes a photo. Th en this photo is forwarded to a mobile device as a push notifi cation message (see Figure 2). Th e message has a hyperlink to the image of the person standing at your doorstep. Th is invention was inspired by the need to know who is ringing your doorbell, even if you’re not home.

We’ll begin by illustrating exactly how to purchase and assemble the raw hardware. Once we’ve built the hardware, we’ll build soft -ware that runs on the device itself, as well as the soft ware running in Microsoft Azure. This and future articles, though, will focus primarily on the requisite soft ware.

We’ll need the code to be able to take a picture and upload it to Azure. From there, it will need to send a push notifi cation to the appropriate mobile devices. Th is will indicate that someone has pressed the doorbell, and a photo of that person is available. Because of the ambitious nature of this project, we’ll provide a num-ber of blog posts to support the work and provide the needed details.

Easy as PiWe’ll address the code that runs on the Raspberry Pi device itself and some of the code that will run in the cloud—specifi cally within Azure Mobile Services. On the Raspberry Pi, we’ll install and run Mono, which is a free, open source project led by Xamarin that provides a Microsoft .NET Framework-compatible set of tools including a C# compiler and a CLR.

A ZURE I NS IDER

Soup to Nuts: From Raw Hardware to Cloud-Enabled DeviceBruno Terkaly and Steven Edouard

This article discusses:• How to control devices using Microsoft Azure Mobile Services as

the platform

• Assembling the confi guring hardware components

• Integrating a Raspberry Pi device with common hardware

Technologies discussed:Microsoft Azure, Mono, C#, Microsoft .NET Framework, Node.js, JavaScript

Page 23: MSDN September 2014

19September 2014msdnmagazine.com

Th e beauty of Mono is it lets you write .NET code compiled on Windows and run it unchanged on the Raspberry Pi. In our case, we’ll take a photo and upload it to Azure storage. In future articles, we’ll expand the code base to support the ability to send push notifi cations to a Windows Phone. To do this, we’ll have to leverage Push Notifi cations in the Azure Service Bus and write a Windows Store or Windows Phone app.

Getting the hardware together is straight-forward because almost all of it is available in a single Raspberry Pi kit called the Canakit. For more details, go to canakit.com. The kit contains a few useful things to get to get our IoT device built, including a system board, A/C adapter, general pur-pose input/output (GPIO) breakout, bread-board, breadboard wires, assorted resisters and LEDs. You’ll also need an external monitor and keyboard and mouse so you can configure and test the Raspberry Pi. Besides the Canakit, you’ll need two more things—a regular doorbell and a Raspberry Pi-compatible camera, both of which are easy to fi nd.

While the pile of hardware in Figure 3 might look intimidating, it’s actually quite simple to put together. If you can build a jigsaw puzzle, you can build a device like the SmartDoor. First, plug the camera module into the Raspberry Pi board. Take the camera out of the bag and attach the fl ex cable to the Raspberry Pi board. Go to bit.ly/1rk3vzk for more details on sending photos to the cloud.

We’ll present full installation of the door-bell itself in a later article, where we will solder it to the Raspberry Pi. For now, we’ll attach a breadboard, which is a test ver-sion of an electrical circuit plugged into a Raspberry Pi. We can use jumper cables and the breadboard to simulate the doorbell.

One of the core components is the GPIO breadboard. Th e GPIO is a hardware circuit with 26 separate pins (numbered left to right) that let you expand the system to interact with other devices. Generally, these pins let you con-nect such things as sensors, actuators, LEDs and so on. Th ere are diff erent types of pins, though. For example, there are two pins pro-viding a power source for connected devices, specifi cally a 3.3 volt and a 5 volt. Th ere’s also a 0 volt pin that acts as a ground, which is neces-sary to defi ne a circuit. Pins labeled GPIO act as a simple on/off switch. If you wish to perform serial communications, you’ll fi nd TX and RX pins (RS-232) for transmitting and receiving data. Th e soft ware that runs on the device will need to communicate with these pins.

One of the complexities in dealing with these pins is there’s a mismatch between the physical pins versus the logical pins with which the software communicates. This has to do with the Broadcom chips in the Raspberry Pi device. Th is means if a signal goes to the pin GPIO 0, your soft ware will actually need to read pin GPIO 17. It can be illogical, so be careful.

Th ere are other crucial hardware compo-nents. Resistors play a key role controlling current fl ow and lowering voltage levels, so you don’t fry the Raspberry Pi or any other devices connected to it. You’ll also need single-core wire to connect the GPIO unit to the Raspberry PI.

Testing, TestingConsequently, we’ll need to verify that we’ve built the hardware correctly. Th e easiest way to test the Raspberry Pi is to simply plug in the external monitor, keyboard, optional mouse and power supply. Once that’s done, plug in the power and the boot sequence

for Linux should appear. Th e default username will be “pi” and the password will be “raspberry.” Go to bit.ly/1k8xBFn for more details on setting up a Raspberry Pi.

Th e Raspberry Pi needs additional soft ware such as Mono to be able to run C# code. Before we can do anything on the device, we’ll need to update its Raspbian OS. Luckily, Pi comes with a pre- installed version. All we need to do is issue a couple of commands

in a console window to update the OS with the latest revision. Th en we can install the Mono runtime from Xamarin and some trusted root certifi cates. Th ese will let the device make HTTPS requests. All these steps are explained in the blog post at bit.ly/Unehrr.

The Software SideTh ere are two tiers we need to code against, the client tier (the Raspberry Pi device it-self) and the service tier (Azure Storage and Azure Mobile Services). Th ere are a variety of languages and back-end services from which to choose. We’ll run C# on the client and Node.js/JavaScript on the server. Th is can be a controversial choice because some folks feel two diff erent languages complicate the implementation.

Our goal was to show diversity. In the context of Node.js, we believe the numer-ous libraries and packages found at npmjs.org could potentially make your server code much easier. Node.js oft en results in a much smaller code base because the libraries are

Figure 2 The Windows Phone Receiving the Push Notifi cation

Figure 1 This Project Combines a Doorbell, Camera and a Raspberry Pi Device

Page 24: MSDN September 2014

msdn magazine20 Azure Insider

so powerful. Less code in a second language is better than lots of code in the same language. Th e diagram in Figure 4 highlights the expected workfl ow, which boils down to three steps:

1. Th e client requests a Shared Access Signature (SAS) token, which is presented as a URL.

2. Th e Node.js application running within Azure Mobile Services will return a SAS URL.

3. Th e client will use the SAS URL to upload the photo into Azure Storage as a blob.

We hosted our Node.js application within Azure Mobile Services. Th is provides a lot of pre-built support for mobile device clients, such as push notifi cations, CRUD storage integration, identity and the ability to build a custom API.

Focus on ServiceWe’ll start by building our service, because it will develop the client if there’s no service tier against which to code. Th ere would be no way to actually run and test the client unless you have a fully functional back-end service. Azure Mobile Services will host our service API.

Th is custom API will be based on Node.js and the Express Web framework. Our client (Raspberry Pi) will use those services to request a SAS. Th en the service will use that token to upload the photo it takes to Azure Storage. Using a SaS URL helps protect our Azure Storage account, because we won’t need to store the account credentials in the Raspberry Pi.

We addressed additional security issues in a past article (msdn.microsoft.com/magazine/dn574801). SAS tokens are also good for another reason—they free the middle tier (Node.js API) from having to broker the transfer of fi les to storage from the client.

Provisioning Mobile and StorageProvisioning Azure Mobile Services consists of just a few clicks in the Azure portal. Th e same is true for provisioning Azure Storage. As with anything that’s provisioned, you’ll need to think about URLs and the naming conventions you want to use for your cloud-based services. You also should consider which of the several global datacenters you’d like to use, making sure your storage account is in the same datacen-ter as Azure Mobile Services, so as to minimize latency and avoid data transfer costs. You can fi nd more detailed steps for provisioning your Azure Mobile Services and Azure Storage account at bit.ly/WyQird.

Shared Access SignaturesAs shown in Figure 4, the Raspberry Pi client will request an SAS token from Azure Mobile Services. It will do so by issuing a get request from an API we defi ne within Azure Mobile Services. SAS tokens free the middle tier (Node.js API) from having to broker the transfer of fi les to storage from the client.

Th e code in Figure 5 is an excerpt of the Node.js running within Azure Mobile Services as an API service endpoint. Th e purpose is to respond to requests from Raspberry Pi clients that need an SAS. Th e Raspberry Pi will issue a “get” request against the endpoint hosted in Azure Mobile Services, passing in the application key, which is an identifi er that uniquely represents our mobile service.

Th e application key represents a secure way to communicate with the specifi c Azure Mobile Service. Th e service will obtain

this key from the portal, which the code running on the Raspberry Pi will use, so you should keep it handy. Th en you can paste it into the client code. Th e client receives an SAS encapsulated within a URL the client can use in a later operation to upload a photo.

Now we’ll focus on some of the code that represents the server side Node.js application. There’s a powerful Node.js SDK tailored for Azure available at bit.ly/Unnikj. Th is code base provides a lot of support for other parts of the Azure platform, such as working with tables, queues, topics, notifi cation hubs, core management and so on. You can fi nd a tutorial on integrating Node.js and Azure Blob Storage at bit.ly/1nBEvBa.Figure 4 High-Level Architectural Diagram of the SmartDoor Project

Azure Mobile Services

API

Request SAS Key

Receive SAS Key2

1

Azure Storage

UploadedImages

Linux and Mono

Doorbell Raspberry PI

Camera

Send SAS Key and Photo to Azure Storage

Send SAS Key and Photo to Azure Storage

3

Figure 3 The Raspberry Pi Canakit (Does Not Include the Camera)

If you can build a jigsaw puzzle, you can build a device like the SmartDoor.

Page 25: MSDN September 2014

Untitled-6 1 5/28/14 4:02 PM

Page 26: MSDN September 2014

msdn magazine22 Azure Insider

For our purposes, the SAS the Node.JS application returns to the client is tied to the storage account we previously provisioned. As such, the Node.js application will need the storage account’s account name and management key.

Azure Mobile Services lets you externalize confi guration set-tings from your Node.js application. It’s generally considered bad programming practice to hardcode account key settings directly in code. App settings let you set key-value pairs the service runtime can read. You can learn more about it at bit.ly/1pwGFRN.

Ultimately, the Node.js code will return a URL with the SAS the client can use to upload photos. Along with the SAS token, the Node.js app returns an HTTP status of 201. Th is means it has fulfi lled that request and created a new resource (the SAS token).

You’ll fi nd a more detailed walk-through that addresses Node.js, SAS URL and the app settings at bit.ly/WyQird.

Inside the Raspberry Pi CodeTh e hardware/soft ware interface is actually quite straightforward. You can think of the client-side code as a giant state machine. It’s in a constant loop checking the status of the GPIO pins. As you can see from the code in Figure 6, we’re just checking to see if a pin is on or off , true or false.

Th ere are two ways to check pin status. Th e fi rst approach, and the one we’ve taken here, is to talk to the fi le system. By checking for specifi c fi les with specifi c values, we can determine if a pin is on or off . Another approach, which typically off ers higher performance, is

to check specifi c locations in memory for specifi c values. Although it’s slower to work with the fi le system, it’s considered safer. Th is approach leverages the built-in driver Linux provides.

Let’s address some of the code that will run on top of Mono on the Raspberry Pi using C#. Th e Raspberry Pi will perform four basic steps. First, it will respond to someone pressing the doorbell button. Second, based on the doorbell button being pressed, it will take a photo and save it to local storage. Th ird, it will request an SAS token it will then use to upload a photo. Fourth, it will upload the photo to Azure Storage as a blob. Although the code is written in C#, it’s all based on REST. Th is means any language or environ-ment capable of HTTP can perform these four steps.

We can control the Raspberry Pi by communicating with the GPIO. Th ere are only four points at which our application is going to use GPIO 2 for input and GPIO 1 for output. We’ll present some C# code to interface with these pins. Take a look at the main loop of the Raspberry Pi C# code in Figure 6. Pins 17 and 22 are used to test for device readiness and to take and upload a photo based on the doorbell button being pressed.

Th is infi nite long-polling loop is constantly checking pin voltages. So the soft ware knows something needs to be accomplished—like taking a photo. Th is loop runs at around 10hz as it polls the pin status. If you’re interested in learning more about benchmarking speed, go to bit.ly/1trFzt9.

Various languages operate at different speeds. For example, Python is fairly slow and you can’t use it in scenarios where speed is crucial. In this case, 10hz is fast enough to check if the doorbell switch has pulled pin 22 to Power when someone presses it.

Each of the three pins performs a diff erent function. Th e fi rst input, pin 17, must be connected to the Ground pin (which is interpreted by C# as false). If this isn’t confi gured this way, the program will exit. Pin 22 must be set to Power (which is interpreted as true). When pin 22 is true, the photo-taking process starts in TakeAndSend Picture. Th e showReady method uses pin 4, an output pin, to show the program is ready to shoot and upload pictures by driving an LED.

exports.get = function(request, response) {

// These are part of "App Settings" in the configuration section // of your service. Shouldn't be hardcoded into this Node.js script. containerName = request.service.config.appSettings.PhotoContainerName; accountName = request.service.config.appSettings.AccountName; accountKey = request.service.config.appSettings.AccountKey;

// Connect to the Blob service. blobService = azure.createBlobService( accountName,accountKey,accountName + '.blob.core.windows.net');

createContainer(); createPolicies();

var sasResponse = GetSAS(); return request.respond(201, sasResponse);}

Figure 5 Node.js Code for the Microsoft Azure Mobile Services API

while (true){ // If pin 17 is off, we are ready. if (!s_Gpio.InputPin(FileGPIO.FileGPIO.enumPIN.gpio17)) { showReady(true); // If pin 22 is true, indicate to the user that the system is busy, // take a photograph and then upload to the cloud. if (s_Gpio.InputPin(FileGPIO.FileGPIO.enumPIN.gpio22)) { showReady(false); TakeAndSendPicture(); } } else { // Not ready to take a photo yet. showReady(false); break; } // Pause for one-tenth of a second. System.Threading.Thread.Sleep(100);}

Figure 6 Long-Polling Loop Interfacing with the Raspberry Pi GPIO to Control Behavior

The easiest way to test the Raspberry Pi is to simply

plug in the external monitor, keyboard, optional mouse

and power supply.

Page 27: MSDN September 2014

Untitled-1 1 5/7/14 2:43 PM

Page 28: MSDN September 2014

msdn magazine24 Azure Insider

Th e solution leverages conditional compilation symbols so the appropriate code runs on the Raspbian OS, versus the normal Windows/Desktop OS. The code in the solution has to be dif-ferent because taking a picture under Raspbian OS is not an API call. It involves running an executable in its own process. Under Windows 8, on the other hand, you leverage the CaptureFileAsync API of CameraCaptureUI.

To take the photo, we call into the built-in raspistill executable as shown in Figure 7. Th is is already confi gured to snap a photo and save it as a JPEG. Th is lets you specify the fi lename, photo quality and the image size. Raspistill is started as a child process. While the photo is being taken, the code requests an SAS URL from the Azure Mobile Service. It then uploads the picture to Azure Blob Storage.

The Visual Studio solution is built to run on a Raspberry Pi, as well as on a traditional Windows OS. Th e solution leverages

conditional compilation symbols so that the appropriate code runs on the Raspbian OS versus the normal Windows desktop OS. Th e code in the solution has to be diff erent because taking a picture under Raspbian OS is platform-specifi c. To keep things simple, when compiled for Windows 8, we don’t take a photo. Instead, we upload an existing image (testPhoto.jpg) to the cloud.

Th e good news is you can share a lot of code between Windows and Raspbian. Everything from acquiring the SAS to uploading the photo is identical. So if it works in Windows, it will most likely work the same way on Raspbian. Th is dramatically simplifi es client-based code development and testing. Th e Raspberry Pi is a constrained device, so it’s best to minimize the work done on the device itself.

Once the device takes a photo, you should be able to see it in two places. Th e fi rst place is on the device itself, specifi cally in /home/pi/Desktop/me.jpg, where it was specifi ed on the command line. Th en, of course, the whole point is to upload the image to the Azure Storage Account container.

Wrapping UpTh is is a solid starting point for building your own Internet of Th ings device. We’ve tried to address everything from procuring the hardware, assembly, installing soft ware, writing soft ware and testing functionality. We’ve also supplied many supporting blog posts. But this solution isn’t complete.

In the next article, we’ll address the way push notifi cations are sent to phones so you can view the photo of the person ringing the doorbell on a mobile device. We’ll introduce the notifi cation service, which is part of the Azure Service Bus. We’ll also build a Windows Phone application capable of receiving push notifi cations from Azure. Finally, we’ll address additional storage mechanisms, such as using a MongoDB NoSQL database and interfacing with a face recognition back end. Stay tuned for more Internet of Th ings with Azure.

BRUNO TERKALY is a developer evangelist for Microsoft . His depth of knowledge comes from years of experience in the fi eld, writing code using a multitude of platforms, languages, frameworks, SDKs, libraries and APIs. He spends time writing code, blogging and giving live presentations on building cloud-based applications, specifi cally using the Microsoft Azure platform. You can read his blog at blogs.msdn.com/b/brunoterkaly.

STEVEN EDOUARD is a developer evangelist for Microsoft . Before that, he worked on the .NET runtime team as a soft ware test engineer delivering products like the .NET Framework 4.5 and .NET Native Compilation. Now his passion resides in exciting people on the limitless potentials of cloud computing services through engaging technical demonstrations, online content and presentations.

THANKS to the following Microsoft technical experts for their review: Gil Isaacs and Brent Stineman

static void TakeAndSendPicture(){

#if LINUX // Start photo-taking process. This will kick off the raspistill process. // We'll wait for it to exit after we get the photo URL. Process raspistill = new Process(); raspistill.StartInfo = new ProcessStartInfo("/usr/bin/raspistill", "-n -q " + photoQuality + " -o /home/pi/Desktop/me.jpg -h 200 -w 200 -t 500") { UseShellExecute = false };

raspistill.Start();#endif

// Get Photo URL while the picture is being taken. WebRequest photoRequest = WebRequest.Create( "https://raspberrypiservice.azure-mobile.net/api/getuploadblobsas?"); photoRequest.Method = "GET"; photoRequest.Headers.Add("X-ZUMO-APPLICATION", "AIzNtpTdQLjORKJJhTrQWWRSHSnXcN78"); PhotoResponse photoResp = null; using (var sbPhotoResponseStream = photoRequest.GetResponse().GetResponseStream()) { StreamReader sr = new StreamReader(sbPhotoResponseStream);

string data = sr.ReadToEnd();

photoResp = JsonConvert.DeserializeObject<PhotoResponse>(data); }

Console.WriteLine("Pushing photo to SAS Url: " + photoResp.sasUrl); WebRequest putPhotoRequest = WebRequest.Create(photoResp.sasUrl); putPhotoRequest.Method = "PUT"; putPhotoRequest.Headers.Add("x-ms-blob-type", "BlockBlob");

#if LINUX // Wait until the photo is taken. raspistill.WaitForExit(); FileStream fs = new FileStream(@"/home/pi/Desktop/me.jpg", FileMode.Open);#else FileStream fs = new FileStream(@"testPhoto.jpg", FileMode.Open);#endif

using (fs) using (var reqStream = putPhotoRequest.GetRequestStream()) { Console.WriteLine("Writing photo to blob..."); fs.CopyTo(reqStream); } using (putPhotoRequest.GetResponse()) {

}}

Figure 7 Taking a Photo and Uploading It to the Cloud

Less code in a second language is better than lots of code in the

same language.

Page 29: MSDN September 2014

(888) 850-9911Sales Hotline - US & Canada:

/update/2014/09

US Headquarters ComponentSource650 Claremore Prof WaySuite 100WoodstockGA 30188-5188USA

© 1996-2014 ComponentSource. All Rights Reserved. All prices correct at the time of press. Online prices may vary from those shown due to daily fluctuations & online discounts.

European Headquarters ComponentSource30 Greyfriars RoadReadingBerkshireRG1 1PE United Kingdom

Asia / Pacific Headquarters ComponentSource3F Kojimachi Square Bldg3-3 Kojimachi Chiyoda-kuTokyoJapan102-0083 www.componentsource.com

www.componentsource.com

We accept purchase orders.Contact us to apply for a credit account.

Help & Manual Professional from $583.10Easily create documentation for Windows, the Web and iPad.

• Powerful features in an easy accessible and intuitive user interface

• As easy to use as a word processor, but with all the power of a true WYSIWYG XML editor

• Single source, multi-channel publishing with conditional and customized output features

• Output to HTML, WebHelp, CHM, PDF, ePUB, RTF, e-book or print

• Styles and Templates give you full design control

BEST SELLER

Aspose.Total for .NET from $2,449.02Every Aspose .NET component in one package.

• Programmatically manage popular fi le formats including Word, Excel, PowerPoint and PDF

• Work with charts, diagrams, images, project plans, emails, barcodes, OCR and OneNote fi les alongside many more document management features in .NET applications

• Common uses also include mail merging, adding barcodes to documents, building dynamic reports on the fl y and extracting text from PDF fi les

BEST SELLER

LEADTOOLS Document Imaging SDKs V18 from $2,695.50Add powerful document imaging functionality to desktop, tablet, mobile & web applications.

• Comprehensive document image cleanup, preprocessing, viewer controls and annotations

• Fast and accurate OCR, OMR, ICR and Forms Recognition with multi-threading support

• PDF & PDF/A Read / Write / Extract / View / Edit

• Barcode Detect / Read / Write for UPC, EAN, Code 128, Data Matrix, QR Code, PDF417

• Zero-Footprint HTML5/JavaScript Controls & Native WinRT Libraries for Windows Store

BEST SELLER

ComponentOne Studio Enterprise 2014 v2 from $1,315.60.NET Tools for the Professional Developer: Windows, HTML5/Web, and XAML.

• Hundreds of UI controls for all .NET platforms including grids, charts, reports and schedulers

• Includes 40+ UI widgets built with HTML5, jQuery, CSS3 and SVG

• New Sparkline control for HTML5 and Web Forms and options for exporting Data views

• New tools to connect, manage and display data in modern Web & Windows interfaces

• All Microsoft platforms supported, Visual Studio 2013, ASP.NET, WinForms, WPF & more

BEST SELLER

Untitled-1 1 7/31/14 10:16 AM

Page 30: MSDN September 2014

IT AND DEVELOPER TRAINING THAT’S OUT OF THIS WORLD.

Live! 360 brings together ve conferences, and the brightest minds in IT and Dev, to explore leading edge technologies and conquer current ones. These co-located events will incorporate knowledge transfer and networking, along with out-of-this-world education and training, as you create your own custom conference, mixing and matching sessions and workshops to best suit your needs.

ORLANDO NOV17-21ROYAL PACIFIC RESORT AT

UNIVERSAL ORLANDO

SUPPORTED BYEVENT PARTERS PLATINUM SPONSOR GOLD SPONSORS

Look for the FULL Live! 360 Pull-Out Agenda on Page 33

Untitled-9 2 8/12/14 1:22 PM

Page 31: MSDN September 2014

live360events.com

The Future of Software Development is Back, Modern Apps Live! will break down the latest techniques in low cost, high value application development. modernappslive.com

PRODUCED BY

magazine

CONNECT WITH LIVE!360 twitter.com/@live360events facebook.com – Search “Live 360”

linkedin.com – Join the “Live 360” group!

USS Collaborate: Let’s Work Together. Climb aboard to work through your most pressing

SharePoint projects.

SQL Server Live! will leave you with the skills needed to Conquer Planet Data, whether you are a

DBA, developer, IT Pro, or Analyst.

Master the Modern Apps Landscape and learn how to architect, design and build a complete

Modern Application from start to nish.

Join us for an IT Training Odyssey, focused entirely on making your datacenter more

modern, more capable, and more manageable.

Calling all .NET Developers: The Code is Strong with This One; Experience unbiased and

practical training on the Microsoft Platform.

REGISTER BY SEPTEMBER 17 AND SAVE $500!

Scan the QR code to register or for more event details.

Use promo code L360SEP2

Five events, 29 tracks, and literally hundreds of sessions to choose from – mix and match sessions to create your own, custom event line-up – it’s like no other conference available today.

Untitled-9 3 8/12/14 1:22 PM

Page 32: MSDN September 2014

msdn magazine28

There’s no unanimous agreement on exactly what the term “machine learning” (ML) means. In my mind, ML is any system that uses data to help make predictions. For example, you might want to predict who will win the Super Bowl, or to which group (cluster) of people a new customer will be most similar.

Writing ML systems from scratch using C# or any other pro-gramming language is fascinating, but it’s time-consuming, requires specialized knowledge and is oft en diffi cult. Th e new Microsoft Azure ML Studio (released in July 2014) makes creating ML systems much easier, faster and more effi cient. In this article, I’ll walk you through a complete example that will get you up and running with ML Studio.

Th e best way to see where this article is headed is to examine the screenshot in Figure 1. Th e image shows a completed ML Studio experiment. Th e goal of the experiment is to predict the political party affi liation (Democrat or Republican) of a member of the U.S. House of Representatives, based on previous voting behavior.

At the top of the image, notice that ML Studio is running in Internet Explorer—it’s a Web-based application. More specifi-cally, ML Studio is the front end for the Microsoft Azure Machine Learning service. From here on, for simplicity, I’ll use the term “ML Studio” to refer to both the client front end and the Azure back end. In the address bar, you can see that I’m using an internal URL “passau.cloupapp.net.” During development, the ML Studio project was code-named “Passau” and you might come across that term in the documentation. By the time you read this article, the public URL for ML Studio will be available at azure.microsoft.com.

Using ML Studio to create ML systems is roughly analogous to using Visual Studio to create executable programs, though you shouldn’t get too carried away with this notion. To use Visual Studio, you can either buy the tool or use a free trial version. With ML Studio, you’re charged for using the service, but there will be ways to try the sys-tem out for free. Th e exact details are certain to change frequently—constant change is one of the major downsides, in my opinion, of working with cloud-based systems. I like to install a product on my desktop and have any changes be totally my decision. In the brave new world of cloud computing, you have to be prepared for a working en-vironment where change is no longer completely under your control.

MICROS OF T A ZUR E

Introduction to Machine Learning StudioJames McCaffrey

This article discusses:• What the Machine Learning Studio is all about

• Setting up the data

• Creating the experiment

• Training and evaluating the model

• Making predictions

Technologies discussed:Machine Learning Studio

Code download available at:msdn.microsoft.com/magazine/msdnmag0914

Page 33: MSDN September 2014

29September 2014msdnmagazine.com

ML Studio has three primary working areas. On the left you can see items with names like Saved Datasets, Data Input and Output, and Machine Learning. Th ese are categories and if you expand them, you see specifi c items that can be dragged onto the center design sur-face. Th is is somewhat similar to the Visual Studio Toolbox, where you can drag UI controls onto a design surface. However, ML Studio modules typically represent what you can think of as methods—that is, prewritten code that performs some sort of ML task.

Th e center area of ML Studio is called the experiment. Th is is analogous to the Visual Studio editor—the place where you do most of your work. In Figure 1, the experiment is titled Voting Experiment. An experiment title is roughly analogous to a Visual Studio Solution name. Th e rectangular boxes are modules that were dragged onto the design surface. For example, the module labeled “Voting data” is the raw data source, and the module labeled “Logistic Regression Binary Classifi cation Model” (the label is partially cut off ) is the core ML algorithm used.

Th e curved lines establish input- output flows between modules. To be honest, my fi rst impression as a developer was not altogether positive: “Oh great. Curvy lines. I don’t like curvy lines. Th at’s not real programming.” But it didn’t take me long to adapt to the ML Studio visual style of creating systems, and now I am a Believer.

The right-hand side of ML Studio shows details about what-ever is currently selected in the main work area. In Figure 1, because the Logistic Regression Binary Classi-fi cation Model module is selected

(its border is bolded), the informa-tion in the right-hand area, such as “Optimization tolerance,” with value 1.0E-07, refers specifically to that module. You can think of the information in the right-hand area as the parameter values (or equivalently, argument values, depending on your point of view) of the selected module/method.

You can run an experiment by clicking on the Run icon located at the bottom of the tool. Th is is somewhat equivalent to hitting the F5 key in Visual Studio to execute a program in the debugger. As each module fi nishes, ML Studio dis-plays a green checkmark inside the module. You can also see a Save icon but, by default, ML Studio automat-ically saves your experiment every few seconds—working in the cloud

can be hazardous due to issues like dropping a network connection.In the sections that follow, I’ll walk you through the creation of

the experiment in Figure 1 so you’ll be able to replicate it. Doing so will give you a solid basis for investigating ML Studio on your own, or for exploring the early-release documentation. Th is article assumes you have at least beginning-level programming skills (in order to understand ML Studio and Visual Studio analogies and terminology), but does not assume you know anything about ML Studio or machine learning.

Getting the Results?If you’re new to ML Studio, you’re probably wondering where to fi nd the output of the experiment. As it turns out, a typical ML Studio experiment oft en has multiple outputs. Th e bottom-line output, so to speak, is shown in Figure 2. I chopped out the center section to make the image a bit easier to view.

Figure 1 A Complete Azure ML Studio Experiment

Figure 2 Azure ML Studio Experiment Results

Page 34: MSDN September 2014

msdn magazine30 Microsoft Azure

In order to see these results, I right-clicked on the right-most Score Model experiment module and selected the Visualize option from the context menu. Th is opened a separate window with the results as shown. For now, look at the bottom part of the image, which resembles:

unknown-party y n y n . . y n democrat 0.0013unknown-party y y y y . . n n republican 0.7028

This output indicates that after the prediction model was created, it was presented with two new data items. Th e fi rst, with an unknown party, is data for a hypothetical Representative who voted “yes” on a legisla-tive bill related to handicapped infants (the columns have headers if you look closely), “no” on a bill related to a water project, and so on, through a “no” vote on a bill related to South Africa. The model created by ML Studio predicts the hypothetical Representative is a Democrat. Th e second data item is for a hypothetical Representa-tive who voted “yes” on the fi rst eight bills and “no” on the second eight bills; the model predicts the person is a Republican.

Setting up the DataNow that you understand the goal of the demo experiment, you’re in a better position

to understand how to create the experiment. It’s fairly safe to say that all ML Studio experiments start with some data, and one or more questions to be answered. Here, the demo data is a well-known (to the ML community, at least) benchmark data set oft en called the Congressional Voting Records Data Set (or the UCI Voting Data Set, because the primary location of the fi le is on a server maintained by the University of California, Irvine). Th e raw data, a simple text fi le named house-votes-84.data, can be found by doing an Internet search.

Th e fi rst four lines of the raw data are:republican,n,y,n,y,y,y,n,n,n,y,?,y,y,y,n,yrepublican,n,y,n,y,y,y,n,n,n,n,n,y,y,y,n,?democrat,?,y,y,?,y,y,n,n,n,n,y,n,y,y,n,ndemocrat,n,y,y,n,?,y,n,n,n,n,y,n,y,n,n,y...

Th ere are a total of 435 comma-delimited lines of data, one for each of the 435 members of the U.S. House of Representatives in 1984. Th e fi rst column/fi eld is the party and is either democrat or republican (there were no independents or other parties at the time). Th e next 16 items on each line represent a yes vote (y), a no vote (n) or a missing vote (?).

ML Studio can read data directly off the Web, or from Azure stor-age, but I prefer to create my own data store. To do so, I copied the text fi le into Notepad on my local machine, and then added column headers based on the fi le description on the UCI Web site, like so:

political-party,handicapped-infants, . . ,south-africarepublican,n,y,n,y,y,y,n,n,n,y,?,y,y,y,n,yrepublican,n,y,n,y,y,y,n,n,n,n,n,y,y,y,n,?democrat,?,y,y,?,y,y,n,n,n,n,y,n,y,y,n,n...

When writing ML code from scratch, working with column headers can be annoying, so headers are oft en left off data fi les. But with ML Studio, using column headers is actually easier than omitting them, as well as making the data easier to understand. I renamed the local fi le to VotingRawWithHeader.txt and saved it on my machine. If you want to use the same headers as I did, you can get the data fi le I used in the code download for this article at msdn.microsoft.com/magazine/msdnmag0914.

Aft er navigating to the ML Studio homepage, I clicked on the Datasets category in the left -hand pane. In the main working area, ML Studio displays a list of built-in data sets, for example Iris Two Class Data and Telescope Data. Most of these data sets you initially

see are more or less well-known benchmark sets (many from the UCI repository) that can be used for exploring ML Studio. In the lower-left corner of ML Studio, I located the New icon and clicked on it.

From there I could choose either a new Dataset or a new Experiment, so I clicked on Dataset and then on the From Local File icon. Th is brought up the dialog box shown in Figure 3. I used the Browse but-ton to target the local fi le, named the data set “Voting data,” selected type “Generic CSV fi le with a header (.csv)” and typed in a brief description of the data set.

I clicked on the OK checkmark and ML Studio uploaded the local fi le into Azure stor-age and saved it. Back in the Datasets view in Figure 4 Processing the Data

Figure 3 Creating a New Dataset

It’s fairly safe to say that all ML Studio experiments start with some data, and one or more questions to be answered.

Page 35: MSDN September 2014

Manage Information Workflows

with Altova® FlowForce® Server

Learn more and download a free trial at www.altova.com/server

Introducing FlowForce Server, the powerful

new platform for automating today’s multi-step,

enterprise-level data mapping, transformation,

integration, and reporting tasks. This flexible workflow orchestration tool

works with any combination of XML, database, flat file, EDI, Excel, XBRL,

and/or Web service data common to many essential business processes.

• FlowForce® Server for orchestrating

events, triggers, and the automation

of processes

• MapForce® Server for automating

any-to-any data mapping and

aggregation processes

• StyleVision® Server for automating

business report generation in HTML,

PDF, and Word

• RaptorXML® Server for hyper-fast

validation/processing of XML, XBRL,

XSLT, and XQuery

FlowForce Server is at the center of

Altova’s new line of cross-platform

server products optimized for today’s

high-performance, parallel computing

environments:

StyleVision Server

HTML, PDF, Word,

OOXML, RTF

MapForce Server

XML, SQL DBs,

EDI, flat files,

XBRL, Web services

RaptorXML Server XML and XBRL

validation/processing

FlowForce Server

Job triggers

User management

Access control

Untitled-3 1 7/21/14 11:13 AM

Page 36: MSDN September 2014

msdn magazine32 Microsoft Azure

ML Studio, I did a page refresh and the voting data was now visible along with the demo data sets. Note that in the pre-release version of ML Studio I used, it wasn’t possible to delete a Dataset. So, when you’re investigating, I strongly suggest that you create a single data set with a generic name like Dummy Data. Th en, when you need a diff erent data set, use the “Th is is a new version of an existing data-set” option so your ML Studio workspace doesn’t become overrun with orphaned, dummy data sets that can’t be deleted.

Creating the ExperimentTo create the experiment, I clicked on the New icon in the lower-left corner of ML Studio, and then on the Experiment option. Next, in the left -hand pane, I clicked on the Saved Datasets category, and then scrolled to the Voting Data item I just created and dragged it onto the design pane. At the top of the design surface, I entered Voting Experiment as the title. At this point, you could right-click on the bottom output node of the Voting Data module and select the Visualize option to verify your data set is correct.

Many developers, including me, when fi rst working with ML, seriously underestimate how much eff ort is involved in manipulat-ing the source data before applying ML algorithms. Typical tasks include rearranging data columns, deleting unwanted columns, dealing with missing values, encoding non-numeric data, and splitting data into training and test sets. From a developer’s point of view for the voting-data experiment, these tasks might take the form of code like this:

string[][] rawData = LoadData("VotingRawWithHeader.txt");rawData = ProcessMissing(rawData, '?', 'n');rawData = SwapColumns(rawData, 0, 16);double[][] data = Encode(rawData);double[][] trainData;double[][] testData;MakeTrainTest(data, 0.80, out trainData, out testData);

Figure 4 shows a close-up of the fi rst four ML Studio modules that perform these tasks. In many ML scenarios, the most common

approach to deal with missing values is to simply delete all data item rows that contain one or more missing values, and ML Studio gives you that option. However, with voting data, my hypothesis was that a missing vote was really an implied “no” vote. So, for the Missing Values Scrubber module, in the right-hand pane, I spec-ifi ed that all missing values (“?”) should be replaced by “n” values.

Th e Project Columns module allows you to specify any columns you want to omit. In this case, I selected the “Select all columns” option. ML Studio examines your data and makes intelligent guesses as to whether column values are string categorical data or numeric data. Th e Metadata Editor module allows you to override the ML assumptions and also allows you to specify the Label column, that is, the variable to predict. I selected the “political-party” column (here’s where having column headers is a big help) and specifi ed it was the Label column. I left the other 16 columns as Feature (predictor) columns.

The Split module does just that, dividing data into a training set, used to create an ML model, and a test set, used to estimate the accuracy of the model. Here, I specifi ed 0.8 in the module’s parameter pane so the training data would be 80 percent of the 435 items (348 items) and the test set would be the remaining 20 percent (87 items). Th e Split module also has a Boolean parameter named “Stratifi ed split.” When working with ML Studio, you’ll certainly come across parame-ters whose meaning you don’t understand. Th e question-mark icon in the lower-right gives you access to the ML Studio Help.

Training the ModelYou can think of an ML model as a collection of information—typically numeric values called weights—that are used to generate outputs and predictions. Training a model is the process of fi nding a set of weight values so that when presented with input data from the training set (in this case, 16 yes and no votes), computed outputs (either democrat or republican) closely match the known outputs in the training data. Once these weights have been determined, the resulting model can be presented with the test data. Th e accuracy of the model on the test data (the percentage of correct predictions) gives you a rough estimate of how well the model will do when pre-sented with new data, where the true output isn’t known.

For the voting demo, a code-based approach to training might resemble:

int numFeatures = 16;LogisticModel lm = new LogisticModel(numFeatures);int maxEpochs = 10000;lm.Train(trainData, maxEpochs);

Figure 5 shows a close-up of the equivalent ML Studio training- related modules. In the demo, the Train Model module accepts as input the Logistic Regression Binary Classifi cation Model module. Unlike the other connections, this isn’t really a data fl ow; it actually

Figure 5 Training the Model

Figure 6 Scoring and Evaluating the Model

However, with voting data, my hypothesis was that a missing vote

was really an implied “no” vote.

Page 37: MSDN September 2014

FEATURED SPEAKERSLive! 360 brings you over 70 speakers; some of the best and brightest experts in the industry.

RACHEL APPEL JASON BOCK ROBERT BOEDIGHEIMER MIGUEL CASTRO MARCEL DE VRIES

DEBORAH KURATA ROCKFORD LHOKTA BRIAN NOYES JOHN PAPA BRIAN RANDELL

JEFFERY HICKS DON JONES SAMI LAIHO BRUCE MCKENZIE-LOW GREG SHIELDS

BILL AYERS ROBERT BOGUE ANDREW CONNELL MATTHEW MCDERMOTT AGNES MOLNAR

ANDREW BRUST PINAL DAVE SCOTT KLEIN LEONARD LOBEL TED NEWARD

ALLEN CONWAY BRENT EDWARDS KEVIN FORD STEVEN HUGHES NICK LANDRY

IT AND DEVELOPER TRAINING THAT’S OUT OF THIS WORLD.

Live! 360 brings together fi ve conferences, and the brightest minds in IT and Dev, to explore leading edge technologies and conquer current ones. These co-located events will incorporate knowledge transfer and networking, along with out-of-this-world education and training, as you create your own custom conference, mixing and matching sessions and workshops to best suit your needs.

OPEN PAGE TO VIEW ➔

VIEW ALL 180+ SESSIONS INSIDE

NOV17-21

ORLANDOROYAL PACIFIC RESORT AT UNIVERSAL ORLANDO

EVENT PARTERS PLATINUM SPONSOR GOLD SPONSORS PRODUCED BY

The Future of Software Development is Back, Modern Apps Live! will break down the latest techniques in low cost, high value application development. modernappslive.com

CONNECT WITH LIVE! 360 twitter.com/@live360events facebook.com – Search “Live 360”

linkedin.com – Join the “Live 360” group!

USS Collaborate: Let’s Work Together. Climb aboard to work through your most pressing

SharePoint projects.

SQL Server Live! will leave you with the skills needed to Conquer Planet Data, whether you are a

DBA, developer, IT Pro, or Analyst.

Master the Modern Apps Landscape and learn how to architect, design and build a complete

Modern Application from start to fi nish.

Join us for an IT Training Odyssey, focused entirely on making your datacenter more

modern, more capable, and more manageable.

Calling all .NET Developers: The Code is Strong with This One; Experience unbiased and

practical training on the Microsoft Platform.

REGISTER BY SEPTEMBER 17 AND SAVE $400!

Scan the QR code to register or for more event details.

Use promo code L360SEPTI

Five events, 29 tracks, and literally hundreds of sessions to choose from – mix and match sessions to create your own, custom event line-up – it’s like no other conference available today.

SUPPORTED BY

magazine

Use promo code L360SEPTI

REGISTER BY SEPTEMBER 17 AND SAVE $400!

CONNECT WITH LIVE! 360 twitter.com/@live360events facebook.com – Search “Live 360”

linkedin.com – Join the “Live 360” group!

VIEW THE FULL LIST OF SPEAKERS AT LIVE360EVENTS.COM

SPECIAL PULL-OUT SECTIONlive360events.com

Page 38: MSDN September 2014

START TIME END TIME Visual Studio Live! Pre-Conference: Sunday, November 16, 2014 SharePoint Live! Pre-Conference: Sunday, November 16, 2014 SQL Server Live! Pre-Conference: Sunday, November 16, 2014 TechMentor Pre-Conference: Sunday, November 16, 2014 Modern Apps Live! Pre-Conf.: Sun., Nov. 164:00 PM 9:00 PM Pre-Conference Registration - Royal Pacific Resort Conference Center6:00 PM 9:00 PM Dine-A-Round Dinner @ Universal CityWalk

START TIME END TIME Visual Studio Live! Pre-Conference Workshops: Monday, November 17, 2014 SharePoint Live! Pre-Conference Workshops: Monday, November 17, 2014 SQL Server Live! Pre-Conference Workshops: Monday, November 17, 2014 TechMentor Pre-Conference Workshops: Monday, November 17, 2014 MAL! Pre-Conf. Workshop: Mon., Nov. 17

8:00 AM 5:00 PM VSM01 - Workshop: Native Mobile App Development for iOS, Android, and Windows using C# - Marcel de Vries & Rockford Lhotka

VSM02 - Workshop: AngularJS in0 to 60 - John Papa

VSM03 - Workshop: FromCode to Release: DevOps forDevelopers - Brian Randell

SPM01 - Workshop: Modern Office 365, SharePoint & Cloud Development Ramp-Up - Andrew Connell

SPM02 - Workshop: Getting Up andRunning with Office 365 - Dan Usher

SQM01 - Workshop: Big Data and NoSQL forDatabase and BI Pros - Andrew Brust

SQM02 - Workshop: Maintaining SQL Serverfor Non-DBAs - Don Jones

TMM01 - Workshop: Microsoft Office 365:The Bootcamp - Andy Malone

TMM02 - Workshop: Automating Hyper-V with System Center Technologies - Greg Shields

MAM01 - Workshop: Modern App TechnologyOverview - Android, iOS, Cloud, and Mobile Web

- Nick Landry, Kevin Ford, & Steve Hughes5:00 PM 6:00 PM EXPO Preview6:00 PM 7:00 PM Live! 360 Keynote:

START TIME END TIME Visual Studio Live! Day 1: Tuesday, November 18, 2014 SharePoint Live! Day 1: Tuesday, November 18, 2014 SQL Server Live! Day 1: Tuesday, November 18, 2014 TechMentor Day 1: Tuesday, November 18, 2014 Modern Apps Live! Day 1: Tues., Nov. 18

8:00 AM 9:00 AM Visual Studio Live! Keynote: To Be Announced SharePoint Live! Keynote: Creating Interactive Experiences for Internal and External Users in Office 365 - Sonya Koptyev, Senior Product Manager, SharePoint and Office, Microsoft SQL Server Live! Keynote: To Be Announced TechMentor Keynote: To Be Announced Modern Apps Live! Keynote: To Be Announced

9:00 AM 9:30 AM Networking Break • Visit the EXPO

9:30 AM 10:45 AM VST01 - Getting Started with Xamarin - Walt Ritscher

VST02 - Great User Experiences with CSS 3 - Robert Boedigheimer

VST03 - What’s New in MVC 5 - Miguel Castro

VST04 - New IDE and Editor Features in Visual Studio 2013

- Deborah KurataSPT01 - Lean-Agile Development

with SharePoint - Bill AyresSPT02 - What’s New for IT PRO’s in SharePoint 2013 - Brian Alderman

SPT03 - Getting Started with Cross Site Publishing in SharePoint 2013

- Prashant Bhoyar

SQT01 - Best Practices for Leveraging SQL Server in Windows Azure Virtual

Machines - Scott KleinSQT02 - SQL Server Integration Services End-to-End - David Dye

SQT03 - Introduction to SQL Server Clustering - Chad Churchwell

TMT01 - Desired State Configura-tion: An Administrator’s Overview

- Don Jones

TMT02 - Automating vSphere with VMware Orchestrator, Part 1

- Greg Shields

TMT03 - Creating an Everywhere LAN Without the Hassle Using DirectAccess - John O’Neill, Sr.

MAT01 - Defining Modern App Development - Rockford Lhotka

11:00 AM 12:15 PMVST05 - Building Your First Universal Application for Windows Phone and

Windows Store - Brian Peek

VST06 - HTML5 and Modernizr for Better Web Sites

- Robert BoedigheimerVST07 - What’s New in Web API 2

- Miguel CastroVST08 - Visual Studio Data Tools for Developers - Deborah Kurata

SPT04 - How to Improve the SharePoint UI Using Bootstrap 3

- Ryan McIntyreSPT05 - Microsoft To Be

Announced SPT06 - To Be Announced SQT04 - SQL Server 2014 In-memory OLTP Deep Dive - Scott Klein

SQT05 - Designing and Maintaining a SQL Server Replication Topology

- Chad Churchwell

SQT06 - Hadoop Administration for SQL Server DBAs - Edwin Sarmiento

TMT04 - PowerShell Scripting and Toolmaking with Patterns and

Practical Uses - Don Jones

TMT05 - Automating vSphere with VMware Orchestrator, Part 2 -

Greg ShieldsTMT06 - To Be Announced MAT02 - Modern App Architecture

- Rockford Lhotka

12:15 PM 2:00 PM Lunch • Visit the EXPO

2:00 PM 3:15 PMVST09 - Introduction to Developing Mobile Apps for the Web Developer

- Ben Hoelting

VST10 - Build an Angular and Bootstrap Web Application in

Visual Studio from the Ground Up - Deborah Kurata

VST11 - ASP.NET MVC for Mobile Devices - Rob Daigneau

VST12 - The Road to Continuous Delivery, Automated UI Testing for

Web, WPF and Windows Forms - Marcel de Vries

SPT07 - Building SharePoint Single Page Apps with AngularJS -

Andrew Connell

SPT08 - Getting Started withOffice 365 - Identity, Provisioning

and Basics of Tenant Administration - Dan Usher

SPT09 - Learn About the Top 5Advanced Search Features You Never

Knew You Needed - Paul Olenick

SQT07 - Big Data 101 with Azure HDInsight - Andrew Brust

SQT08 - Implementing Auditing in SQL Server - David Dye

SQT09 - Building Perfect SQLServers, Every Time - Joey D’Antoni

TMT07 - GO DARK: The PowerShell Delegated AdministrationResource Kit - Don Jones

TMT08 - Using Microsoft Azurefor Easy, Secure, Off-Site Backup

- John O’Neill, Sr.

TMT09 - System Center and the Modern Datacenter: A Tactical

Briefing - Greg Shields

MAT03 - ALM with Visual Studio Online (TFS)and Git - Brian Randell

3:15 PM 4:15 PM Networking Break • Visit the EXPO

4:15 PM 5:30 PMVST13 - Creating Responsive

Cross-Platform Native/Web Apps with JavaScript and Bootstrap -

Ben Dewey

VST14 - Hate JavaScript? TryTypeScript - Ben Hoelting

VST15 - What’s New in WPF 4.5 - Walt Ritscher

VST16 - Understanding Dependency Injection & Writing Testable Software - Miguel Castro

SPT10 - SharePoint 2013 Display Templates and Query Rules

- Matt McDermott

SPT11 - Office 365 Information Architecture and Governance 101

- Ben Curry

SPT12 - Getting Started withSharePoint 2013 Workflows

- Prashant Bhoyar

SQT10 - Integrating SQL Server Analysis Services with Hadoop

- Edwin Sarmiento

SQT11 - Dealing with Errors in SQL Server Integration Services

- David Dye

SQT12 - SQL Server HighAvailability and Disaster Recovery

- Chad Churchwell

TMT10 - Top 20 Mistakes inMicrosoft Public Key Infrastructure

(PKI) Deployments - Mark B. Cooper

TMT11 - Integrating Office 365 with Active Directory, Step-by-Step

- John O’Neill, Sr.

TMT12 - Career Strategies for IT Professionals: A Roundtable

Discussion and Q&A - Don Jones & Greg Shields

MAT04 - Reusing Business and Data Access Logic Across Platforms - Kevin Ford

5:30 PM 7:30 PM Exhibitor Reception

START TIME END TIME Visual Studio Live! Day 2: Wednesday, November 19, 2014 SharePoint Live! Day 2: Wednesday, November 19, 2014 SQL Server Live! Day 2: Wednesday, November 19, 2014 TechMentor Day 2: Wednesday, November 19, 2014 Modern Apps Live! Day 2: Wed., Nov. 198:00 AM 9:00 AM Live! 360 Keynote: To Be Announced

9:15 AM 10:30 AMVSW01 - Build Cross-Platform Apps

with Shared Projects, CSLA .NET, and C# - Rockford Lhotka

VSW02 - AngularJS Jump-Start - John Papa

VSW03 - Best Practices for Self Hosting Web API Based Services

- Rob Daigneau

VSW04 - The Busy Developers Guide to Virtualization with

Hyper-V - Brian Randell

SPW01 - Office Graph and Oslo - The Future of Discovering and

Consuming Information? - Agnes Molnar

SPW02 - SharePoint Tips and Tricks - Avoiding Administrative

Blunders - Dan Usher

SPW03 - Real World: Hybrid Office 365 Solution

- Ben Curry

SQW01 - Who Moved My Tuple? Columnstore Indexes in SQL Server

2014 - Joey D’Antoni

SQW02 - Integrating Reporting Services with SharePoint -

Kevin Goff

SQW03 - Everything You Never Wanted to Know about SQL Server

Indexes - Don Jones

TMW01 - Managing and Deploying BYOD Identity Solutions with a Microsoft PKI - Mark B. Cooper

TMW02 - Managing Infrastructure Migrations at Windows Server’s

End-of-Life - Rick Claus

TMW03 - Automating Application Installations: An Introduction to

Software Packaging & Repackaging - John O’Neill, Sr.

MAW01 - Coding for Quality and Maintainability - Jason Bock

10:30 AM 11:00 AM Networking Break • Visit the EXPO

11:00 AM 12:15 PM VSW05 - Building Cordova Apps in Visual Studio 2013 - Nick Landry

VSW06 - AngularJS Anywherewith Node.js - John Papa

VSW07 - Slice Development Time With ASP.NET MVC, Visual Studio,

and Razor - Philip Japikse

VSW08 - Build It and Ship It with TFS and Release Management

- Brian RandellSPW04 - To Be Announced SPW05 - SharePoint Intranet

Design - Michael DoyleSPW06 - Roadmap for a Successful

Migration to SharePoint Online - Paul Olenick

SQW04 - Getting Started withMDX - William E. Pearson III SQW05 - To Be Announced

SQW06 - Virtualizing SQL Server in VMware, Hyper-V, or Xen:

Yes or No? - Don Jones

TMW04 - Securing Cloud Servers and Services with PKI Certificates

- Mark B. Cooper

TMW05 - Everything You’ve Needed to Know about Windows Scale

Out File Server - Rick ClausTMW06- Skype Internals from a

Security Perspective - Andy MaloneMAW02 - UX Design for Modern Apps

- Anthony Handley

12:15 PM 1:45 PM Birds-of-a-Feather Lunch • Visit the EXPO

1:45 PM 3:00 PM VSW09 - What’s New in Azure for Developers - Vishwas Lele

VSW10 - I Just Met You, and “This” is Crazy, But Here’s My NaN, So Call(me) Maybe? - Rachel Appel

VSW11 - Automated Cross Browser Testing of Your Web Applications

with Visual Studio CodedUI -Marcel de Vries

VSW12 - Readable Code - John Papa

SPW07 - Deploying Provider-Hosted Apps Into Production

- Paul Schaeflein

SPW08 - Optimizing SQL Server 2014 for SharePoint 2013

- Brian Alderman

SPW09 - Office 365: Considerations for a Hybrid Deployment - Geoff Varosky

SQW07 - Getting Started with Analysis Services 2014 Tabular

- William E. Pearson III

SQW08 - Programming the T-SQL Enhancements in SQL Server 2012

- Leonard Lobel

SQW09 - Prevent RecoveryAmnesia - Forget the Backups

- Chris Bell

TMW07 - CIM-ple RemoteManagement with PowerShell

- Jeffery Hicks

TMW08 - Troubleshooting the Windows Client, an Introductory

Clinic - Jeff Stokes

TMW09 - The Dark Side ofSocial Networking and How to

Survive It - Andy Malone

MAW03 - Applied UX: iOS, Android, Windows - Anthony Handley

3:00 PM 4:00 PM Networking Break • Visit the EXPO • Expo Raffle @ 3:30 p.m.

4:00 PM 5:15 PM VSW13 - API Management - Vishwas Lele

VSW14 - Creating HTML5 and Angular Websites Using Visual Studio

LightSwitch - Michael Washington

VSW15 - Build Real-Time Websites and Apps with SignalR

- Rachel Appel

VSW16 - Visual Studio Online:An Update Every Three Weeks

- Brian RandellSPW10 - Test-driven Development with SharePoint 2013 - Bill Ayres

SPW11 - Bringing the Users With You - SharePoint 2013 Adoption and Engagement - Robert Bogue

SPW12 - SharePoint and the Mystical OneDrive for Business

- Dan Usher

SQW10 - Implementing Data Warehouse Patterns with the

Microsoft BI Tools - Kevin Goff

SQW11 - Accelerate Database Performance through Data

Compression - Joey D’Antoni

SQW12 - Building a DatabaseDeployment Pipeline

- Grant FritcheyTMW10 - Creating Graphical

PowerShell Tools - Jeffery HicksTMW11 - Building a Better VDI

Image: Best Practices fromMicrosoft - Jeff Stokes

TMW12 - The Hacker’s Guideto Identity Theft and How to

Survive It - Andy MaloneMAW04 - Leveraging Azure Services

- Kevin Ford

8:00 PM 10:00 PM Live! 360 Evening Event

START TIME END TIME Visual Studio Live! Day 3: Thursday, November 20, 2014 SharePoint Live! Day 3: Thursday, November 20, 2014 SQL Server Live! Day 3: Thursday, November 20, 2014 TechMentor Day 3: Thursday, November 20, 2014 Modern Apps Live! Day 3: Thurs., Nov. 20

8:00 AM 9:15 AMVSH01 - Creating Visual Studio Cloud Business Applications for

Office 365 / SharePoint 2013 - Michael Washington

VSH02 - To Be AnnouncedVSH03 - Games Development with

Unity and Other Frameworks for Windows and Windows Phone

- Brian Peek

VSH04 - Managing the .NET Compiler - Jason Bock

SPH01- How to Develop and Debug Client-Side Code

- Mark Rackley

SPH02 - Managing SharePoint 2013 with System Center

Operations Manager (SCOM) 2012 R2 - Jason Kaczor

SPH03 - Getting a Grip onSharePoint Social - Michael Doyle

SQH01 - SQL Server Reporting Services on Power BI

- Kevin Goff

SQH02 - Getting Started Reading Query Execution Plans

- Grant Fritchey

SQH03 - Database Design:Size DOES Matter - Thomas LaRock

TMH01 - Managing Hyper-Vwith Windows PowerShell

- Jeffery Hicks

TMH02 - Building a Secure and Cost-Effective BitLocker

- Sami Laiho

TMH03 - Improve Your TechWriting Skills: Lessons from a

Professional Author - Don Jones

MAH01 - Analyzing Results with Power BI - Steve Hughes

9:30 AM 10:45 AMVSH05 - Microsoft Azure Web Sites for the Web Developer

- Eric D. Boyd

VSH06 - Building Rich Data Input Windows 8 Applications -

Brian Noyes

VSH07 - Build Your First Mobile App in 1 Hour with Microsoft App Studio

- Nick Landry

VSH08 - Writing Asynchronous Code Using .NET 4.5 and C# 5.0

- Brian PeekSPH04 - Deep Dive into Office 365

APIs - Jeremy ThakeSPH05 - No Governance As Usual

- Robert BogueSPH06 - Is “Enterprise Search”

Dead??? - Agnes MolnarSQH04 - Excel, Power BI and You:

An Analytics Superhub - Andrew Brust

SQH05 - Secrets of SQL Server: Database WORST Practices -

Pinal Dave

SQH06 - Securing Your Database by Using Transparent Data

Encryption (TDE) - Bradley Ball

TMH04 - Document Everything with Windows PowerShell

- Jeffery Hicks

TMH05 - The Real-World Guide to Upgrading your IT Skills AND Your Infrastructure, Part 1 - Rick Claus

TMH06 - Proactive Security inWindows Environments

- Sami LaihoMAH02 - Building a Native iOS App

- Lou Miranda

11:00 AM 12:15 PM VSH09 - Moving Web Apps to the Cloud - Eric D. Boyd

VSH10 - XAML Antipatterns - Ben Dewey VSH11 - To Be Announced VSH12 - Asynchronous Debugging

in .NET - Jason Bock

SPH07 - Lazy Client-side Dev: Let the 3rd-party Libraries Do the Heavy Lifting - Mark Rackley

SPH08 - Automating your Enter-prise Application Deployments with PowerShell - Geoff Varosky

SPH09 - Implementing ECM Solutions with SharePoint 2013

- Rob Bogue

SQH07 - Self-ServiceBI Governance

- Jen Underwood

SQH08 - Statistics and theQuery Optimizer - Grant Fritchey

SQH09 - To Be Announced

TMH07 - Discussing the Future of Desktop Administration:

Are Configuration Manager’s Days Numbered?

- Don Jones and Greg Shields

TMH08 - The Real-World Guide to Upgrading your IT Skills AND Your Infrastructure, Part 2 - Rick Claus

TMH09 - How to Build a Perfect File Server with Windows Server

- Sami Laiho

MAH03 - Building an Android App with Xamarin - Nick Landry

12:15 PM 1:30 PM Lunch on the Lanai

1:30 PM 2:45 PM VSH13 - Node.js for .NET Developers - Jason Bock

VSH14 - Building Maintainable and Extensible MVVM WPF Apps

with Prism 5 - Brian Noyes

VSH15 - Learning EntityFramework 6 - Leonard Lobel

VSH16 - Rock Your Code Using Code Contracts - David McCarter

SPH10 - BreezeJS Makes Cli-ent-Side SharePoint 2013 REST

Development a… BREEZE! - Andrew Connell

SPH11 - 10 Misconceptions of Information Architecture You Should Forget - Agnes Molnar

SPH12 - Developers Approach to Search Applications

- Matt McDermott

SQH10 - Busy Developer’s Guideto R - Ted Neward

SQH11 - Inside the SQL Server Query Optimizer - Bradley Ball

SQH12 - Monitoring Databasesin a Virtual Environment

- Thomas LaRock

TMH10 - Eliminate the Regulatory Compliance Nightmare

- J. Peter BruzzeseTMH11 - To Be Announced

TMH12 - Oh Snap! Active Directory Attribute-level Recovery when

the AD Recycle Bin Cannot Help - Ashley McGlone

MAH04 - Building a Windows App - Brent Edwards

3:00 PM 4:15 PMVSH17 - Building Mobile

Cross-Platform Apps in C# with Azure Mobile Services - Nick Landry

VSH18 - XAML for the WinForms Developer - Philip Japikse

VSH19 - Database Development with SQL Server Data Tools

- Leonard Lobel

VSH20 - Rock Your Code With Visual Studio Add-ins

- David McCarter

SPH13 - SharePoint DesignManager – Step by Step

-Paul Schaeflein

SPH14 - SharePoint Forensics forIT Professionals - Jason Kaczor

SPH15 - Introducing Office Web Apps as a Tool for Developing

Content Rich Applications - Ryan McIntyre

SQH13 - Advanced Analytics and Data Mining for Power BI

- Jen UnderwoodSQH14 - Cardinality Estimates in

SQL Server 2014 - Thomas LaRockSQH15 - Busy Developer’s Guide

to NoSQL - Ted Neward

TMH13 - Exchange 2013 and SharePoint 2013: Better Together

- J. Peter Bruzzese

TMH14 - Migrating Your Windows Failover Clusters - Is Now the

Right Time to Upgrade? - Bruce Mackenzie-Low

TMH15 - Migrate GPOs from One Domain / Forest to another Using

PowerShell - Ashley McGlone

MAH05 - Building a Responsive Single Page App - Allen Conway

4:30 PM 5:45 PM Live! 360 Conference Wrap-up Andrew Connell, Matt McDermott, Don Jones, Greg Shields, Andrew Brust, Rockford Lhotka

START TIME END TIME Visual Studio Live! Post-Conference Workshops: Friday, November 21, 2014 SharePoint Live! Post-Conference Workshops: Friday, November 21, 2014 SQL Server Live! Post-Conference Workshops: Friday, November 21, 2014 TechMentor Post-Conference Workshops: Friday, November 21, 2014 MAL! Post-Conf. Workshop: Fri., Nov. 21, 2014

8:00 AM 5:00 PM VSF01 - Workshop: Service Orientation Technologies: Designing,Developing, & Implementing WCF and the Web API - Miguel Castro

VSF02 - Workshop: Build a Windows 8.1 Application in a Day - Philip Japikse

SPF01 - Workshop: Apps for SharePoint -The Next Level - Paul Schaeflein

SPF02 - Workshop: Implementing Search Based Intranet in SharePoint 2013 and Office 365

- Agnes Molnar

SQF01 - Workshop: Performance Tuning Best Practices - Every DBA and Developer MUST Know

- Pinal DaveSQF02 - Workshop: SQL Server 2014 for Developers

- Leonard LobelTMF01 - Workshop: Microsoft Exchange Boot Camp

for the Accidental Exchange Administrator - J. Peter Bruzzese

TMF02 - Workshop: Windows TroubleshootingDEEP DIVE - Bruce Mackenzie-Low

MAF01 - Workshop: Modern App Development In-Depth: iOS, Android, Windows, and Web - Brent Edwards,Anthony Handley, Lou Miranda, & Allen Conway

Speakers and sessions subject to change

VISUAL STUDIO LIVE! TRACKS SHAREPOINT LIVE! TRACKS SQL SERVER LIVE! TRACKS TECHMENTOR TRACKS MODERN APPS LIVE! TRACK

ASP.NET CloudComputing

Cross-PlatformMobile

Development

DataManagement

JavaScript /HTML5 Client

Visual Studio/ .NET Framework

WindowsClient

WindowsPhone

Developing Apps and Solutions for

SharePoint

High-Value Share-Point Workloads: Social, Search, BI,

and Business Process Automation

Information and Content

Management: Documents,

Records, and Web

Keys to SharePoint Success: Strategy,

Governance, Adoption

SharePoint Infrastructure

Management andAdministration

SharePoint, Office 365 and the Cloud

BI, Big Data, Data Analytics,

and Data Visualization

SQL Server Administration &

Maintenance

SQL Server Features &

Components

SQL Server for the Developer / SQL Server 2014

SQL Server in the Cloud

SQL ServerPerformance Tuning and

Optimization

SQL Server Tools, Tricks,

and Techniques

Advanced Windows

Networking

Hybrid Cloudand

Virtualizatin

Jack ofAll Trades

Security and Ethical Hacking

System Center & Microsoft Exchange

Windows PowerShell

WindowsServer

Presented inPartnership with:

Page 39: MSDN September 2014

START TIME END TIME Visual Studio Live! Pre-Conference: Sunday, November 16, 2014 SharePoint Live! Pre-Conference: Sunday, November 16, 2014 SQL Server Live! Pre-Conference: Sunday, November 16, 2014 TechMentor Pre-Conference: Sunday, November 16, 2014 Modern Apps Live! Pre-Conf.: Sun., Nov. 164:00 PM 9:00 PM Pre-Conference Registration - Royal Pacific Resort Conference Center6:00 PM 9:00 PM Dine-A-Round Dinner @ Universal CityWalk

START TIME END TIME Visual Studio Live! Pre-Conference Workshops: Monday, November 17, 2014 SharePoint Live! Pre-Conference Workshops: Monday, November 17, 2014 SQL Server Live! Pre-Conference Workshops: Monday, November 17, 2014 TechMentor Pre-Conference Workshops: Monday, November 17, 2014 MAL! Pre-Conf. Workshop: Mon., Nov. 17

8:00 AM 5:00 PM VSM01 - Workshop: Native Mobile App Development for iOS, Android, and Windows using C# - Marcel de Vries & Rockford Lhotka

VSM02 - Workshop: AngularJS in0 to 60 - John Papa

VSM03 - Workshop: FromCode to Release: DevOps forDevelopers - Brian Randell

SPM01 - Workshop: Modern Office 365, SharePoint & Cloud Development Ramp-Up - Andrew Connell

SPM02 - Workshop: Getting Up andRunning with Office 365 - Dan Usher

SQM01 - Workshop: Big Data and NoSQL forDatabase and BI Pros - Andrew Brust

SQM02 - Workshop: Maintaining SQL Serverfor Non-DBAs - Don Jones

TMM01 - Workshop: Microsoft Office 365:The Bootcamp - Andy Malone

TMM02 - Workshop: Automating Hyper-V with System Center Technologies - Greg Shields

MAM01 - Workshop: Modern App TechnologyOverview - Android, iOS, Cloud, and Mobile Web

- Nick Landry, Kevin Ford, & Steve Hughes5:00 PM 6:00 PM EXPO Preview6:00 PM 7:00 PM Live! 360 Keynote:

START TIME END TIME Visual Studio Live! Day 1: Tuesday, November 18, 2014 SharePoint Live! Day 1: Tuesday, November 18, 2014 SQL Server Live! Day 1: Tuesday, November 18, 2014 TechMentor Day 1: Tuesday, November 18, 2014 Modern Apps Live! Day 1: Tues., Nov. 18

8:00 AM 9:00 AM Visual Studio Live! Keynote: To Be Announced SharePoint Live! Keynote: Creating Interactive Experiences for Internal and External Users in Office 365 - Sonya Koptyev, Senior Product Manager, SharePoint and Office, Microsoft SQL Server Live! Keynote: To Be Announced TechMentor Keynote: To Be Announced Modern Apps Live! Keynote: To Be Announced

9:00 AM 9:30 AM Networking Break • Visit the EXPO

9:30 AM 10:45 AM VST01 - Getting Started with Xamarin - Walt Ritscher

VST02 - Great User Experiences with CSS 3 - Robert Boedigheimer

VST03 - What’s New in MVC 5 - Miguel Castro

VST04 - New IDE and Editor Features in Visual Studio 2013

- Deborah KurataSPT01 - Lean-Agile Development

with SharePoint - Bill AyresSPT02 - What’s New for IT PRO’s in SharePoint 2013 - Brian Alderman

SPT03 - Getting Started with Cross Site Publishing in SharePoint 2013

- Prashant Bhoyar

SQT01 - Best Practices for Leveraging SQL Server in Windows Azure Virtual

Machines - Scott KleinSQT02 - SQL Server Integration Services End-to-End - David Dye

SQT03 - Introduction to SQL Server Clustering - Chad Churchwell

TMT01 - Desired State Configura-tion: An Administrator’s Overview

- Don Jones

TMT02 - Automating vSphere with VMware Orchestrator, Part 1

- Greg Shields

TMT03 - Creating an Everywhere LAN Without the Hassle Using DirectAccess - John O’Neill, Sr.

MAT01 - Defining Modern App Development - Rockford Lhotka

11:00 AM 12:15 PMVST05 - Building Your First Universal Application for Windows Phone and

Windows Store - Brian Peek

VST06 - HTML5 and Modernizr for Better Web Sites

- Robert BoedigheimerVST07 - What’s New in Web API 2

- Miguel CastroVST08 - Visual Studio Data Tools for Developers - Deborah Kurata

SPT04 - How to Improve the SharePoint UI Using Bootstrap 3

- Ryan McIntyreSPT05 - Microsoft To Be

Announced SPT06 - To Be Announced SQT04 - SQL Server 2014 In-memory OLTP Deep Dive - Scott Klein

SQT05 - Designing and Maintaining a SQL Server Replication Topology

- Chad Churchwell

SQT06 - Hadoop Administration for SQL Server DBAs - Edwin Sarmiento

TMT04 - PowerShell Scripting and Toolmaking with Patterns and

Practical Uses - Don Jones

TMT05 - Automating vSphere with VMware Orchestrator, Part 2 -

Greg ShieldsTMT06 - To Be Announced MAT02 - Modern App Architecture

- Rockford Lhotka

12:15 PM 2:00 PM Lunch • Visit the EXPO

2:00 PM 3:15 PMVST09 - Introduction to Developing Mobile Apps for the Web Developer

- Ben Hoelting

VST10 - Build an Angular and Bootstrap Web Application in

Visual Studio from the Ground Up - Deborah Kurata

VST11 - ASP.NET MVC for Mobile Devices - Rob Daigneau

VST12 - The Road to Continuous Delivery, Automated UI Testing for

Web, WPF and Windows Forms - Marcel de Vries

SPT07 - Building SharePoint Single Page Apps with AngularJS -

Andrew Connell

SPT08 - Getting Started withOffice 365 - Identity, Provisioning

and Basics of Tenant Administration - Dan Usher

SPT09 - Learn About the Top 5Advanced Search Features You Never

Knew You Needed - Paul Olenick

SQT07 - Big Data 101 with Azure HDInsight - Andrew Brust

SQT08 - Implementing Auditing in SQL Server - David Dye

SQT09 - Building Perfect SQLServers, Every Time - Joey D’Antoni

TMT07 - GO DARK: The PowerShell Delegated AdministrationResource Kit - Don Jones

TMT08 - Using Microsoft Azurefor Easy, Secure, Off-Site Backup

- John O’Neill, Sr.

TMT09 - System Center and the Modern Datacenter: A Tactical

Briefing - Greg Shields

MAT03 - ALM with Visual Studio Online (TFS)and Git - Brian Randell

3:15 PM 4:15 PM Networking Break • Visit the EXPO

4:15 PM 5:30 PMVST13 - Creating Responsive

Cross-Platform Native/Web Apps with JavaScript and Bootstrap -

Ben Dewey

VST14 - Hate JavaScript? TryTypeScript - Ben Hoelting

VST15 - What’s New in WPF 4.5 - Walt Ritscher

VST16 - Understanding Dependency Injection & Writing Testable Software - Miguel Castro

SPT10 - SharePoint 2013 Display Templates and Query Rules

- Matt McDermott

SPT11 - Office 365 Information Architecture and Governance 101

- Ben Curry

SPT12 - Getting Started withSharePoint 2013 Workflows

- Prashant Bhoyar

SQT10 - Integrating SQL Server Analysis Services with Hadoop

- Edwin Sarmiento

SQT11 - Dealing with Errors in SQL Server Integration Services

- David Dye

SQT12 - SQL Server HighAvailability and Disaster Recovery

- Chad Churchwell

TMT10 - Top 20 Mistakes inMicrosoft Public Key Infrastructure

(PKI) Deployments - Mark B. Cooper

TMT11 - Integrating Office 365 with Active Directory, Step-by-Step

- John O’Neill, Sr.

TMT12 - Career Strategies for IT Professionals: A Roundtable

Discussion and Q&A - Don Jones & Greg Shields

MAT04 - Reusing Business and Data Access Logic Across Platforms - Kevin Ford

5:30 PM 7:30 PM Exhibitor Reception

START TIME END TIME Visual Studio Live! Day 2: Wednesday, November 19, 2014 SharePoint Live! Day 2: Wednesday, November 19, 2014 SQL Server Live! Day 2: Wednesday, November 19, 2014 TechMentor Day 2: Wednesday, November 19, 2014 Modern Apps Live! Day 2: Wed., Nov. 198:00 AM 9:00 AM Live! 360 Keynote: To Be Announced

9:15 AM 10:30 AMVSW01 - Build Cross-Platform Apps

with Shared Projects, CSLA .NET, and C# - Rockford Lhotka

VSW02 - AngularJS Jump-Start - John Papa

VSW03 - Best Practices for Self Hosting Web API Based Services

- Rob Daigneau

VSW04 - The Busy Developers Guide to Virtualization with

Hyper-V - Brian Randell

SPW01 - Office Graph and Oslo - The Future of Discovering and

Consuming Information? - Agnes Molnar

SPW02 - SharePoint Tips and Tricks - Avoiding Administrative

Blunders - Dan Usher

SPW03 - Real World: Hybrid Office 365 Solution

- Ben Curry

SQW01 - Who Moved My Tuple? Columnstore Indexes in SQL Server

2014 - Joey D’Antoni

SQW02 - Integrating Reporting Services with SharePoint -

Kevin Goff

SQW03 - Everything You Never Wanted to Know about SQL Server

Indexes - Don Jones

TMW01 - Managing and Deploying BYOD Identity Solutions with a Microsoft PKI - Mark B. Cooper

TMW02 - Managing Infrastructure Migrations at Windows Server’s

End-of-Life - Rick Claus

TMW03 - Automating Application Installations: An Introduction to

Software Packaging & Repackaging - John O’Neill, Sr.

MAW01 - Coding for Quality and Maintainability - Jason Bock

10:30 AM 11:00 AM Networking Break • Visit the EXPO

11:00 AM 12:15 PM VSW05 - Building Cordova Apps in Visual Studio 2013 - Nick Landry

VSW06 - AngularJS Anywherewith Node.js - John Papa

VSW07 - Slice Development Time With ASP.NET MVC, Visual Studio,

and Razor - Philip Japikse

VSW08 - Build It and Ship It with TFS and Release Management

- Brian RandellSPW04 - To Be Announced SPW05 - SharePoint Intranet

Design - Michael DoyleSPW06 - Roadmap for a Successful

Migration to SharePoint Online - Paul Olenick

SQW04 - Getting Started withMDX - William E. Pearson III SQW05 - To Be Announced

SQW06 - Virtualizing SQL Server in VMware, Hyper-V, or Xen:

Yes or No? - Don Jones

TMW04 - Securing Cloud Servers and Services with PKI Certificates

- Mark B. Cooper

TMW05 - Everything You’ve Needed to Know about Windows Scale

Out File Server - Rick ClausTMW06- Skype Internals from a

Security Perspective - Andy MaloneMAW02 - UX Design for Modern Apps

- Anthony Handley

12:15 PM 1:45 PM Birds-of-a-Feather Lunch • Visit the EXPO

1:45 PM 3:00 PM VSW09 - What’s New in Azure for Developers - Vishwas Lele

VSW10 - I Just Met You, and “This” is Crazy, But Here’s My NaN, So Call(me) Maybe? - Rachel Appel

VSW11 - Automated Cross Browser Testing of Your Web Applications

with Visual Studio CodedUI -Marcel de Vries

VSW12 - Readable Code - John Papa

SPW07 - Deploying Provider-Hosted Apps Into Production

- Paul Schaeflein

SPW08 - Optimizing SQL Server 2014 for SharePoint 2013

- Brian Alderman

SPW09 - Office 365: Considerations for a Hybrid Deployment - Geoff Varosky

SQW07 - Getting Started with Analysis Services 2014 Tabular

- William E. Pearson III

SQW08 - Programming the T-SQL Enhancements in SQL Server 2012

- Leonard Lobel

SQW09 - Prevent RecoveryAmnesia - Forget the Backups

- Chris Bell

TMW07 - CIM-ple RemoteManagement with PowerShell

- Jeffery Hicks

TMW08 - Troubleshooting the Windows Client, an Introductory

Clinic - Jeff Stokes

TMW09 - The Dark Side ofSocial Networking and How to

Survive It - Andy Malone

MAW03 - Applied UX: iOS, Android, Windows - Anthony Handley

3:00 PM 4:00 PM Networking Break • Visit the EXPO • Expo Raffle @ 3:30 p.m.

4:00 PM 5:15 PM VSW13 - API Management - Vishwas Lele

VSW14 - Creating HTML5 and Angular Websites Using Visual Studio

LightSwitch - Michael Washington

VSW15 - Build Real-Time Websites and Apps with SignalR

- Rachel Appel

VSW16 - Visual Studio Online:An Update Every Three Weeks

- Brian RandellSPW10 - Test-driven Development with SharePoint 2013 - Bill Ayres

SPW11 - Bringing the Users With You - SharePoint 2013 Adoption and Engagement - Robert Bogue

SPW12 - SharePoint and the Mystical OneDrive for Business

- Dan Usher

SQW10 - Implementing Data Warehouse Patterns with the

Microsoft BI Tools - Kevin Goff

SQW11 - Accelerate Database Performance through Data

Compression - Joey D’Antoni

SQW12 - Building a DatabaseDeployment Pipeline

- Grant FritcheyTMW10 - Creating Graphical

PowerShell Tools - Jeffery HicksTMW11 - Building a Better VDI

Image: Best Practices fromMicrosoft - Jeff Stokes

TMW12 - The Hacker’s Guideto Identity Theft and How to

Survive It - Andy MaloneMAW04 - Leveraging Azure Services

- Kevin Ford

8:00 PM 10:00 PM Live! 360 Evening Event

START TIME END TIME Visual Studio Live! Day 3: Thursday, November 20, 2014 SharePoint Live! Day 3: Thursday, November 20, 2014 SQL Server Live! Day 3: Thursday, November 20, 2014 TechMentor Day 3: Thursday, November 20, 2014 Modern Apps Live! Day 3: Thurs., Nov. 20

8:00 AM 9:15 AMVSH01 - Creating Visual Studio Cloud Business Applications for

Office 365 / SharePoint 2013 - Michael Washington

VSH02 - To Be AnnouncedVSH03 - Games Development with

Unity and Other Frameworks for Windows and Windows Phone

- Brian Peek

VSH04 - Managing the .NET Compiler - Jason Bock

SPH01- How to Develop and Debug Client-Side Code

- Mark Rackley

SPH02 - Managing SharePoint 2013 with System Center

Operations Manager (SCOM) 2012 R2 - Jason Kaczor

SPH03 - Getting a Grip onSharePoint Social - Michael Doyle

SQH01 - SQL Server Reporting Services on Power BI

- Kevin Goff

SQH02 - Getting Started Reading Query Execution Plans

- Grant Fritchey

SQH03 - Database Design:Size DOES Matter - Thomas LaRock

TMH01 - Managing Hyper-Vwith Windows PowerShell

- Jeffery Hicks

TMH02 - Building a Secure and Cost-Effective BitLocker

- Sami Laiho

TMH03 - Improve Your TechWriting Skills: Lessons from a

Professional Author - Don Jones

MAH01 - Analyzing Results with Power BI - Steve Hughes

9:30 AM 10:45 AMVSH05 - Microsoft Azure Web Sites for the Web Developer

- Eric D. Boyd

VSH06 - Building Rich Data Input Windows 8 Applications -

Brian Noyes

VSH07 - Build Your First Mobile App in 1 Hour with Microsoft App Studio

- Nick Landry

VSH08 - Writing Asynchronous Code Using .NET 4.5 and C# 5.0

- Brian PeekSPH04 - Deep Dive into Office 365

APIs - Jeremy ThakeSPH05 - No Governance As Usual

- Robert BogueSPH06 - Is “Enterprise Search”

Dead??? - Agnes MolnarSQH04 - Excel, Power BI and You:

An Analytics Superhub - Andrew Brust

SQH05 - Secrets of SQL Server: Database WORST Practices -

Pinal Dave

SQH06 - Securing Your Database by Using Transparent Data

Encryption (TDE) - Bradley Ball

TMH04 - Document Everything with Windows PowerShell

- Jeffery Hicks

TMH05 - The Real-World Guide to Upgrading your IT Skills AND Your Infrastructure, Part 1 - Rick Claus

TMH06 - Proactive Security inWindows Environments

- Sami LaihoMAH02 - Building a Native iOS App

- Lou Miranda

11:00 AM 12:15 PM VSH09 - Moving Web Apps to the Cloud - Eric D. Boyd

VSH10 - XAML Antipatterns - Ben Dewey VSH11 - To Be Announced VSH12 - Asynchronous Debugging

in .NET - Jason Bock

SPH07 - Lazy Client-side Dev: Let the 3rd-party Libraries Do the Heavy Lifting - Mark Rackley

SPH08 - Automating your Enter-prise Application Deployments with PowerShell - Geoff Varosky

SPH09 - Implementing ECM Solutions with SharePoint 2013

- Rob Bogue

SQH07 - Self-ServiceBI Governance

- Jen Underwood

SQH08 - Statistics and theQuery Optimizer - Grant Fritchey

SQH09 - To Be Announced

TMH07 - Discussing the Future of Desktop Administration:

Are Configuration Manager’s Days Numbered?

- Don Jones and Greg Shields

TMH08 - The Real-World Guide to Upgrading your IT Skills AND Your Infrastructure, Part 2 - Rick Claus

TMH09 - How to Build a Perfect File Server with Windows Server

- Sami Laiho

MAH03 - Building an Android App with Xamarin - Nick Landry

12:15 PM 1:30 PM Lunch on the Lanai

1:30 PM 2:45 PM VSH13 - Node.js for .NET Developers - Jason Bock

VSH14 - Building Maintainable and Extensible MVVM WPF Apps

with Prism 5 - Brian Noyes

VSH15 - Learning EntityFramework 6 - Leonard Lobel

VSH16 - Rock Your Code Using Code Contracts - David McCarter

SPH10 - BreezeJS Makes Cli-ent-Side SharePoint 2013 REST

Development a… BREEZE! - Andrew Connell

SPH11 - 10 Misconceptions of Information Architecture You Should Forget - Agnes Molnar

SPH12 - Developers Approach to Search Applications

- Matt McDermott

SQH10 - Busy Developer’s Guideto R - Ted Neward

SQH11 - Inside the SQL Server Query Optimizer - Bradley Ball

SQH12 - Monitoring Databasesin a Virtual Environment

- Thomas LaRock

TMH10 - Eliminate the Regulatory Compliance Nightmare

- J. Peter BruzzeseTMH11 - To Be Announced

TMH12 - Oh Snap! Active Directory Attribute-level Recovery when

the AD Recycle Bin Cannot Help - Ashley McGlone

MAH04 - Building a Windows App - Brent Edwards

3:00 PM 4:15 PMVSH17 - Building Mobile

Cross-Platform Apps in C# with Azure Mobile Services - Nick Landry

VSH18 - XAML for the WinForms Developer - Philip Japikse

VSH19 - Database Development with SQL Server Data Tools

- Leonard Lobel

VSH20 - Rock Your Code With Visual Studio Add-ins

- David McCarter

SPH13 - SharePoint DesignManager – Step by Step

-Paul Schaeflein

SPH14 - SharePoint Forensics forIT Professionals - Jason Kaczor

SPH15 - Introducing Office Web Apps as a Tool for Developing

Content Rich Applications - Ryan McIntyre

SQH13 - Advanced Analytics and Data Mining for Power BI

- Jen UnderwoodSQH14 - Cardinality Estimates in

SQL Server 2014 - Thomas LaRockSQH15 - Busy Developer’s Guide

to NoSQL - Ted Neward

TMH13 - Exchange 2013 and SharePoint 2013: Better Together

- J. Peter Bruzzese

TMH14 - Migrating Your Windows Failover Clusters - Is Now the

Right Time to Upgrade? - Bruce Mackenzie-Low

TMH15 - Migrate GPOs from One Domain / Forest to another Using

PowerShell - Ashley McGlone

MAH05 - Building a Responsive Single Page App - Allen Conway

4:30 PM 5:45 PM Live! 360 Conference Wrap-up Andrew Connell, Matt McDermott, Don Jones, Greg Shields, Andrew Brust, Rockford Lhotka

START TIME END TIME Visual Studio Live! Post-Conference Workshops: Friday, November 21, 2014 SharePoint Live! Post-Conference Workshops: Friday, November 21, 2014 SQL Server Live! Post-Conference Workshops: Friday, November 21, 2014 TechMentor Post-Conference Workshops: Friday, November 21, 2014 MAL! Post-Conf. Workshop: Fri., Nov. 21, 2014

8:00 AM 5:00 PM VSF01 - Workshop: Service Orientation Technologies: Designing,Developing, & Implementing WCF and the Web API - Miguel Castro

VSF02 - Workshop: Build a Windows 8.1 Application in a Day - Philip Japikse

SPF01 - Workshop: Apps for SharePoint -The Next Level - Paul Schaeflein

SPF02 - Workshop: Implementing Search Based Intranet in SharePoint 2013 and Office 365

- Agnes Molnar

SQF01 - Workshop: Performance Tuning Best Practices - Every DBA and Developer MUST Know

- Pinal DaveSQF02 - Workshop: SQL Server 2014 for Developers

- Leonard LobelTMF01 - Workshop: Microsoft Exchange Boot Camp

for the Accidental Exchange Administrator - J. Peter Bruzzese

TMF02 - Workshop: Windows TroubleshootingDEEP DIVE - Bruce Mackenzie-Low

MAF01 - Workshop: Modern App Development In-Depth: iOS, Android, Windows, and Web - Brent Edwards,Anthony Handley, Lou Miranda, & Allen Conway

Speakers and sessions subject to change

VISUAL STUDIO LIVE! TRACKS SHAREPOINT LIVE! TRACKS SQL SERVER LIVE! TRACKS TECHMENTOR TRACKS MODERN APPS LIVE! TRACK

ASP.NET CloudComputing

Cross-PlatformMobile

Development

DataManagement

JavaScript /HTML5 Client

Visual Studio/ .NET Framework

WindowsClient

WindowsPhone

Developing Apps and Solutions for

SharePoint

High-Value Share-Point Workloads: Social, Search, BI,

and Business Process Automation

Information and Content

Management: Documents,

Records, and Web

Keys to SharePoint Success: Strategy,

Governance, Adoption

SharePoint Infrastructure

Management andAdministration

SharePoint, Office 365 and the Cloud

BI, Big Data, Data Analytics,

and Data Visualization

SQL Server Administration &

Maintenance

SQL Server Features &

Components

SQL Server for the Developer / SQL Server 2014

SQL Server in the Cloud

SQL ServerPerformance Tuning and

Optimization

SQL Server Tools, Tricks,

and Techniques

Advanced Windows

Networking

Hybrid Cloudand

Virtualizatin

Jack ofAll Trades

Security and Ethical Hacking

System Center & Microsoft Exchange

Windows PowerShell

WindowsServer

Presented inPartnership with:

Page 40: MSDN September 2014

START TIME END TIME Visual Studio Live! Pre-Conference: Sunday, November 16, 2014 SharePoint Live! Pre-Conference: Sunday, November 16, 2014 SQL Server Live! Pre-Conference: Sunday, November 16, 2014 TechMentor Pre-Conference: Sunday, November 16, 2014 Modern Apps Live! Pre-Conf.: Sun., Nov. 164:00 PM 9:00 PM Pre-Conference Registration - Royal Pacific Resort Conference Center6:00 PM 9:00 PM Dine-A-Round Dinner @ Universal CityWalk

START TIME END TIME Visual Studio Live! Pre-Conference Workshops: Monday, November 17, 2014 SharePoint Live! Pre-Conference Workshops: Monday, November 17, 2014 SQL Server Live! Pre-Conference Workshops: Monday, November 17, 2014 TechMentor Pre-Conference Workshops: Monday, November 17, 2014 MAL! Pre-Conf. Workshop: Mon., Nov. 17

8:00 AM 5:00 PM VSM01 - Workshop: Native Mobile App Development for iOS, Android, and Windows using C# - Marcel de Vries & Rockford Lhotka

VSM02 - Workshop: AngularJS in0 to 60 - John Papa

VSM03 - Workshop: FromCode to Release: DevOps forDevelopers - Brian Randell

SPM01 - Workshop: Modern Office 365, SharePoint & Cloud Development Ramp-Up - Andrew Connell

SPM02 - Workshop: Getting Up andRunning with Office 365 - Dan Usher

SQM01 - Workshop: Big Data and NoSQL forDatabase and BI Pros - Andrew Brust

SQM02 - Workshop: Maintaining SQL Serverfor Non-DBAs - Don Jones

TMM01 - Workshop: Microsoft Office 365:The Bootcamp - Andy Malone

TMM02 - Workshop: Automating Hyper-V with System Center Technologies - Greg Shields

MAM01 - Workshop: Modern App TechnologyOverview - Android, iOS, Cloud, and Mobile Web

- Nick Landry, Kevin Ford, & Steve Hughes5:00 PM 6:00 PM EXPO Preview6:00 PM 7:00 PM Live! 360 Keynote:

START TIME END TIME Visual Studio Live! Day 1: Tuesday, November 18, 2014 SharePoint Live! Day 1: Tuesday, November 18, 2014 SQL Server Live! Day 1: Tuesday, November 18, 2014 TechMentor Day 1: Tuesday, November 18, 2014 Modern Apps Live! Day 1: Tues., Nov. 18

8:00 AM 9:00 AM Visual Studio Live! Keynote: To Be Announced SharePoint Live! Keynote: Creating Interactive Experiences for Internal and External Users in Office 365 - Sonya Koptyev, Senior Product Manager, SharePoint and Office, Microsoft SQL Server Live! Keynote: To Be Announced TechMentor Keynote: To Be Announced Modern Apps Live! Keynote: To Be Announced

9:00 AM 9:30 AM Networking Break • Visit the EXPO

9:30 AM 10:45 AM VST01 - Getting Started with Xamarin - Walt Ritscher

VST02 - Great User Experiences with CSS 3 - Robert Boedigheimer

VST03 - What’s New in MVC 5 - Miguel Castro

VST04 - New IDE and Editor Features in Visual Studio 2013

- Deborah KurataSPT01 - Lean-Agile Development

with SharePoint - Bill AyresSPT02 - What’s New for IT PRO’s in SharePoint 2013 - Brian Alderman

SPT03 - Getting Started with Cross Site Publishing in SharePoint 2013

- Prashant Bhoyar

SQT01 - Best Practices for Leveraging SQL Server in Windows Azure Virtual

Machines - Scott KleinSQT02 - SQL Server Integration Services End-to-End - David Dye

SQT03 - Introduction to SQL Server Clustering - Chad Churchwell

TMT01 - Desired State Configura-tion: An Administrator’s Overview

- Don Jones

TMT02 - Automating vSphere with VMware Orchestrator, Part 1

- Greg Shields

TMT03 - Creating an Everywhere LAN Without the Hassle Using DirectAccess - John O’Neill, Sr.

MAT01 - Defining Modern App Development - Rockford Lhotka

11:00 AM 12:15 PMVST05 - Building Your First Universal Application for Windows Phone and

Windows Store - Brian Peek

VST06 - HTML5 and Modernizr for Better Web Sites

- Robert BoedigheimerVST07 - What’s New in Web API 2

- Miguel CastroVST08 - Visual Studio Data Tools for Developers - Deborah Kurata

SPT04 - How to Improve the SharePoint UI Using Bootstrap 3

- Ryan McIntyreSPT05 - Microsoft To Be

Announced SPT06 - To Be Announced SQT04 - SQL Server 2014 In-memory OLTP Deep Dive - Scott Klein

SQT05 - Designing and Maintaining a SQL Server Replication Topology

- Chad Churchwell

SQT06 - Hadoop Administration for SQL Server DBAs - Edwin Sarmiento

TMT04 - PowerShell Scripting and Toolmaking with Patterns and

Practical Uses - Don Jones

TMT05 - Automating vSphere with VMware Orchestrator, Part 2 -

Greg ShieldsTMT06 - To Be Announced MAT02 - Modern App Architecture

- Rockford Lhotka

12:15 PM 2:00 PM Lunch • Visit the EXPO

2:00 PM 3:15 PMVST09 - Introduction to Developing Mobile Apps for the Web Developer

- Ben Hoelting

VST10 - Build an Angular and Bootstrap Web Application in

Visual Studio from the Ground Up - Deborah Kurata

VST11 - ASP.NET MVC for Mobile Devices - Rob Daigneau

VST12 - The Road to Continuous Delivery, Automated UI Testing for

Web, WPF and Windows Forms - Marcel de Vries

SPT07 - Building SharePoint Single Page Apps with AngularJS -

Andrew Connell

SPT08 - Getting Started withOffice 365 - Identity, Provisioning

and Basics of Tenant Administration - Dan Usher

SPT09 - Learn About the Top 5Advanced Search Features You Never

Knew You Needed - Paul Olenick

SQT07 - Big Data 101 with Azure HDInsight - Andrew Brust

SQT08 - Implementing Auditing in SQL Server - David Dye

SQT09 - Building Perfect SQLServers, Every Time - Joey D’Antoni

TMT07 - GO DARK: The PowerShell Delegated AdministrationResource Kit - Don Jones

TMT08 - Using Microsoft Azurefor Easy, Secure, Off-Site Backup

- John O’Neill, Sr.

TMT09 - System Center and the Modern Datacenter: A Tactical

Briefing - Greg Shields

MAT03 - ALM with Visual Studio Online (TFS)and Git - Brian Randell

3:15 PM 4:15 PM Networking Break • Visit the EXPO

4:15 PM 5:30 PMVST13 - Creating Responsive

Cross-Platform Native/Web Apps with JavaScript and Bootstrap -

Ben Dewey

VST14 - Hate JavaScript? TryTypeScript - Ben Hoelting

VST15 - What’s New in WPF 4.5 - Walt Ritscher

VST16 - Understanding Dependency Injection & Writing Testable Software - Miguel Castro

SPT10 - SharePoint 2013 Display Templates and Query Rules

- Matt McDermott

SPT11 - Office 365 Information Architecture and Governance 101

- Ben Curry

SPT12 - Getting Started withSharePoint 2013 Workflows

- Prashant Bhoyar

SQT10 - Integrating SQL Server Analysis Services with Hadoop

- Edwin Sarmiento

SQT11 - Dealing with Errors in SQL Server Integration Services

- David Dye

SQT12 - SQL Server HighAvailability and Disaster Recovery

- Chad Churchwell

TMT10 - Top 20 Mistakes inMicrosoft Public Key Infrastructure

(PKI) Deployments - Mark B. Cooper

TMT11 - Integrating Office 365 with Active Directory, Step-by-Step

- John O’Neill, Sr.

TMT12 - Career Strategies for IT Professionals: A Roundtable

Discussion and Q&A - Don Jones & Greg Shields

MAT04 - Reusing Business and Data Access Logic Across Platforms - Kevin Ford

5:30 PM 7:30 PM Exhibitor Reception

START TIME END TIME Visual Studio Live! Day 2: Wednesday, November 19, 2014 SharePoint Live! Day 2: Wednesday, November 19, 2014 SQL Server Live! Day 2: Wednesday, November 19, 2014 TechMentor Day 2: Wednesday, November 19, 2014 Modern Apps Live! Day 2: Wed., Nov. 198:00 AM 9:00 AM Live! 360 Keynote: To Be Announced

9:15 AM 10:30 AMVSW01 - Build Cross-Platform Apps

with Shared Projects, CSLA .NET, and C# - Rockford Lhotka

VSW02 - AngularJS Jump-Start - John Papa

VSW03 - Best Practices for Self Hosting Web API Based Services

- Rob Daigneau

VSW04 - The Busy Developers Guide to Virtualization with

Hyper-V - Brian Randell

SPW01 - Office Graph and Oslo - The Future of Discovering and

Consuming Information? - Agnes Molnar

SPW02 - SharePoint Tips and Tricks - Avoiding Administrative

Blunders - Dan Usher

SPW03 - Real World: Hybrid Office 365 Solution

- Ben Curry

SQW01 - Who Moved My Tuple? Columnstore Indexes in SQL Server

2014 - Joey D’Antoni

SQW02 - Integrating Reporting Services with SharePoint -

Kevin Goff

SQW03 - Everything You Never Wanted to Know about SQL Server

Indexes - Don Jones

TMW01 - Managing and Deploying BYOD Identity Solutions with a Microsoft PKI - Mark B. Cooper

TMW02 - Managing Infrastructure Migrations at Windows Server’s

End-of-Life - Rick Claus

TMW03 - Automating Application Installations: An Introduction to

Software Packaging & Repackaging - John O’Neill, Sr.

MAW01 - Coding for Quality and Maintainability - Jason Bock

10:30 AM 11:00 AM Networking Break • Visit the EXPO

11:00 AM 12:15 PM VSW05 - Building Cordova Apps in Visual Studio 2013 - Nick Landry

VSW06 - AngularJS Anywherewith Node.js - John Papa

VSW07 - Slice Development Time With ASP.NET MVC, Visual Studio,

and Razor - Philip Japikse

VSW08 - Build It and Ship It with TFS and Release Management

- Brian RandellSPW04 - To Be Announced SPW05 - SharePoint Intranet

Design - Michael DoyleSPW06 - Roadmap for a Successful

Migration to SharePoint Online - Paul Olenick

SQW04 - Getting Started withMDX - William E. Pearson III SQW05 - To Be Announced

SQW06 - Virtualizing SQL Server in VMware, Hyper-V, or Xen:

Yes or No? - Don Jones

TMW04 - Securing Cloud Servers and Services with PKI Certificates

- Mark B. Cooper

TMW05 - Everything You’ve Needed to Know about Windows Scale

Out File Server - Rick ClausTMW06- Skype Internals from a

Security Perspective - Andy MaloneMAW02 - UX Design for Modern Apps

- Anthony Handley

12:15 PM 1:45 PM Birds-of-a-Feather Lunch • Visit the EXPO

1:45 PM 3:00 PM VSW09 - What’s New in Azure for Developers - Vishwas Lele

VSW10 - I Just Met You, and “This” is Crazy, But Here’s My NaN, So Call(me) Maybe? - Rachel Appel

VSW11 - Automated Cross Browser Testing of Your Web Applications

with Visual Studio CodedUI -Marcel de Vries

VSW12 - Readable Code - John Papa

SPW07 - Deploying Provider-Hosted Apps Into Production

- Paul Schaeflein

SPW08 - Optimizing SQL Server 2014 for SharePoint 2013

- Brian Alderman

SPW09 - Office 365: Considerations for a Hybrid Deployment - Geoff Varosky

SQW07 - Getting Started with Analysis Services 2014 Tabular

- William E. Pearson III

SQW08 - Programming the T-SQL Enhancements in SQL Server 2012

- Leonard Lobel

SQW09 - Prevent RecoveryAmnesia - Forget the Backups

- Chris Bell

TMW07 - CIM-ple RemoteManagement with PowerShell

- Jeffery Hicks

TMW08 - Troubleshooting the Windows Client, an Introductory

Clinic - Jeff Stokes

TMW09 - The Dark Side ofSocial Networking and How to

Survive It - Andy Malone

MAW03 - Applied UX: iOS, Android, Windows - Anthony Handley

3:00 PM 4:00 PM Networking Break • Visit the EXPO • Expo Raffle @ 3:30 p.m.

4:00 PM 5:15 PM VSW13 - API Management - Vishwas Lele

VSW14 - Creating HTML5 and Angular Websites Using Visual Studio

LightSwitch - Michael Washington

VSW15 - Build Real-Time Websites and Apps with SignalR

- Rachel Appel

VSW16 - Visual Studio Online:An Update Every Three Weeks

- Brian RandellSPW10 - Test-driven Development with SharePoint 2013 - Bill Ayres

SPW11 - Bringing the Users With You - SharePoint 2013 Adoption and Engagement - Robert Bogue

SPW12 - SharePoint and the Mystical OneDrive for Business

- Dan Usher

SQW10 - Implementing Data Warehouse Patterns with the

Microsoft BI Tools - Kevin Goff

SQW11 - Accelerate Database Performance through Data

Compression - Joey D’Antoni

SQW12 - Building a DatabaseDeployment Pipeline

- Grant FritcheyTMW10 - Creating Graphical

PowerShell Tools - Jeffery HicksTMW11 - Building a Better VDI

Image: Best Practices fromMicrosoft - Jeff Stokes

TMW12 - The Hacker’s Guideto Identity Theft and How to

Survive It - Andy MaloneMAW04 - Leveraging Azure Services

- Kevin Ford

8:00 PM 10:00 PM Live! 360 Evening Event

START TIME END TIME Visual Studio Live! Day 3: Thursday, November 20, 2014 SharePoint Live! Day 3: Thursday, November 20, 2014 SQL Server Live! Day 3: Thursday, November 20, 2014 TechMentor Day 3: Thursday, November 20, 2014 Modern Apps Live! Day 3: Thurs., Nov. 20

8:00 AM 9:15 AMVSH01 - Creating Visual Studio Cloud Business Applications for

Office 365 / SharePoint 2013 - Michael Washington

VSH02 - To Be AnnouncedVSH03 - Games Development with

Unity and Other Frameworks for Windows and Windows Phone

- Brian Peek

VSH04 - Managing the .NET Compiler - Jason Bock

SPH01- How to Develop and Debug Client-Side Code

- Mark Rackley

SPH02 - Managing SharePoint 2013 with System Center

Operations Manager (SCOM) 2012 R2 - Jason Kaczor

SPH03 - Getting a Grip onSharePoint Social - Michael Doyle

SQH01 - SQL Server Reporting Services on Power BI

- Kevin Goff

SQH02 - Getting Started Reading Query Execution Plans

- Grant Fritchey

SQH03 - Database Design:Size DOES Matter - Thomas LaRock

TMH01 - Managing Hyper-Vwith Windows PowerShell

- Jeffery Hicks

TMH02 - Building a Secure and Cost-Effective BitLocker

- Sami Laiho

TMH03 - Improve Your TechWriting Skills: Lessons from a

Professional Author - Don Jones

MAH01 - Analyzing Results with Power BI - Steve Hughes

9:30 AM 10:45 AMVSH05 - Microsoft Azure Web Sites for the Web Developer

- Eric D. Boyd

VSH06 - Building Rich Data Input Windows 8 Applications -

Brian Noyes

VSH07 - Build Your First Mobile App in 1 Hour with Microsoft App Studio

- Nick Landry

VSH08 - Writing Asynchronous Code Using .NET 4.5 and C# 5.0

- Brian PeekSPH04 - Deep Dive into Office 365

APIs - Jeremy ThakeSPH05 - No Governance As Usual

- Robert BogueSPH06 - Is “Enterprise Search”

Dead??? - Agnes MolnarSQH04 - Excel, Power BI and You:

An Analytics Superhub - Andrew Brust

SQH05 - Secrets of SQL Server: Database WORST Practices -

Pinal Dave

SQH06 - Securing Your Database by Using Transparent Data

Encryption (TDE) - Bradley Ball

TMH04 - Document Everything with Windows PowerShell

- Jeffery Hicks

TMH05 - The Real-World Guide to Upgrading your IT Skills AND Your Infrastructure, Part 1 - Rick Claus

TMH06 - Proactive Security inWindows Environments

- Sami LaihoMAH02 - Building a Native iOS App

- Lou Miranda

11:00 AM 12:15 PM VSH09 - Moving Web Apps to the Cloud - Eric D. Boyd

VSH10 - XAML Antipatterns - Ben Dewey VSH11 - To Be Announced VSH12 - Asynchronous Debugging

in .NET - Jason Bock

SPH07 - Lazy Client-side Dev: Let the 3rd-party Libraries Do the Heavy Lifting - Mark Rackley

SPH08 - Automating your Enter-prise Application Deployments with PowerShell - Geoff Varosky

SPH09 - Implementing ECM Solutions with SharePoint 2013

- Rob Bogue

SQH07 - Self-ServiceBI Governance

- Jen Underwood

SQH08 - Statistics and theQuery Optimizer - Grant Fritchey

SQH09 - To Be Announced

TMH07 - Discussing the Future of Desktop Administration:

Are Configuration Manager’s Days Numbered?

- Don Jones and Greg Shields

TMH08 - The Real-World Guide to Upgrading your IT Skills AND Your Infrastructure, Part 2 - Rick Claus

TMH09 - How to Build a Perfect File Server with Windows Server

- Sami Laiho

MAH03 - Building an Android App with Xamarin - Nick Landry

12:15 PM 1:30 PM Lunch on the Lanai

1:30 PM 2:45 PM VSH13 - Node.js for .NET Developers - Jason Bock

VSH14 - Building Maintainable and Extensible MVVM WPF Apps

with Prism 5 - Brian Noyes

VSH15 - Learning EntityFramework 6 - Leonard Lobel

VSH16 - Rock Your Code Using Code Contracts - David McCarter

SPH10 - BreezeJS Makes Cli-ent-Side SharePoint 2013 REST

Development a… BREEZE! - Andrew Connell

SPH11 - 10 Misconceptions of Information Architecture You Should Forget - Agnes Molnar

SPH12 - Developers Approach to Search Applications

- Matt McDermott

SQH10 - Busy Developer’s Guideto R - Ted Neward

SQH11 - Inside the SQL Server Query Optimizer - Bradley Ball

SQH12 - Monitoring Databasesin a Virtual Environment

- Thomas LaRock

TMH10 - Eliminate the Regulatory Compliance Nightmare

- J. Peter BruzzeseTMH11 - To Be Announced

TMH12 - Oh Snap! Active Directory Attribute-level Recovery when

the AD Recycle Bin Cannot Help - Ashley McGlone

MAH04 - Building a Windows App - Brent Edwards

3:00 PM 4:15 PMVSH17 - Building Mobile

Cross-Platform Apps in C# with Azure Mobile Services - Nick Landry

VSH18 - XAML for the WinForms Developer - Philip Japikse

VSH19 - Database Development with SQL Server Data Tools

- Leonard Lobel

VSH20 - Rock Your Code With Visual Studio Add-ins

- David McCarter

SPH13 - SharePoint DesignManager – Step by Step

-Paul Schaeflein

SPH14 - SharePoint Forensics forIT Professionals - Jason Kaczor

SPH15 - Introducing Office Web Apps as a Tool for Developing

Content Rich Applications - Ryan McIntyre

SQH13 - Advanced Analytics and Data Mining for Power BI

- Jen UnderwoodSQH14 - Cardinality Estimates in

SQL Server 2014 - Thomas LaRockSQH15 - Busy Developer’s Guide

to NoSQL - Ted Neward

TMH13 - Exchange 2013 and SharePoint 2013: Better Together

- J. Peter Bruzzese

TMH14 - Migrating Your Windows Failover Clusters - Is Now the

Right Time to Upgrade? - Bruce Mackenzie-Low

TMH15 - Migrate GPOs from One Domain / Forest to another Using

PowerShell - Ashley McGlone

MAH05 - Building a Responsive Single Page App - Allen Conway

4:30 PM 5:45 PM Live! 360 Conference Wrap-up Andrew Connell, Matt McDermott, Don Jones, Greg Shields, Andrew Brust, Rockford Lhotka

START TIME END TIME Visual Studio Live! Post-Conference Workshops: Friday, November 21, 2014 SharePoint Live! Post-Conference Workshops: Friday, November 21, 2014 SQL Server Live! Post-Conference Workshops: Friday, November 21, 2014 TechMentor Post-Conference Workshops: Friday, November 21, 2014 MAL! Post-Conf. Workshop: Fri., Nov. 21, 2014

8:00 AM 5:00 PM VSF01 - Workshop: Service Orientation Technologies: Designing,Developing, & Implementing WCF and the Web API - Miguel Castro

VSF02 - Workshop: Build a Windows 8.1 Application in a Day - Philip Japikse

SPF01 - Workshop: Apps for SharePoint -The Next Level - Paul Schaeflein

SPF02 - Workshop: Implementing Search Based Intranet in SharePoint 2013 and Office 365

- Agnes Molnar

SQF01 - Workshop: Performance Tuning Best Practices - Every DBA and Developer MUST Know

- Pinal DaveSQF02 - Workshop: SQL Server 2014 for Developers

- Leonard LobelTMF01 - Workshop: Microsoft Exchange Boot Camp

for the Accidental Exchange Administrator - J. Peter Bruzzese

TMF02 - Workshop: Windows TroubleshootingDEEP DIVE - Bruce Mackenzie-Low

MAF01 - Workshop: Modern App Development In-Depth: iOS, Android, Windows, and Web - Brent Edwards,Anthony Handley, Lou Miranda, & Allen Conway

Speakers and sessions subject to change

VISUAL STUDIO LIVE! TRACKS SHAREPOINT LIVE! TRACKS SQL SERVER LIVE! TRACKS TECHMENTOR TRACKS MODERN APPS LIVE! TRACK

ASP.NET CloudComputing

Cross-PlatformMobile

Development

DataManagement

JavaScript /HTML5 Client

Visual Studio/ .NET Framework

WindowsClient

WindowsPhone

Developing Apps and Solutions for

SharePoint

High-Value Share-Point Workloads: Social, Search, BI,

and Business Process Automation

Information and Content

Management: Documents,

Records, and Web

Keys to SharePoint Success: Strategy,

Governance, Adoption

SharePoint Infrastructure

Management andAdministration

SharePoint, Office 365 and the Cloud

BI, Big Data, Data Analytics,

and Data Visualization

SQL Server Administration &

Maintenance

SQL Server Features &

Components

SQL Server for the Developer / SQL Server 2014

SQL Server in the Cloud

SQL ServerPerformance Tuning and

Optimization

SQL Server Tools, Tricks,

and Techniques

Advanced Windows

Networking

Hybrid Cloudand

Virtualizatin

Jack ofAll Trades

Security and Ethical Hacking

System Center & Microsoft Exchange

Windows PowerShell

WindowsServer

Presented inPartnership with:

Page 41: MSDN September 2014

FEATURED SPEAKERSLive! 360 brings you over 70 speakers; some of the best and brightest experts in the industry.

RACHEL APPEL JASON BOCK ROBERT BOEDIGHEIMER MIGUEL CASTRO MARCEL DE VRIES

DEBORAH KURATA ROCKFORD LHOKTA BRIAN NOYES JOHN PAPA BRIAN RANDELL

JEFFERY HICKS DON JONES SAMI LAIHO BRUCE MCKENZIE-LOW GREG SHIELDS

BILL AYERS ROBERT BOGUE ANDREW CONNELL MATTHEW MCDERMOTT AGNES MOLNAR

ANDREW BRUST PINAL DAVE SCOTT KLEIN LEONARD LOBEL TED NEWARD

ALLEN CONWAY BRENT EDWARDS KEVIN FORD STEVEN HUGHES NICK LANDRY

IT AND DEVELOPER TRAINING THAT’S OUT OF THIS WORLD.

Live! 360 brings together fi ve conferences, and the brightest minds in IT and Dev, to explore leading edge technologies and conquer current ones. These co-located events will incorporate knowledge transfer and networking, along with out-of-this-world education and training, as you create your own custom conference, mixing and matching sessions and workshops to best suit your needs.

OPEN PAGE TO VIEW ➔

VIEW ALL 180+ SESSIONS INSIDE

NOV17-21

ORLANDOROYAL PACIFIC RESORT AT UNIVERSAL ORLANDO

EVENT PARTERS PLATINUM SPONSOR GOLD SPONSORS PRODUCED BY

The Future of Software Development is Back, Modern Apps Live! will break down the latest techniques in low cost, high value application development. modernappslive.com

CONNECT WITH LIVE! 360 twitter.com/@live360events facebook.com – Search “Live 360”

linkedin.com – Join the “Live 360” group!

USS Collaborate: Let’s Work Together. Climb aboard to work through your most pressing

SharePoint projects.

SQL Server Live! will leave you with the skills needed to Conquer Planet Data, whether you are a

DBA, developer, IT Pro, or Analyst.

Master the Modern Apps Landscape and learn how to architect, design and build a complete

Modern Application from start to fi nish.

Join us for an IT Training Odyssey, focused entirely on making your datacenter more

modern, more capable, and more manageable.

Calling all .NET Developers: The Code is Strong with This One; Experience unbiased and

practical training on the Microsoft Platform.

REGISTER BY SEPTEMBER 17 AND SAVE $400!

Scan the QR code to register or for more event details.

Use promo code L360SEPTI

Five events, 29 tracks, and literally hundreds of sessions to choose from – mix and match sessions to create your own, custom event line-up – it’s like no other conference available today.

SUPPORTED BY

magazine

Use promo code L360SEPTI

REGISTER BY SEPTEMBER 17 AND SAVE $400!

CONNECT WITH LIVE! 360 twitter.com/@live360events facebook.com – Search “Live 360”

linkedin.com – Join the “Live 360” group!

VIEW THE FULL LIST OF SPEAKERS AT LIVE360EVENTS.COM

SPECIAL PULL-OUT SECTIONlive360events.com

Page 42: MSDN September 2014

FEATURED SPEAKERSLive! 360 brings you over 70 speakers; some of the best and brightest experts in the industry.

RACHEL APPEL JASON BOCK ROBERT BOEDIGHEIMER MIGUEL CASTRO MARCEL DE VRIES

DEBORAH KURATA ROCKFORD LHOKTA BRIAN NOYES JOHN PAPA BRIAN RANDELL

JEFFERY HICKS DON JONES SAMI LAIHO BRUCE MCKENZIE-LOW GREG SHIELDS

BILL AYERS ROBERT BOGUE ANDREW CONNELL MATTHEW MCDERMOTT AGNES MOLNAR

ANDREW BRUST PINAL DAVE SCOTT KLEIN LEONARD LOBEL TED NEWARD

ALLEN CONWAY BRENT EDWARDS KEVIN FORD STEVEN HUGHES NICK LANDRY

IT AND DEVELOPER TRAINING THAT’S OUT OF THIS WORLD.

Live! 360 brings together fi ve conferences, and the brightest minds in IT and Dev, to explore leading edge technologies and conquer current ones. These co-located events will incorporate knowledge transfer and networking, along with out-of-this-world education and training, as you create your own custom conference, mixing and matching sessions and workshops to best suit your needs.

OPEN PAGE TO VIEW ➔

VIEW ALL 180+ SESSIONS INSIDE

NOV17-21

ORLANDOROYAL PACIFIC RESORT AT UNIVERSAL ORLANDO

EVENT PARTERS PLATINUM SPONSOR GOLD SPONSORS PRODUCED BY

The Future of Software Development is Back, Modern Apps Live! will break down the latest techniques in low cost, high value application development. modernappslive.com

CONNECT WITH LIVE! 360 twitter.com/@live360events facebook.com – Search “Live 360”

linkedin.com – Join the “Live 360” group!

USS Collaborate: Let’s Work Together. Climb aboard to work through your most pressing

SharePoint projects.

SQL Server Live! will leave you with the skills needed to Conquer Planet Data, whether you are a

DBA, developer, IT Pro, or Analyst.

Master the Modern Apps Landscape and learn how to architect, design and build a complete

Modern Application from start to fi nish.

Join us for an IT Training Odyssey, focused entirely on making your datacenter more

modern, more capable, and more manageable.

Calling all .NET Developers: The Code is Strong with This One; Experience unbiased and

practical training on the Microsoft Platform.

REGISTER BY SEPTEMBER 17 AND SAVE $400!

Scan the QR code to register or for more event details.

Use promo code L360SEPTI

Five events, 29 tracks, and literally hundreds of sessions to choose from – mix and match sessions to create your own, custom event line-up – it’s like no other conference available today.

SUPPORTED BY

magazine

Use promo code L360SEPTI

REGISTER BY SEPTEMBER 17 AND SAVE $400!

CONNECT WITH LIVE! 360 twitter.com/@live360events facebook.com – Search “Live 360”

linkedin.com – Join the “Live 360” group!

VIEW THE FULL LIST OF SPEAKERS AT LIVE360EVENTS.COM

SPECIAL PULL-OUT SECTIONlive360events.com

Page 43: MSDN September 2014

33September 2014msdnmagazine.com

specifi es exactly what kind of ML model is to be used. Alternatives to Logistic Regression Binary Classifi cation include modules Aver-aged Perceptron Binary, Boosted Decision Tree Binary and Neural Network Binary Classifi ers.

So, how do you know which model to use? Because the output to predict has two possible values, democrat or republican, you want a binary model. But there are dozens of ML approaches and probably the hardest part of using ML Studio is having to research the pros and cons of diff erent ML classifi ers. A devel-oper analogy with Visual Studio is that the Microsoft .NET Framework has dozens of data structures, such as generic Dictio-nary, HashSet, and generic Queue, and it’s up to you to know exactly what each data structure does. In the same way, it’s up to you to learn about ML classifi ers.

The Logistic Regression module has some parameters you likely won’t understand, including Optimization tolerance, L1 regularization weight, and Memory size for L-BFGS. Again, it’s up to you to learn what these

parameters do. Fortunately, ML Studio has well-chosen default val-ues for most module parameters. I accepted all default parameter values except I used zero for the “Random number seed.”

In the Train Model module, you have to tell ML Studio which col-umn of the training data is the Label column; that is, which column is the variable to predict. With the Train Model module selected, I clicked on the Launch column selector button in the module’s parameters pane and chose the pick-by-name option in the dropdown control, and then typed political party. I could’ve used the column index, 1, because political party is in the first column (ML Studio indices are 1-based rather than 0-based as developers are accustomed to). Note that specify-ing the Label column for the Train Model module is required even if you do so in the Metadata Editor.

Evaluating the ModelAfter the demo model has been trained, the next steps are to feed the training data and the test data to the model, calculate the computed outputs, and calculate the accuracy of the computed outputs (against

the known outputs). In code, this might look like:lm.ComputeOutputs(trainData); // Scoredouble trainAccuracy = lm.Accuracy(trainData); // Evaluatelm.ComputeOutputs(testData); // Score double testAccuracy = lm.Accuracy(testData); // Evaluate

Figure 6 shows a close-up of the relevant scoring and evaluating modules. Th e two Score Model modules accept two input fl ows. Th e fi rst input is the trained model (the information needed to com-pute outputs), and the second input is either a training set or test set

Figure 7 Model Accuracy on Test Data

Figure 8 Entering New Data to Predict

Page 44: MSDN September 2014

msdn magazine34 Microsoft Azure

(the data inputs needed). Th e results of these two scoring modules are sent to the Evaluate Model module, which computes accuracy.

Figure 7 shows the results in the Evaluate Model module. Notice in the upper right, the second of two Dataset items has been selected (it’s highlighted), which means the results are for the test data. Th e most important part of the result is the Accuracy value of 0.989. Recall the test set was 20 percent of the 435 original data items, or 87 items. Th e Logistic Regression model correctly predicted the political party of 86 out of the 87 test items. Th ere’s a lot of other information in Evaluate Model module results. For example, the graph is called a Receiver Operating Characteristic (ROC) graph. It plots the percentage of “true positives” (correct predictions) on the y-axis vs. the percentage of “false positives” (incorrect predictions) on the x-axis.

Making PredictionsOnce an ML Studio model has been created and evaluated, it can be used to make predictions on data with unknown outputs. I wanted to predict the political party of a hypothetical Representative who voted “yes,” “no,” “yes,” “no,” and so on, on the 16 legislative bills, and a second Representative who voted “yes” on the fi rst eight bills and “no” on the remaining eight bills.

One approach would be to create and upload a new ML Studio Dataset and then score it in the same way as the training and test

data sets. But for a limited amount of data, a more interactive approach is to use the Enter Data module as shown in Figure 8, which allows you to enter data manually.

Th e format of the data in the module must exactly match the format of the data used to train the model, so the column headers are required. Th e output from the Enter Data module is combined with the output from the Train Model module. Aft er running the experiment, you can see the results by clicking on the Visualize option of the Score Model module, as shown earlier in Figure 2.

If you were making predictions using a procedural programming language, the code might resemble:

string[] unknown = new string[] { "party", "y", "n", "y", . . "n" };double result = lm.ComputeOutput(unknown);if (result < 0.5) Console.WriteLine("Predicted party is democrat");else Console.WriteLine("Predicted party is republican");

Again, some of the ML Studio information is likely to be a bit mys-terious. Recall that the predictions include two trailing numeric values:

unknown-party y n y . . y n democrat 0.0013unknown-party y y y . . n n republican 0.7028

As it turns out, for Logistic Regression Binary Classifi cation, an output value below 0.5 indicates the fi rst class (democrat in this example) and an output value above 0.5 indicates the second class (republican). Keep in mind that, like Visual Studio, ML Studio has many features and generates a huge amount of information. You learn what the various pieces of information mean over time by using the system and tackling one new piece at a time, rather than doing a deep dive into the documentation and trying to learn everything at once.

No Code?!Th is article just scratched the surface of ML Studio, but it provides enough information so you can replicate the voting experiment and give the tool a try. You may have noticed that this article doesn’t include any coding. No code? Bah! But one of the coolest things about ML Studio is that you can write your own custom modules using C#, and I’ll be covering this topic in future articles. My hunch is that ML Studio will generate an ecosystem in which developers write sophisticated, specialized modules and make them available both commercially and through various channels, such as open source and blogs.

DR. JAMES MCCAFFREY works for Microsoft Research in Redmond, Wash. He has worked on several Microsoft products including Internet Explorer and Bing. He can be reached at jammc@microsoft .com.

THANKS to the following Microsoft technical experts for reviewing this article: Roger Barga (Machine Learning) and Michael Jones (Global Product Engineering)

The Azure ML Studio application, together with its back-end engine, the Microsoft Azure Machine Learning (ML) service, is much more than the client tool described in this short article. From a developer’s point of view, ML Studio dramatically simplifi es the creation of prediction systems. But there are additional value propositions that are not so obvious.

One important topic not covered in this article is the ability of Azure ML to create and publish a Web service using just drag and drop and a few clicks. Azure ML automatically handles deployment, capacity provisioning, load balancing, auto-scaling and health monitoring. One pre-release customer estimated that with Azure ML, they were able to create a business solution (a fraud detection system) at a tiny fraction of the cost of using commercial analytics software.

Azure ML supports R, a popular data science programming language. Hundreds of existing open source R modules can be directly copied into an Azure ML system.

ML Studio allows easy collaboration. An experiment can be easily shared among several people. I’ve used this feature myself and it was much more effi cient than my normal, back-and-forth e-mail conversation approach.

Azure ML provides more than just advantages to developers and data scientists. “Deploying advanced analytics is hard,” said Joseph Sirosh, Microsoft corporate vice president, Information Management and Machine Learning. “Enterprises are tired of pay-ing high prices, recruiting expensive talent and waiting months to get results. Having the ability to quickly develop analytic models and deploy them without these bottlenecks is game-changing. Azure ML allows businesses to unlock value in their data and build systems to reduce expenses, grow revenue and serve their end customers better.”

More Than Just a Tool

One of the coolest things about ML Studio is that you can write your own custom modules using C#.

Page 45: MSDN September 2014

solutions available for

Learn more at www.nevron.com today

Untitled-12 1 6/10/14 12:26 PM

Page 46: MSDN September 2014

msdn magazine36

The ever-increasing adoption of mobile devices is pro-pelling the creation of location-aware apps. Th e opportunities for apps that know and react to a user’s location are virtually limitless. Windows 8 included geolocation from the beginning, giving developers an easy way to determine the current location of a device. Th e Windows simulator even includes support for testing this feature. With Windows 8.1, these APIs have been extended with the concept of geofencing.

A geofence is a defi ned region around a GPS location that can be registered with Windows so an app can receive notifi cations when the device enters or leaves that region. Let’s say you’re a service technician with a dozen house calls to make in a given day. What if

the app that manages your appointments could automatically send a text message to the home owner when you were fi ve minutes away? Or suppose an amusement park wanted to announce the presence of characters, but only to people within a certain proximity of the character to limit the number of people that might show up. Th e possibilities are endless.

This article will explore the use of geofences in Windows 8.1. However, the geofencing API is also shared with Windows Phone 8.1, which means you can implement the same features on both platforms. You’ll learn how to add geofences to your location-based app, plus how to handle events when the app is in the foreground and how to handle notifi cations when the app is in the background.

Adding Geolocation SupportBecause geofences are part of the geolocation API in the Windows SDK, you must add support for this API to your app before you can use it. Luckily, Windows Store apps need very little setup to use geolocation. In fact, the only requirement is the package appxmanifest must include the Location capability. To add this, open the solution’s appxmanifest in the designer and check “Location” in the capabilities tab, as shown in Figure 1.

Once this capability has been added to your project, the app is able to access Windows location services through the geolocation API if given permission by the user. Th is capability also adds a Permissions section to the app’s Settings charm, which

GE O FE NC ING

Creating a Location-Aware App with GeofencingTony Champion

This article discusses:• Adding geolocation support to a Windows Store app

• Determining user location

• Creating geofences

• Using geofences in the foreground

• Using geofences in the background

Technologies discussed:Windows 8.1, Windows Store Apps

Code download available at:msdn.microsoft.com/magazine/msdnmag0914

Page 47: MSDN September 2014

37September 2014msdnmagazine.com

lets the user enable and disable access to the device’s location, as shown in Figure 2.

In addition to granting access to the location services on an individual app level, Windows can disable location services for the entire device. Location services are enabled by default in Windows, but users or systems administrators are free to change this by going to Control Panel | Hardware and Sound | Location Settings.

Because there are several diff erent scenarios that can aff ect the app’s access to the device’s location, it’s important your app know when there’s a change to this access. Th e SDK lets the app monitor its access to the location services through an event exposed in the DeviceAccessInformation class in the Windows.Devices.Enumer-ation namespace. An instance of the DeviceAccessInformation class is created through a static method, CreateFromDeviceClass, which takes a DeviceClass enumeration that specifi es the hardware device on which you want information. For the location services, this value is DeviceClass.Location. Aft er creating an instance of DeviceAccessInformation, you can determine the current access level from the CurrentStatus property and listen for access changes through the AccessChanged event, like so:

DeviceAccessInformation deviceAccess = DeviceAccessInformation.CreateFromDeviceClass(DeviceClass.Location);

DeviceAccessStatus currentStatus = deviceAccess.CurrentStatus;// Setup geolocation based on status

// Listen for access changesdeviceAccess.AccessChanged += deviceAccess_AccessChanged;

The CurrentStatus property and AccessChanged event both receive a DeviceAccessStatus enumeration that describes the current access level. Figure 3 shows the available values and their defi nitions.

Determining LocationIf you’re going to build a location-aware app that uses a geofence, you need to be able

to determine the user’s location. Though this is not necessarily required to implement geofences, you’ll see later in this article that it comes in handy when validating geofence events.

Th e Windows SDK exposes a Geolocator class that attempts to determine the current GPS loca-tion of the device through several methods. Th e Geolocator and all location classes can be found in the Windows.Devices.Geolocation namespace. Th e fi rst time you use a Geolocator class must be in the UI thread of the app, because Windows will prompt the user for permission

to use the location services. Users are prompted only once per device and they can change this setting at any time by using the Permissions setting described earlier. Th erefore, if a user blocks the original request or disables the permission from the Settings charm, you won’t be able to programmatically change the access back and must rely on a UI notifi cation to prompt users to change it themselves.

To determine the device’s current location, Geolocator has a Get-GeopositionAsync method that returns a Geoposition object. Th is object contains a Geocoordinate instance in the Coordinate property that contains the information returned by location ser-vices. Arguably the three most important pieces of information in a Geocoordinate class are the longitude, latitude and altitude of the current GPS position. In Windows 8.1, these are contained in the Point property, which is a Geopoint instance. Th e Latitude, Longitude and Altitude properties of the Geocoordinate class are there for backward compatibility, but the Point property should be used going forward.

Th ere are several other valuable pieces of information in the Geocoordinate class that are helpful in dealing with geofences. Th e most important is the Accuracy property, which defi nes the GPS accuracy in meters. Th e Geolocator class uses the Windows loca-

tion service to determine the current location. Th e location service uses several diff erent ap-proaches to do this. Th e most accurate method is when the device has a GPS radio that’s enabled and receiving a signal. If that’s not available, the location service tries using the device’s Wi-Fi connection to pinpoint the location. Finally, it tries a less accurate approach using IP resolution if the device doesn’t have an active Wi-Fi connection. Obviously, the accuracy of the current location is a signifi cant factor in the validity of the geofences in your app and should be taken into consideration. For instance, IP resolution is only accurate to within 10 miles. Th at really won’t help much if you’re using geofences in an amusement park. With such

Figure 1 Enable Location Capability

Figure 2 Permissions Settings

Page 48: MSDN September 2014

msdn magazine38 Geofencing

a wide range of accuracy for a device, it’s important to consider the size of your geofence in comparison to the accuracy of the location to determine if the geofence is valid.

Th e Timestamp property is extremely useful in determining how old the data is. When dealing with geofences, timing can be very important. If you have geofences in your amusement park, for example, your app might use a different workflow if a user enters the parking lot during business hours versus the middle of the night. Figure 4 shows an example of getting the current loca-tion of the user’s device.

Creating GeofencesTh ere are currently four diff erent constructors for the Geofence class that allow you to define the location and behavior of a geofence. All of the geofencing structures are found in the Windows.Devices.Geolocation.Geofencing namespace. It’s import-ant to know how you want the Geofence instance to behave prior to creating it, because all of the exposed properties are read-only. Th erefore, if you don’t specify something during construction, you’ll have to replace the geofence with a new one if you want to modify it.

The minimum information you need to create a Geofence class is a unique string identifi er and a defi nition of the shape of the geofence, which is represented by an implementation of the IGeoshape interface. Th e only shape supported in Windows 8.1 is the Geocircle, which is defi ned by a center location and a radius in meters. As with the Geofence, these values must be defi ned at construction and can’t be changed aft erward. Th e radius can be anywhere from .1 meters to .25 of the earth’s circumference, which should be sufficient to handle any size your app requires. The following example shows how to create a Geofence at the current device’s location that has a 50-meter radius:

Geolocator geo = new Geolocator();

try { Geoposition pos = await geo.GetGeopositionAsync(); Geocircle shape = new Geocircle(pos.Coordinate.Point.Position, 50.0); Geofence geofence = new Geofence("myUniqueId", shape);}catch (Exception) { }

Windows can monitor several diff erent device interactions with a geofence. By default, it will monitor when a device enters and exits the defi ning area of the geofence. In addition, you can specify

notification when a geofence has been removed from being monitored. It’s a requirement that either the entering or exiting state be monitored, so you can’t monitor only the removal of a geofence, which, to be honest, wouldn’t be very useful to your app in the fi rst place. Monitoring states can be defi ned using a combi-nation of MonitoredGeofence States enumerations and are stored in the MonitoredStates property.

A geofence can also be a single- or multi-use entity. It’s considered to be used once all of the monitored states have occurred. Th erefore, if you specify the entered and exit states, the device must enter and then leave the specifi ed area before the geofence is considered used. Unless otherwise specifi ed, the monitoring will continue until the geofence is removed. Th e SingleUse property identifi es whether the Geofence is set for single use. Th e following builds on the previous example and shows the second Geofence constructor:

MonitoredGeofenceStates monitor = MonitoredGeofenceStates.Entered | MonitoredGeofenceStates.Exited | MonitoredGeofenceStates.Removed;

bool singleUse = true;

Geofence geofence = new Geofence("myUniqueId", shape, monitor, singleUse);

By default, a device must remain on the monitored side of a boundary for 10 seconds before an app is notifi ed. Th is keeps the system from fi ring multiple events if a device is right on the edge and moving back and forth. This value is the DwellTime and can be set to any TimeSpan greater than 0. Th e same DwellTime will be used for entering and exiting the area. Th erefore, if you need diff erent values, you’ll have to create two geofences, one for entering and one for exiting. Th e following uses the third construc-tor by setting the DwellTime to 20 seconds:

TimeSpan dwellTime = new TimeSpan(0, 0, 20);Geofence geofence = new Geofence("myUniqueId", shape, monitor, singleUse, dwellTime);

Th e fi nal constructor allows you to set the StartTime and Duration of the geofence. A geofence will become active once the StartTime is in the past. By default, the StartTime is set to 0 or the beginning of a time handled in a DateTime class. If a geofence is created with a Start-Time in the past and the device is already inside the defi ning area, the Entered state will be reported once the DwellTime has passed. In conjunction with the StartTime, you can defi ne a Duration for how long the geofence will be active from the StartTime. If the Duration is set to 0 (the default value), the geofence remains active as long as it’s registered to be monitored. When a Duration value has been set, the app will be notifi ed of its expiration if the Removed monitor state is selected. Here’s the fi nal constructor, which sets a StartTime for midnight, Jan. 1, 2015, and a duration of 365 days:

DateTime startTime = new DateTime(2015, 1, 1);TimeSpan duration = new TimeSpan(365, 0, 0, 0, 0);

Geofence geofence = new Geofence( "myUniqueId", shape, monitor, singleUse, dwellTime, startTime, duration);

Using Geofences in the ForegroundAft er a geofence has been created, the next step is to register it to be monitored so your app can receive notifi cations about it. Th is is handled through a GeofenceMonitor instance. Each app will have a single GeofenceMonitor that can be accessed through the static property of GeofenceMonitor.Current. The GeofenceMonitor

private void deviceAccess_AccessChanged( DeviceAccessInformation sender, DeviceAccessChangedEventArgs args){ switch (args.Status) { case DeviceAccessStatus.Allowed: // Access to the device is allowed break; case DeviceAccessStatus.DeniedByUser: // Denied by user when prompted or thru Permissions settings break; case DeviceAccessStatus.DeniedBySystem: // Denied at the system level from the Control Panel break; case DeviceAccessStatus.Unspecified: // Unknown reason for access to the device break; }}

Figure 3 AccessChanged Event

Page 49: MSDN September 2014

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); BarCoa C de bbarCoarCCode =de = newn EEanEan113SuS pp5(“12234556789001212345”, x, y + 21); barCode.X += (204 - barCodee.Get

ddUPCVersionA(GrouGroup elemenem ts, float x, floatfloa y) { AddCaptionAndRectangle(elemente s, “UPC Version A Bar Code”, x, y, 2y, 204, 99);9)99);9) Bar BarB rBa CodeC barbarCCode = neew UpcVepcVersionAA(“12345678901”, x, y + 21); barCode.X += (204 - baarCo

ddUPCVersionASSup2(up2 Grououpp elements,, floatoa xx, float y) { AddCaptionAndRectangle(ele( ments, “UPC Version E Bar Code, 2 digit git supsuppsuppup lement”nt”, x,x, x y, 204, 999); BaarCodde barCCode = new UpcVersionASup2(“123456787 90112”, xx, yx, y +

s.Add(barCode); } } pprivate te vooid AddUPCVPCVersiers onASup5(Group elements, float x, floato y) { AddCaptionAndRectangle(eleementmmentm s, “s, “UPC UPC VerVersion EE Bar Code, 5 diggit suupplemment”, x, y, 204, 99); BarCode barCode = n ew UpcVeeersio

ode.GetSymbolWWidth(dth )) / 2; 2 elements.AddAdd(bar(ba Code); } privatee voi v d AddEANEAN8(Group p elements, float x, float y) { AddCddCaptitionAnonAn dRecReccecttaangle(elemments, “EANN/JANN 8 BBar Codde”, x, y, 204, 99); BarCode barCode == newn Ean8(“123434

g(); fileDialog.Title =le = “Op “Open Fen File Dialogg”; filfi eDialog.Filter = “AdAdobe PDFF fileses (*.pdf)f)|*.pdf|All Files (*.*)|*.*”; if (fileDieDialog.log.ShSSShowwDDiallog()og == DialoggResult.OK) { pdfVieweewer.OppenFile(fileDialog.FileName, “”); } SaveSav FileF Diallog saavaveFa

File Dialog”; s saveFveFileDialoal gg.Filter = “AdoAdobee PDF files (*.pdf)f)|*.pdf|All Files (**.*)|*.*”; if (saveFileDialog.ShowDowDialoialoa g()=g()==DiaDi=DiaDi logResulsule t .OOK) {{ pdfVfVieweewerr.SaveAs(saveFileDiaDialog.FileNamee); ); } } if (p( dfVidfV ewewer.PPagP e

WithDialog(); } e else se { MessMe aageBox.SShow(w “PPlease open a fifile tto printt”); } OOpenFileF Dialog fileDiD aloglog = n = nnnew Oew Oe pepenpenFileDDialog(); fifile Dialog.Tiitle = “Open File Dialoog”; filleDialog.InitialDirecectoory = @”c:\”:\ ; fi fileDleDialoglo .Filterter = “= “All F

) == DialogResules t.Ot.OK) { Dy D nnamicPDFFViewewerrClass test = new Dew DynammicPDFVieewerCr lass(); PDFDFPrinPrintter prinprinninterter er = = test.OpenFpe ileForPorPrinnter (file(fileDiaalog.FileName); pprinnter.PrintQuieQuiet();() } bytbybytby ee[] contcontentst =

pServices; GCHGC andandle gcchh = GCHandled .AllAl occ(contents, GCHHandndleTypType.Pinnedd); IntIntPtr contcontentsentsIntPtr ===gcch.ch.h.AAAddrOfPinnednn Objeect()ct ;ppdf Viewer.O.OpenBpepe ufffefeuff r(cor(r(cor( ntentsIntPtrt ,

kmark Page Elemelement:”, x,x, y); y); p pageEleementen s.AAdd(new Bookkmarrk(“( BBookB marked Text”x , x , x + 5,+ 5, y + 20,0 parpareenenttOe utline)); pageElg emennts.Ats.Add (new Label(“This tes texxt is bookmaokmaokmarkedrked ”, .”, xx + 5, y + 20, 2

ageElements, fls, float a x, float at y) {{ // Addsdss a circltt to the pageEllemeents AddCaptioonnAndRAndRectaectangle(paggpagpaggeEleeEl mentmen s, “Circle PPaage Elemment:ent:”, x, y); pageElgeElements.As.Add(ndddd(ndd ew CCircle(x (x + 112.5f2 ,

shLarge)); } pprivavate te void AddFAd orormattedteede TextArrea(Group pp ageeEg lemennts, float x,x, floafloat yt y)t { /{ / AdA dsds ads a for forfofoo matttedd text area too tthepageEeElle ments strring formattm edHtedHtml = “<p“<p><<i>Dynamic</i><b>PDb>P F</bb>&tm>&tmmtm; Generaeraaator oro v6.0 foror .NE

matting suppoort for or text thath t aappears s in the ddocument. Yt. Youuu havve “ + “comcompletetple e cooontrorol ovovovovver 8r 8e parar agraph pph properties: ssppacing befoeforee, spacingg after, firfirst liine “ + “indentantation, left indentatitation, righr t ininndentdentdentntatiotionn, a, aaliignment, alalllowi

<font face=’Tim’Times’es’>fontt fac f e, </fonnt>t>><f> ont ppoino tSizSize=’6’>fffont “ + “““size, </</fonfonntn ><fo<f nt ct coolorloolorlol =’FF000000 ’>>coloor, </font>><b>b<b> old, </b</b><<i>italic aannd </i><<u>uunderline</u>>; “ + “and 2 line proopertrties: leaeadingng, anndd leleeeaadinaad g type. Text

extArea = neew FoFormatrm tedTdTextAArea(fororrmmattedHHtmtml, x + 5, y +++ 20,, 21555, 60, F, FontontFamilmmi y.HeHeelvvelveteticaica, 9, ffalse)e); // SSets the the indent properoperty foformatteatt ddTextAreeaa.Styyle.PParagrapph.Inndent = 18; AddCCapttionAndRectRectanglgle(pae(papa(paapae geEgeElements, ts, “F

ageElemem ntts, “Fo“FormmattedTdTextAtArea OOvvverflow flow TText:”, x + 27999, y); pagpaggeEleeEleementmen ss.AdAdAdd(fod(foodd ormrrmatrmatmatatttedTextAtArea)); // CCreate e an oa verflow formatteded t text art a ea for tr the ooverflflow textt FoormattedTextArea ova oveerflowForFormattma edTeTTeextArxtArxtArtxttArea =ea =e formatte

a(x + 284, y + 20)20); pap geEElemenements.Adddd(o(overflverflowwFowFoow rmatarm tedTeextAe rrea); } privprivate ate vvooidov AddAddA dA Imagmagmagmage(Group up paggeElememeents, float x, float y) { // A/ dds an in magee tto thhe paageElemmenents AddCaptionAndRedRectangle((pagpageElemmmentsenntstsnts, “Imagegee Pag

es/DPDFLoogo.pn.png”), x ++ 1112.55f, y ++ 550f,50f, 0.20.244f);4f // Image is sizeed annnd centeenteredd in tn tthe rrrrectataec nglengle imam ge.SetBoB unds(215, 60); image.VAlign = VAlign.Cenenterr; imaage.Alignn = Align.Center; paggeEeElements.Ad.Addd(imaggee)g ;; } } privvate ate vvoidv A

pageElemennts AdAddCapdC tiononAndRectaannglengle(pag(paggeeEleeElements, “LLabell & PPagePageNumbeerinerine gLgLabg bel PPage ElememE entts:”, x, y); string labelText = “Labels can be rottaated”; strring numbermbe Text = “PageNummbeeringLabelsels contcontaiain ppage nummbeerib ngTT

xt, x + 5, y + 12+ 12, 22220, 80, F0 ontt.TimemessRomRoman,an, 12, TextAlign..Cennter);; l lababel.AngAngglle = 8; 8; 8; PagePageeNNumNumbN erinri gLagLabel pageNumLabel = new PageNumberb ingLabelab (nnumbberText, x +x + 5, y + 55, 220, 880, FFont.TimesResRoman, 1212, TextAltAligignign.n Ce

mem nts.Add(labeabel); l); } private voe id AAddLdLinne(Gne(Groupp pageElemennts, flflfloat x, floaoat y) {{{) { / // Addss a l a lla inne to the phe pageEag lements AddCaptionAndRectangle(p( ageElemee nnts, ““Line Paage Element:”, x, y); ppageeElemennts.As.Add(neew Lw ine(x +x + + x 5, y5 +

w Liw ne(xx + 2+ 220, y + 20, x + + 5, yy + 8 + 0,0, 30, 3, Rg, RgbCoolor.Green)); } prprivivaate vvoid Ad AddLiinknk(Groupup p pagpap eElementments, float x, float y) { // Adds a link to the ppageElemeem ntts Foont font == Foont.TimesRoman;; st string text = “TThisT iss s a lia nk tnk tk o o Dynaamic

mentm :”, x, y); Label label == newne LaLabbbel(textt, x + 5, y + 20, 2155,5, 800, fonnnnt, 1t, 2, R2, RgbbColor.or.BBluelu ); l; abel.UndUndererline = true; Link link = new Link(x + 5, y + 20, font.on GGetTeextWidthh(texxt, 12), 12 - font.GGetDDescendder(1r(12), neeww ee UrlUrlAlAction(“n(“hhttp

EleE mennts.Add(li( nk);; } p } privavate ve voidd AAddPath(ath Grroup pageElemmentts, floatoatfl x, floatt y) y) {{ // AddAd s a s pathh to the pageElements ceTe.DynamicPDF.PageElementen s.Pathh path = nneww ceTe.DynamicPDPDF.PF.PageElemenmennnts.Ps.Paaath(h(x + x + 55, y, y + + 2+ 20, R

PathP s.AAdd(new LineeSubPatPa h(xx ++ 2215, y + 4+ 0))); path.Suh.S bPatths.Ahs.AAAdddd((new CurvurveeToSubPatPa h(x h(x + 1008, y + 80, x + 160, y + 80)); path.SubPaths.Add(neww CCurvveSuubPath(x + 55, y + 40, x + 65, 6 y + y + 80, x + 5, y5, yy + + 60))); AddAddCCaCaptC ionAAnd

AAdd(ppaaath); } privatee void AAddRReccttaangle(GrG oupp pageeEElemennnts, flflflofloatat x, float yat y)) oorderee dLisdL t = t = ordderedList.GetOverFlowList(x + 5, y + 20); AddCaptionAnAndRRectaanggle(pagge.Elements, “Orderr ed Led List Pagegee Ele EleEl mentttn OOOve Ovev rflowrfl :”, x, y, 2

88; /8; // C/ Create an unoordereedd list UUnnornorderede List uunorderere edListt =t =stt neeew UUnonorderrderedLLied st(xx + 55, yy + 20+ 20, 400, 90, Font.Helvetica, 10); unorderedList.Items.Add(Add(“Fruits””); uunorderedere List.Items.Add(“d “VegeVegeg tablees””); UnU U ordeeer redSreedSd ubbList unord

tt((); (); unorderedSubList.Items.ms.Add(“dd((““ Citrus”); unordorderededederedSuSubLiist.Iteeemss.AdAddd(“ Nonn-Citrt us”)s” ; AdAddCCaptionAndRectangle(page.Elemennts, “Unordered Lisst Pagee Elemmente :”, x, yx, y, 225, 110); Unonn rddereedSubLisbLisst ununnu ordederedSredSdredSdd ubLiub st2 = uno

rederer SubbbList2.Items.Add((“PoPotato”); unorderedSSubLiiubLisstt2.Itemmms.Addddd(“BBeans”); Unorno derederedSubdSubLisst subUnorderedSubList = unorderede SubLS ist.Items[0]].SuubLists.AAddddUnorderrde edSubList(); subs bUnorUnorderedSubdSSubbLListLLL .Iteteeems.Ams.Am Addd(“Lime”); s

LList subbbUnorderedSSubList2st = unorderedSubLbLS iist.ist.Itemss[1].SuubLissts.AAddUnordeeredSuedS bLisbL t();t() suubUnorderedSubList2.Items.Add(“Mana go”); subUnorrdereedSSubList2.It2 temms.AAdd(“Banana”); ); UnUnordderedSSuSubdS ListLissLis sububUnorn derede dSubList

tt(()(); subUUnordereddSSubList3.Items.Add(“SweSweew t PoPotato””); Unoorderred dSSubList subbUnorUno dereer dSubdSubListList44 = unorrderedSubList2.It2 ems[1].S].SubLists.AddUnoordeereddSubbList(s ); subUnubU orderedSubLibubListst4.s Iteems.AdAdAdA d(“Sd(“S“Strining BeeBeean”)an” ; subUnoU rde

AAdddd(“Kiddney Beanean”); x += 279; paga e.Elemeements.Addd(ud nnordereedLisst); uunorderedListLis == unordnorderedere List.GetOvere FlowList(x + 5, y + 20);) AddA CaptionAndRecctanngle(ppageag .Elemeents, “UnorUnorderederer d Lid st PPage e ElemElemmmeent ee Oveverve flow:flow:flo ”, x, y, 225

ooiddd AdddTedTextFxtField(Group pageElemenme ts, , flofloat x,, flooat y)) { TexxtField txtt = new TextFixtF eeld(“txt“t fnafname”, x + 20, y + 40, 120, 20); txt.Defaulu tValue = “This iis s a Scrrollabble Te extFFieldd”; txt.BordederColrColC or =o RgbRgbCColoor.Br.Br.Br.Black; txtxttxtxt.BacackgrokgroundCun o

(td(d xt); TTexTextField txt1 = new TextFiField(ld “txxtf1naf1 me”,me” x + 175, yy + 440, 120, 20); txtt1.DefDe aultu Valualue = “TextField”; txt1.Password = true; ttxt1.MaxLength = = 99; txtt1.BoordderColor = RgbCollor.BBor.Black; txt1.B1.Backgckgrounou dCololor =oror =or = RgbRgbR ColoColor Alr.Al

eree ies(); pieSeries.DataLabel == da;a;da plop tAreAreaa.Sea riesrie .Add(pieSSeriess); ppieSeries.Elemelementss.Add(Add(27,27, “Website A”); pieSeries.Elements.Addd (19, “Website BB”)); pieSerrieses.Elementmen s.Add(21d(21, “WWWebsiseb te Cee ”); ”); ); pieSpieSp eries.ElElemenmeements[0ts[0s[0s[0].Co].C lor or == a

esess.Elements[2].Color = aututograog diendientt3;”RgbCRgbColoor.AliceeBlue; txt2.Too.ToolTip = “Multilinnee”; pagepageElElements.Add(txt2); AddCaptionAndRectangle(pageElememennts, “TexxtFiField Formorm PagPage Ele Elemenemenemennnt:”,:”, x, y, 5, 5y 0404, 85);5) } p} rivaate ve ve ooid oid AddCdCombomb

CombCCC ooBox(“cmmbnambna e”, e”, x + x + 51, 51, y + y + 40,40, 150,15 220); cb.BBorderColoor = RgbColor.BlacBlack; ccb.Bab.BackckgroundColor = RgbColor.AliceBlue; cb.Font = Font.Helveelveticaa; cbb.FonFo tSizzSizze = e 12; cb.Icb.Itemsstemsstems.AddA (“Item 1eme ”); ); cb.cb.Itemstems.AddAdAd.Add(“It(“It(“It( Item 2em ”); ”); cbcb

didd table””)”); cb.Itemms[s[“[“Editaabble”].Selectcteded = true; c; cb.Editable = truue; ccb.ToolTip == “Edi“Ed tablab e CoC mmbo Box”; pageElements.Add(cb); ComboBox cb1 = new Cew omboombbb Box(B x(“cmbmb1nammee”, x + 303,3303, y + y + 40, 150, 20 20); c); cb1.BBb1 ordedederderrColor == R

= F== ont.HHHelveticca;a; ca; cbb1.FontSnt ize = 122; cb1.Itemss.AAdd(“IItem 1”); ccb1.Ittems.Add(“It“Item 2em ”); ”) cb1.cb1.ItItems.Add(“Item 3”); cb1.Items.Add(“Item 4”); cb1.Itemss.AAddd(“Noon-Ediditabtablee”);); c cb1.Items[““[“Non-Non-EditEditableable”].S”].Seelected = tr= ue; ue; cb1.1 Edita

ntnntts.Ads dd(cb(cb(cb1); Converter.CoC nvert(“http://www.gogoogogle.ccom”, “Outputt.pdf”);Convertve er.Cer.Conveonvert(GetDocPath(“DocumentA.rtf”), “Output.pdf”);System.Diaiagnooosticscss.ProoPP cesssess.SStart(“Outptput.pput.pdf”)df”); As; AsyncCncConverterrt aCooCoonnvenverteer = new A

errr((aC(aCo( nverrter_Converted); aConverter.ConversionErroor += nnew ConnversionErrorEvventHtHandler(aConverter_ConversionError); aConverter.Convert(@”C:\tC:\ emmp\mpmm DDocummenmenttAA.rtf”, @”C:\tememmmp\Oup\OutputtputA.pdA.pdf”);f”);) aConverv rter.ter.Coonvert(@”C

verve t(@”C:\temp\DocumentC.rtf”, @”C:\temp\OutputCC.pdf”)); aCoonveerter.Convert(e “hhttp://p://www.yahoo.com”, @”C:\Temp\yahoo.pdf”); ConversionOptionsoni ooptop ionnsnsns = = new CConversiosionOptnOpttionsions(720(720, 72, 720, 72, ttrue); ceeTe.DTe. yynamicPDF

tempte \\ooutput.pdf”, options); ceTe.DynamicPDF.Conveersion.Connvertter.Convert(“C:\\\teemp\\Document2.docx”, “C:\\temp\\output.pdf”, options); string sg ammmpamplmpam eHtmH ml = l “<hth ml><ml><bodybody><p>><p>pp TThis is a very ssimplm e HTML ML strring includ

<tab<t le bborder=\”1\”>1 <tr><td>100</td><td>200</td>”” + “<ttd>3300<</td></tr><tr><<td>>400</td><td>500</td><td>600</t< d></tr></table><></bod/body><y><//</</hhthtmhtmlhtmhtm >”;Conveveo rsion.Con.CoCC nvernverter.ter.CConvvertHtmlString(saamplempleHtmll, “C“C:\\\temp\emp\\Sam\Sam

ererNamee”, Path.Combo ine(GetPath(), “LetterPortrait.pdff”)); prrintJoob.DDocumentNamee = “LettLetter Pe ortrait”; if (printJob.Pob. rinter.Color) prinprinprinprinpri tJobtJob P.PrintOpntOn tions.Cos. lor o = trtrue; ue; if (if (prinprinri tJobtJo .Printer.ColC late) printJob.Pb.P.PPrrintr OOptiOptip ons.ons.onons CoCoollollate at = tr= tr= uurr

innt

;ppd

t:: ,

Untitled-1 1 9/8/11 12:41 PM

Page 50: MSDN September 2014

msdn magazine40 Geofencing

maintains a list of all registered geofences in the Geofences prop-erty, which is an IList<Geofence>. Adding and removing geofences from this list is as easy as using the IList methods you’re used to, such as Add and Remove. Once an app registers a geofence, it’s per-sisted to disk. Th is means you only need to register the geofence once, even between app uses. If you attempt to register a geofence with a duplicate id, an error will be generated, so it’s a good policy to verify the id isn’t present prior to registration:

IEnumerable<Geofence> existing = GeofenceMonitor.Current.Geofences.Where(g => g.Id == geofence.Id);

if (existing.Count() == 0){ GeofenceMonitor.Current.Geofences.Add(geofence);}else{ // Handle duplicate entry}

Once the geofence has been added to the GeofenceMonitor, you’ll receive notifications about it based on the monitor states that have been selected. Th ese notifi cations are handled through the GeofenceStateChanged event of the GeofenceMonitor:

GeofenceMonitor.Current.GeofenceStateChanged += GeofenceStateChanged;

When the GeofenceStateChanged event is fired, the affected geofences are not sent in the args property, which is common for most changed event handlers. To get the notification about what has changed, you call the ReadReports method of the cur-rent GeofenceMonitor. This will return a collection of recent monitor notifications, sorted in a descending timestamp order, that have happened for the app. Each notifi cation is represented by a GeofenceStateChangeReport class.

Th e GeofenceStateChangeReport has a Geofence property that references the geofence whose state has changed, and a Geopos-tion property that provides the location of the device responsible for the state being changed. It also has a NewState property, which is a GeofenceState enum that identifi es which monitoring state was triggered. Finally, there’s a RemovalReason property, which is a GeofenceRemovalReason enum that can be either Used or Expired. Th e default is Used for any event and doesn’t mean the geofence has been removed. It simply provides a removal reason if the NewState value is Removed.

Th e number of reports returned by ReadReports is controlled by Windows. Th ere’s no guarantee how many reports will be stored or for how long, so if you need to maintain any information, you’ll need to keep a separate copy in the app. Figure 5 is an example of handling the GeofenceStateChanged event.

Using Geofences in the BackgroundOne of the additional issues developers have to take into consider-ation is the lifecycle of a Windows Store app. If an app isn’t visible on the screen, Windows suspends the application while keeping it in memory, in order to help preserve performance and battery life. Th is means your app will no longer be running. In most cases this isn’t a cause for concern because if the user isn’t directly inter-acting with the app, there’s nothing for the app to do.

However, in some scenarios, an app still needs the ability to continue to perform certain tasks, even if the app isn’t running. Windows addresses this with the concept of background tasks. A

background task is a small unit of code that executes in response to a predefined system event. There are more than a dozen dif-ferent events your app can register a background task for, and listening to geofences is one of them.

Adding a Background TaskAll background tasks are implemented by creating sealed classes that implement the IBackgroundTask interface located in the Windows.ApplicationModel.Background namespace. Th is inter-face defi nes a single Run method that must be implemented. Any classes that implement IBackgroundTask must exist in a Windows Runtime Component and won’t execute if they’re part of your main app project. It’s common practice to put all background tasks for an app in a single Windows Runtime Component.

To create a background task, add a Windows Runtime Component project to your solution. Add a reference to that new project to your main app project so when you register the task the app has visibility to the class structure. Figure 6 illustrates a background task that responds to geofence state changes.

Registering a Background TaskOnce you’ve created a background task, the next step is to register that background task with Windows. As with location services, the user must grant your app permission to use background tasks. You can prompt the user via the static method RequestAccessAsync of the BackgroundExecutionManager class. If the user has already answered the prompt, this method will return the current status of running background tasks on the app.

The actual registration is completed through an instance of BackgroundTaskBuilder. It requires three pieces of information to be valid. The first is a unique name for the app. The second

Geolocator geo = new Geolocator();

try{ Geoposition pos = await geo.GetGeopositionAsync();

double longitude = pos.Coordinate.Point.Position.Longitude; double latitude = pos.Coordinate.Point.Position.Latitude; double altitude = pos.Coordinate.Point.Position.Altitude; double accuracy = pos.Coordinate.Accuracy; DateTimeOffset timestamp = pos.Coordinate.Timestamp; }catch (Exception ex){ // Handle errors like unauthorized access to location services}

Figure 4 Getting Geoposition

In some scenarios an app still needs the ability to continue to

perform certain tasks, even if the app isn’t running.

Page 51: MSDN September 2014

MS Wordcompatible

Create Adobe 1D and 2D 2D and 3Dcharting

Untitled-4 1 7/29/14 1:01 PM

Page 52: MSDN September 2014

msdn magazine42 Geofencing

is the TaskEntryPoint property that takes the full name of the background task class in a string, including the namespace.

Th e last piece of information defi nes the type of event for which you want to register. Th is is done by creating a trigger and using the SetTrigger method of the BackgroundTaskBuilder. Every background task can have just a single trigger. If you want to use the same back-ground task for multiple triggers, you must create and register multiple background tasks. In order to track geofence changes, create a LocationTrigger instance and pass in a LocationTriggerType.Geofence enum value into the constructor. Currently geofencing is the only location-based trigger off ered in Windows. Th e end result is that the Run method of the IBackgroundTask you created will be called every time there’s a change to the state of a registered geofence. Figure 7 demonstrates how to register a geofence background task.

Th e fi nal step to enable your app to run background tasks is to add a Background Task declaration in the package appxmanifest. Inside the appxmanifest designer, select the Declarations tab, select Background Task from the Add Declarations dropdown, then click the Add button. In the details pane, select Location as the property and for the Entry point, put the classname of the TaskEntryPoint of

your BackgroundTaskBuilder. Once you do this, you’ll see a red “X” on the Application tab. Some background tasks require your app to be added to the lock screen in order for the tasks to run, and a location background task is one such task. Th e fi rst step is to set the Lock screen notifi cations on the Application pane to either Badge or Badge and Tile Text. Th e next step is for the user to add the app to his lock screen. Th e BackgroundExecution Mananger.Request-AccessAsync method discussed earlier will add the app to the lock screen if the user approves it. However, you need to write code to notify the user in the event the user removes the app from the lock screen at a later date, because Windows only prompts the user to add the app a single time.

Your app will now respond to geofence state changes in the background. It’s important to remember that this will take place even if your app is currently running, so the workfl ow of your app should take that into consideration if you’re also monitoring geofences in the foreground for UI updates.

For a deeper description of background tasks in Windows 8.1, please refer to “Supporting Your App with Background Tasks (XAML)” at bit.ly/1i9AH8X.

Wrapping UpGeofences add a new dynamic to any location-aware app, by letting your app respond to changes in proximity to predefi ned GPS coor-dinates. Th is allows you to easily provide hot spots your app can interact with around the globe. Not only can your app respond to these geofences when it’s running, but by utilizing background tasks it can still respond to them when the app has been suspended or isn’t even running. With smaller GPS-enabled devices becoming ever more popular, adding location-aware features to your app can provide a great UX, and I, for one, can’t wait to see what gets created next.

TONY CHAMPION is president of Champion DS, is a Microsoft MVP, and is active in the community as a speaker, blogger, and author. He maintains a blog at tonychampion.net and can be reached at [email protected].

THANKS to the following Microsoft technical expert for reviewing this article: Robert Green

private async void RegisterBackgroundTask(object sender, RoutedEventArgs e){ BackgroundAccessStatus accessStatus = await BackgroundExecutionManager.RequestAccessAsync();

if(accessStatus == BackgroundAccessStatus.AllowedMayUseActiveRealTimeConnectivity || accessStatus == BackgroundAccessStatus.AllowedWithAlwaysOnRealTimeConnectivity) {

BackgroundTaskBuilder taskBuilder = new BackgroundTaskBuilder(); taskBuilder.Name = "MyGeoBackground"; taskBuilder.TaskEntryPoint = "WindowsRuntimeComponent1.MyBackgroundTask";

LocationTrigger trigger = new LocationTrigger(LocationTriggerType.Geofence);

taskBuilder.SetTrigger(trigger);

taskBuilder.Register(); }

}

Figure 7 Register Background Task

void Current_GeofenceStateChanged(GeofenceMonitor sender, object args){ IReadOnlyList<GeofenceStateChangeReport> reports = GeofenceMonitor.Current.ReadReports();

foreach (GeofenceStateChangeReport report in reports) { switch (report.NewState) { case GeofenceState.Entered: // Handle entered state break; case GeofenceState.Exited: // Handle exited state break; case GeofenceState.Removed: if (report.RemovalReason == GeofenceRemovalReason.Used) { // Removed because it was single use } else { // Removed because it was expired } break; } }}

Figure 5 GeofenceStateChanged Event Handler

public sealed class MyBackgroundTask : IBackgroundTask{ public void Run(IBackgroundTaskInstance taskInstance) { BackgroundTaskDeferral deferral = taskInstance.GetDeferral();

var reports = GeofenceMonitor.Current.ReadReports();

foreach (var report in reports) { // Handle each report }

deferral.Complete(); }}

Figure 6 Background Task

Page 53: MSDN September 2014

Choosing a software development kit for your application can be a dif cult task. You must navigate a harmony of features, ease of use, support, cost and more in an equally hard-to-balance time frame. LEADTOOLS is the World Leader in Imaging SDKs and there are many reasons why.

Unparalleled ExperienceSince 1990, LEAD Technologies has been supply-ing imaging technology to software developers, integrators, contractors and solution providers throughout the United States government, military and most Fortune 1000 companies. LEAD’s agship SDKs, LEADTOOLS, are the most compre-

hensive and widely used imaging toolkits and are regarded as the gold standard across the globe. Any programmer writing an application for document, medical, multimedia, raster or vector imaging can bene t from the vast development experience packed into the millions of lines of code that comprise LEADTOOLS.

One Stop ShopIf you could summarize LEADTOOLS in one word it would probably be comprehensive. Why? It boasts the most imaging categories on the widest gamut of development platforms including .NET, Win32/64, WinRT, Windows Phone, HTML5/JavaScript, iOS, OS X, Android, Linux and more. With LEADTOOLS, you will be able to create astonishing applications featuring OCR, Forms, Barcode, PDF, DICOM, PACS, Image Processing, MPEG-2 Transport Stream, Multimedia Playback/Capture/Conversion and much more on virtually any platform you can imagine.

Tomorrow’s Technology TodayLEAD Technologies is always at the forefront of imaging technology. This means that you can rest assured that when new standards and development platforms are released that LEADTOOLS will have something for you. LEAD also forms strategic partnerships with customers looking for tools targeting cutting edge technology that provide a dual bene t of a custom-tailored solution and expedited time-to-market.

Personal TouchWe software developers sometimes get a bad rap as being anti-social cave dwellers, but we’re people too! LEAD Technologies gets that and has utilized the customer feedback and suggestions over the decades to make LEADTOOLS incredibly programmer-friendly. On top of that, free technical support over email, chat and phone is available and LEAD’s developer support team loves to help you get the most out of LEADTOOLS with custom-made example projects and pointers to help you along the way.

MSDN Magazine Vendor Pro le

Best of the Best: LEADTOOLS Imaging SDKs

To learn more please visit our website

VPmagazine

MSDN MAGAZINE VENDOR PROFILE

www.leadtools.com

Untitled-8 1 8/7/14 1:24 PM

Page 54: MSDN September 2014

msdn magazine44

Welcome back to my series on Unity. In the fi rst article, I covered some Unity basics and architecture. In this article, I’m going to explore 2D in Unity, which builds upon the 2D support Unity added in version 4.3. You could do 2D in Unity before 4.3, but the process was quite painful without a third-party toolkit. What I want is to just drag and drop an image into my scene and have it appear and work as I’d expect via a drag/drop interface. Th at’s some of what Unity 4.3 brings to the table and in this article, I’ll discuss more of its features while developing a basic 2D platformer game to learn some essential Unity concepts.

2D in UnityTo get 2D support in Unity, when creating a new project you select 2D from the dropdown in the new project dialog. When you do,

project defaults are set to 2D (viewed under Edit | Project Settings | Editor) and any images imported into your project are brought in as sprites as opposed to just textures. (I’ll cover this in the next section.) Also, the scene view defaults to 2D mode. Th is really just provides a helper button that fi xes you to two axes during scene development, but has no eff ect in your actual game. You can click it at any time to pop in and out of 2D working mode. A 2D game in Unity is really still a 3D environment; your work is just con-strained to the X and Y axes. Figure 1 and Figure 2 show the 2D mode selected and not selected. I have the camera highlighted so you can see an outline of the camera’s viewing area, but note that it looks out into space as a rectangle shape.

Th e highlighted camera is set up as an orthographic camera, one of two camera modes in Unity. Th is camera type, which is commonly used in 2D, doesn’t scale objects further away as your eyes would see them; that is, there’s no depth from the camera position. The other camera type is perspective, which shows objects as our eyes see them, with depth. Th ere are various reasons to use one camera type instead of the other, but in general, choose

UN IT Y

Developing Your First Game with Unity and C#, Part 2Adam Tuliper

This article discusses:• Working with 2D in Unity

• Sprites

• Common functionality, including colliders, score-tracking and animation

• Creating prefabs for reuse

Technologies discussed:Unity, C#, Microsoft .NET Framework

Code download available at:bit.ly/UnityPlatformer

A 2D game in Unity is really still a 3D environment; your work is just constrained to the X and Y axes.

Page 55: MSDN September 2014

45September 2014msdnmagazine.com

perspective if you need visual depth, unless you want to scale your objects accordingly. You can change the mode simply by selecting the camera and changing the projection type. I recommend trying this out and seeing how your camera’s viewing area changes when you start moving objects further away into the Z axis. You can change the default behavior mode at any time, which aff ects only future importing of images into your project.

If you have an existing project in Unity or aren’t sure if you’ve selected 2D from the project dialog, you can set your project defaults for 2D by going to Edit | Project Settings | Editor; otherwise, you’ll have to manually set the texture type on every 2D image you import, which is a bit tedious if you have a lot of artwork.

It’s All About the SpriteWhen 3D is selected as the default behavior mode, images are recognized as type Texture. You can’t drag a texture into your scene; a tex-ture must be applied to an object. Th is way isn’t much fun to create 2D games. I want to just drag and drop an image and have it appear in my scene. If your default behavior mode is 2D, though, things get easy. When I drag and drop an image into Unity, it’s now recognized as type Sprite.

Th is allows you to simply drag and drop your artwork into Unity, and then from Unity drag and drop it into your scene to build out your game. If you have artwork that looks small, rather than rescale it everywhere you can just decrease the Pixels To Units value. Th is is a very common operation in Unity for both 2D and 3D and typically is more performant than scaling objects via its transform’s scale property.

When dropping objects, you might notice that one object ends up on top of another. Unity creates a series of vertices behind the scenes, even for 2D images, so the drawing order can differ on various parts of the images. It’s always best to explicitly specify the z-order of your images. You can do this via three methods, listed in the order Unity draws your sprites:

1. Setting the “Sorting Layer” property in the Sprite Renderer.

2. Setting the “Order in layer” property, also on the Sprite Renderer.

3. Setting the Transform’s Z position value.

Th e sorting layer takes priority over all, followed by order in layer, which in turn takes priority over the transform’s z value.

Sorting layers draw in order of defi nition. When you add other layers (in Edit | Project Settings | Tags and Layers), Unity draws out any object it fi nds on the Default layer fi rst (then Order in Layer takes over, and then the Transform’s Z position value) , then Background, then Platforms, and so forth. So you can easily fix overlapping images by setting them to the Platforms layer and giving the one you want on top an Order in Layer of 1, so it will be drawn aft er anything with Order in Layer of 0.

Common FunctionalityFigure 3 shows a level containing some platforms and background images that were built out by dragging and dropping and setting the sorting layers.

As it stands now, it looks like a game, but it doesn’t act like one. At a minimum, it needs a number of features to be a functional game. I’ll discuss several of these in the following sections.

Keyboard, Mouse and Touch Movement In Unity, keyboard, mouse, accelerometer and touch are read through the input

Figure 1 2D Mode Selected—Camera Has Focus

Figure 2 2D Mode Not Selected—Camera Has Focus

When 3D is selected as the default behavior mode, images are recognized as type Texture.

Page 56: MSDN September 2014

msdn magazine46 Unity

system. You can read input movement and mouse clicks or touch easily using a script like the following on the main player (I’ll build on this script shortly.):

void Update(){

// Returns -1 to 1 var horizontal = Input.GetAxis("Horizontal");

// Returns true or false. A left-click // or a touch event on mobile triggers this. var firing = Input.GetButtonDown("Fire1"); }

If you check Edit | Project Settings | Input, you can see the default inputs (Unity gives you a bunch that are there in every new project) or set new ones. Figure 4 shows the defaults for reading horizontal movement. Th e “left ” and “right” settings represent the left and right arrow keys but notice also that “a” and “d” are used for horizontal movement. Th ese can map to joystick inputs. You can add new ones or change the defaults. Th e Sensitivity fi eld controls how fast Unity will go from 0 to 1 or -1. When the right arrow is pressed, the fi rst frame might yield a value of .01 and then scale pretty quickly up to 1, although you can adjust the speed to give your character instant horizontal speed or movement. I’ll show you the code shortly for applying these values to your game

objects. Th ere’s no actual GameObject com-ponent required for reading these values; you simply use the Input keyword in your code to access the functionality for reading input. Input, as a general rule, should be read in the Update function as opposed to FixedUpdate to avoid missing input events.

Linear Movement Th ings need to be able to move. If this is a top-down game, gravity typically isn’t important. If it’s a platformer, gravity is exceedingly important. In either case, object collision detection is critical. Here are the basic rules. A Rigidbody2D or RigidBody (used for 3D) component added to a game object will automatically give that compo-nent mass and make it understand gravity and receive forces. According to Wikipedia, “In physics, a rigid body is an idealization of a solid body in which deformation is neglected. In other words, the distance between any two given points of a rigid body remains constant in time regardless of external forces exerted on it.” Th e same principle applies in games. Adding a rigid body lets you make calls like the ones in Figure 5.

As a general rule, linear movement should happen via Update and accelerated

movement via FixedUpdate. If you’re a beginner, it might seem con-fusing what to use when, and, in fact, linear movement will work

in either function. But you’ll get better visual results by following this rule.

Collision Detection An object gets its mass from its RigidBody component, but you also need to tell Unity how to handle collisions with this object. The size and shape of your artwork or models doesn’t matter here, although scaling does affect physics on the object itself. What matters is the size and shape of the collider com-ponent, which is simply a defined region around, on or within the object that you want Unity to detect another object con-tacting. Th is is what enables scenarios like detecting when you enter the region of an idle zombie or boulders that go bouncing down a mountain side on approach.

Th ere are variously shaped colliders. A collider for 2D can be a circle, edge, poly-gon or box. Box colliders are great for objects shaped like squares or rectangles, or when you simply want to detect colli-sions in a square area. Th ink of a platform you can stand on—this is a good example of a box collider. Simply adding this com-ponent to your game object allows you to

Figure 3 A Game Level

Figure 4 Horizontal Input Defaults

Page 57: MSDN September 2014

Untitled-2 1 6/3/14 12:54 PM

Page 58: MSDN September 2014

msdn magazine48 Unity

take advantage of physical collisions. In Figure 6, I added a circle collider and rigid body to the character and a box collider to the platform. When I click play in the Editor, the player immediately drops onto the platform and stops. No code required.

You can move and resize the region a collider covers by changing its properties on the collider component. By default, objects with colliders don’t pass through each other (except for triggers, which I’ll cover next). Collisions require collider components on both game objects and at least one object has to have a RigidBody component, unless it’s a trigger.

If I want Unity to call my code when this collision instance fi rst happens, I simply add the following code to a game object via a script component (discussed in the previous article):

void OnCollisionEnter2D(Collision2D collision){ // If you want to check who you collided with, // you should typically use tags, not names. if (collision.gameObject.tag == "Platform") { // Play footsteps or a landing sound. }}

Triggers Sometimes you want to detect a collision but don’t want any physics involved. Th ink of a scenario like picking up treasure in a game. You don’t want the coins to be kicked out in front of the player when it approaches; you want the coins to be picked up and not interfere with player movement. In this case, you use a collider called a trigger, which is nothing more than a collider with the IsTrigger checkbox enabled. Th at turns off the physics and Unity will only call your code when object A (which contains a collider) comes within the region of object B (which also has a collider). In this case, the code method is OnTriggerEnter2D instead of OnCollisionEnter2D:

void OnTriggerEnter2D(Collider2D collider){ // If the player hits the trigger. if (collider.gameObject.tag == "Player") { // More on game controller shortly. GameController.Score++; // You don’t do: Destroy(this); because 'this' // is a script component on a game object so you use // this.gameObject or just gameObject to destroy the object. Destroy(gameObject); }}

Th e thing to remember is that with triggers, there’s no physical interaction, it’s basically just a notifi cation. Triggers do not require a Rigidbody component on the game object, either, because no force calculations are taking place.

One thing that oft en trips up new developers is the behavior of rigid bodies when you add colliders to them. If I have a circle collider on my object and I put this object on an inclined plane (as indicated by its collider shape), it starts to roll, as Figure 7shows. Th is models what you’d see in the physical world if a wheel was set on an incline. Th e reason I don’t use a box collider for my character is because a box has edges that can get caught up when moving over other colliders’ edges, yielding a less smooth expe-rience. A circle collider makes this smoother. However, for times when a smooth rotation isn’t acceptable, you can use the Fixed Angle setting on the Rigidbody component.

Audio To hear sound, you need an Audio Listener component, which already exists on any camera by default. To play a sound, simply add an Audio Source component to a game object and set the audio clip. Unity supports most major audio formats and will

void FixedUpdate(){ // -1 to 1 value for horizontal movement float moveHorizontal = Input.GetAxis("Horizontal"); // A Vector gives you simply a value x,y,z, ex 1,0,0 for // max right input, 0,1,0 for max up. // Keep the current Y value, which increases for each interval because of gravity. var movement = new Vector3(moveHorizontal * _moveSpeed, rigidbody.velocity.y, 0); rigidbody.velocity = movement; if (Input.GetButtonDown("Fire1")) { rigidbody.AddForce(0, _jumpForce, 0); }}

Figure 5 Adding Movement and Velocity

Figure 6 Adding Colliders

An object gets its mass from its RigidBody component, but you

also need to tell Unity how to handle collisions with this object.

Figure 7 Using a Circle Collider for Smooth Movement

Page 59: MSDN September 2014

Untitled-1 1 11/26/12 3:02 PM

Page 60: MSDN September 2014

msdn magazine50 Unity

encode longer clips to MP3. If you have a bunch of audio sources with clips assigned in the Unity Editor, keep in mind they’ll all be loaded at run time. You can instead load the audio via code located in a special resource folder and destroy it when done.

When I imported audio into my project, I kept it as a WAV fi le, which is uncompressed audio. Unity will re-encode your longer audio to optimize it, so always use the best quality audio you have. Th is is especially true for short fi les like sound eff ects, which Unity won’t encode. I also added an Audio Source component to my main camera, though I could’ve added it to any game object. I then assigned the Adventure audio clip to this Audio Source compo-nent and checked off Loop, so it constantly loops. And in three simple steps, I now have background music when my game plays.

GUI/Heads-Up Display A GUI system can comprise many things in a game. It may involve the menu system, the health and score display, weapons inventory, and more. Typically, a GUI sys-tem is what you see on the screen that stays put no matter where the camera is looking (although it doesn’t have to). Th e Unity GUI functionality is currently undergoing a complete revision and the new uGUI system is coming out in Unity 4.6. Because that isn’t released yet, I’ll simply discuss some of the basic func-tionality here, but check out my channel9 blog for details of the new GUI system at channel9.msdn.com/Blogs/AdamTuliper.

To add simple display text to the screen (for example, score: 0), I clicked on Game Object | Create Other | GUI Text. Th is option no longer exists in Unity 4.6, so you’ll want to watch that video on uGUI I mentioned. You can still add a GUI Text component to the game object in 4.6 by clicking the Add Component button; it’s

just missing from the Editor menu. With the existing (legacy) Unity GUI system, you can’t see your GUI objects in the scene view, only in the Game view, which makes layout creation a little weird. If you like, you can use pure code to set up your GUI, and there’s a GUILayout class that lets you track widgets automatically. But I prefer a GUI system where I can click and drag and work with easily, which is why I fi nd uGUI far superior. (Before uGUI, the leader in this area was a pretty solid third-party product called NGUI, which was actually used as the initial code base for uGUI.)

Th e easiest way to update this display text is to simply search for or assign in the Editor a reference to the GUI Text game object, and treat it like a label in .NET and update its text property. Th is makes it easy to update the screen GUI text:

void UpdateScore(){ var score = GameObject.Find("Score").GetComponent<GUIText>(); score.text = "Score: 0";}

Th is is a slightly shortened example. For performance, I’d actually cache a reference to the GUIText component in the Start method so as to not query for it every method call.

Score Tracking Tracking scores is easy. You simply have a class that exposes a public method or properties on which to set a score. It’s common in games to have an object called a Game Controller that acts as the game’s organizer. The Game Controller can be responsible for triggering game saves, loading, score keeping and more. In this example, I can simply have a class that exposes a score variable, as shown in Figure 8. I assign this component to an empty game object, so it’s available when the scene loads. When the score is updated, the GUI is in turn updated. Th e _scoreText variable is assigned in the Unity editor. Just drop any GUIText game object onto this exposed fi eld or use the search widget where this script component exposes the Score Text variable in the editor.

I can then simply update (in this example) the mushroom’s trigger code as follows to increment the score with each pickup:

void OnTriggerEnter2D(Collider2D collider){ if (collider.gameObject.tag == "Player") { GameController.Score++; Destroy(gameObject); }}

Animations Just as with XAML, animations are created by carry-ing out various actions in key frames. I could easily devote a whole

article just to animations in Unity, but I’ll keep it brief here because of space. Unity has two animation systems, the legacy sys-tem and the newer Mecanim. Th e legacy system uses animation(.ani) fi les, while Mecanim uses states to control which an-imation fi le plays.

Animation in 2D uses Mecanim by default. The simplest way to create an animation is to drag and drop images into your scene and let Unity create the anima-tions for you. To start, I drag some single sprites into Unity and in turn Unity cre-ates several things for me. First, it creates

public class GameController : MonoBehaviour{ private int _score;

// Drag a GuiText game object in the editor onto // this exposed field in the Editor or search for it upon startup // as done in Figure 12. [SerializeField] private GUIText _scoreText;

void Start() { if (_scoreText == null) { Debug.LogError("Missing the GuiText reference. "); } }

public int Score { get { return _score; } set { _score = value; // Update the score on the screen _scoreText.text = string.Format("Score: {0}", _score); } }}

Figure 8 Creating the _scoreText Variable

Figure 9 The Animator Component Pointing to a Controller

Page 61: MSDN September 2014

Untitled-1 1 4/1/14 10:47 AM

Page 62: MSDN September 2014

msdn magazine52 Unity

a game object with a sprite renderer component to draw the sprites. Then it creates an animation file. You can see this by going to Window | Animator and highlighting your game object. Th e anima-tor shows the animation fi le assigned, which, in my case, contains six key frames because I dropped six images into my scene. Each key frame controls one or more parameters on some component; here, it changes the Sprite property of the Sprite Renderer compo-nent. Animations are nothing more than single images showing at some rate that makes the eye perceive movement.

Next, Unity creates an Animator component on the game object, as shown in Figure 9.

This component points to a simple state machine called an animation controller. Th is is a fi le Unity creates, which just shows

the default state; in other words, it’s always in the “idle” state as that’s the only state available. Th is idle state does nothing more than point to my animation fi le. Figure 10 shows the actual key frame data on the time line.

Th is might seem like a lot to go through just to play an animation. Th e power of state machines, though, is that you can control them by setting simple variables. Remember, a state does nothing more than point to an animation fi le (although in 3D you can get fancy and do things like blend animations together).

I then took more images to make a run anima-tion and dropped them onto my Yeti game object.

Because I already have an animator compo-nent on the game object, Unity just creates a new animation fi le and adds a new state called “run.” I can simply right-click on idle and cre-ate a transition to run. Th is creates an arrow between the idle and run states. I can then add a new variable called “Running,” which is simple to use—you just click on the arrow between the states and change the condition to use the variable, as shown in Figure 11.

When Running becomes true, the idle animation state changes to the run animation state, which simply means the run animation fi le plays. You can control these variables in code very easily. If you want to start your

run animation by triggering the run state when the mouse button is clicked, you can add the code shown in Figure 12.

In my example, I used single sprites to create an animation. It’s pretty common, though, to use a sprite sheet—a single image fi le with more than one image in it. Unity supports sprite sheets, so it’s a matter of telling Unity how to slice up your sprite, and then dropping those slices into your scene. The only steps that are diff erent are changing Sprite Mode from Single to Multiple on the sprite properties, and opening the Sprite Editor, which can then automatically slice the sprite and apply the changes, as shown in Figure 13. Finally, you expand the sprite (there’s a little arrow on the sprite’s icon in the project view), highlight the resulting sprites, and drop them into your scene as you did earlier.

Animation can be a complicated subject until you learn the system. For more information, check out my channel9 blog or one of the many fi ne resources on Unity’s learning site.

The End of the Level When the player gets to the end of the level, you can simply have a collider that’s set to a trigger and

Figure 10 The Idle Animation Data

Figure 11 Changing from the Idle to Run States

private Animator _animator;void Awake(){ // Cache a reference to the Animator component from this game object _animator = GetComponent<Animator>();}void Update(){

if (Input.GetButtonDown("Fire1")) { // This will cause the animation controller to // transition from idle to run states _animator.SetBool("Running", true); }}

Figure 12 Changing State with Code

See this project built out: channel9.msdn.com/Events/Build/2014/2-503

Microsoft Virtual Academy - Developing 2D & 3D Games with Unity for Windows: aka.ms/UnityMVA

Adam’s Channel 9 Blog: aka.ms/AdamChannel9

Unity Resources: unity3d.com/learn

Additional Learning

Page 63: MSDN September 2014

53September 2014msdnmagazine.com

allow the player to hit that zone. When it does, you just load another level or reload the current one:

void OnTriggerEnter2D(Collider2D collider){ // If the player hits the trigger. if (collider.gameObject.tag == "Player") { // Reload the current level. Application.LoadLevel(Application.loadedLevel); // Could instead pass in the name of a scene to load: // Application.LoadLevel("Level2"); }}

The game object and its respective properties are shown in Figure 14. Note the collider’s height is high enough that the player can’t jump over it and also that this collider is set as a trigger.

Game Play In a simple 2D game like this, the fl ow is pretty straightforward. Th e player starts. Gravity on the rigid body makes the player fall. Th ere’s a collider on the player and on the platform, so the player stops. Keyboard, mouse, and touch input are read

and moves the player. Th e player jumps between platforms by applying rigidbody.AddForce to make it jump, and moves left or right by reading Input.GetAxis-(“Horizontal”) and applying it to the rigidbody.velocity. Th e player picks up mushrooms, which are just colliders set as triggers. When the player touches them, they

increment the score and destroy themselves. When the player fi nally makes it to the last sign, there’s a collider/trigger that just reloads the current level. An additional to-do item here would be to add a large collider under the ground to detect when the player falls off the platform and simply reload the level then, as well.

Prefabs Reuse is important in coding, as well as in design. Once you assign several components and customize your game objects, you’ll oft en want to reuse them across the same scene or even multiple scenes or games. You can create another instance of a game object in your scene, but you can also create an instance of a prefab that doesn’t yet exist in your scene. Consider platforms and their colliders. If you want to reuse them across scenes, well, currently, you can’t. But by creating prefabs, you can. Just drag any game object from the hierarchy back into the project folder and a new fi le is created with the extension .prefab that includes any child hierarchies. You can now drag this fi le into your scenes and reuse it. Th e original game object turns blue to note it’s now con-nected to a prefab. Updating the .prefab fi le updates all instances in your scenes and you can also push changes from a modifi ed scene prefab back down to the .prefab fi le, as well.

Clicking on the prefab displays the game objects it contains, as shown in Figure 15. If you make

changes here, all instances in your scene will be updated.

Wrapping UpTh ere are a number of common operations performed across games. In this article, I covered the basics of a platformer game that uses colliders, rigid bodies, animations, score-keeping, basic GUI text and reading user input to apply force to move the player. Th ese building blocks can be reused across a variety of game types. Stay tuned for a discussion of 3D coming in my next installment!

ADAM TULIPER is a senior technical evangelist with Microsoft living in sunny Southern California. He’s an indie game dev, co-admin of the Orange County Unity Meetup, and a pluralsight.com author. He and his wife are about to have their third child, so reach out to him while he still has a spare moment at adamt@microsoft .com or on Twitter at twitter.com/AdamTuliper.

THANKS to the following technical experts for reviewing this article: Matt Newman (Subscience Studios), Tautvydas Žilys (Unity)

Figure 15 Viewing the Contents of a Prefab

Figure 13 Creating a Sprite Sheet

Figure 14 The Game Object and Its Properties

Page 65: MSDN September 2014

Untitled-2 3 8/5/14 11:39 AM

Page 66: MSDN September 2014

msdn magazine56

Authentication and authorization are cornerstones of application security. Authentication establishes the identity of a user by validating the credentials provided, while authorization determines whether a user is allowed to perform a requested action. A secured Web API authenticates requests and authorizes access to the resource requested based on the identity established.

You can implement authentication in ASP.NET Web API using the extensibility points available in the ASP.NET Web API pipe-line, as well as using options provided by the host. With the fi rst version of ASP.NET Web API, a common practice is to use an authorization fi lter or an action fi lter to implement authentica-tion. ASP.NET Web API 2 introduces a new authentication fi lter dedicated to the process. This new extensibility point allows authentication and authorization concerns to be cleanly separated. In this article, I’m going to introduce you to these two security fi l-ters and show you how to use them to implement authentication and authorization as separate concerns in ASP.NET Web API.

Options for Implementing Security AspectsAuthentication and authorization in ASP.NET Web API can be implemented using the extensibility points off ered by the host, as well as those available in the ASP.NET Web API pipeline itself. Host-based options include HTTP modules and OWIN middle-ware components, while ASP.NET Web API extensibility options consist of message handlers, action fi lters, authorization fi lters, and authentication fi lters.

Host-based options integrate well into the host pipeline and are capable of rejecting invalid requests earlier in the pipeline. Th e ASP.NET Web API extensibility options, on the other hand, off er a fi ner level of control over the authentication process. Th at is, you’ll be able to set diff erent authentication mechanisms for diff er-ent controllers and even diff erent action methods. Th e trade-off is better integration with the host and early rejection of bad requests versus the authentication granularity. Apart from these general characteristics, each option has its own pros and cons, as I’ll cover in the sections that follow.

HTTP Module Th is is an option for Web APIs running on IIS. HTTP modules allow security code to execute early as part of the IIS pipeline. Th e principal established from an HTTP module is available to all components, including the IIS components running later in the pipeline. For example, when the principal is established by an HTTP module in response to the AuthenticateRequest event, the username of the principal gets logged correctly in the cs-user-name fi eld in IIS logs. Th e biggest drawback with HTTP modules is the lack of granularity. HTTP modules run for all requests coming into the application. For a Web application with diff erent capabilities such as HTML markup generation, Web APIs and so on, having an HTTP module enforcing authentication in one way is generally not a fl exible-enough approach. Another disadvantage with using an HTTP module is the dependency on the host—IIS, in this case.

OWIN Middleware Th is is another host-related option, avail-able with OWIN hosts. ASP.NET Web API 2 fully supports OWIN. Perhaps the most compelling reason for using OWIN middleware for security is that the same middleware can work across diff erent frameworks. Th is means you can use multiple frameworks such as ASP.NET Web API, SignalR and so on in your application, yet use common security middleware. However, OWIN middleware’s minimal granularity could be a shortcoming, because OWIN mid-dleware runs in the OWIN pipeline and gets invoked typically for all requests. Also, OWIN middleware can be used only with OWIN-compatible hosts, although this dependency is comparatively better than taking dependency on a specifi c host/server such as IIS, as is the case with HTTP modules. A point worth noting here is

A S P. N E T

ASP.NET Web API Security FiltersBadrinarayanan Lakshmiraghavan

This article discusses:• Options for implementing authentication and authorization

• Getting authentication and authorization fi lters to work together

• Creating an authentication fi lter

• Using an authorization fi lter

• Filter overrides

Technologies discussed:ASP.NET Web API, IIS, OWIN

Page 67: MSDN September 2014

57September 2014msdnmagazine.com

that OWIN middleware can run in the (IIS-integrated) ASP.NET pipeline, thanks to the package Microsoft .Owin.Host.SystemWeb.

Message Handler An extensibility option provided by ASP.NET Web API, the greatest benefi t in using a message handler for security is it’s a concept of the ASP.NET Web API framework and, hence, doesn’t depend on the underlying host or server. Also, a message handler runs only for Web API requests. Th e downside of using a message handler is the lack of fi ner control. A message handler can be confi gured to run as a global handler for all requests or for a spe-cifi c route. For a given route, you can have multiple controllers. All these controllers and the action methods they contain must share the same authentication enforced by the message handler confi gured for that route. In other words, the lowest granularity for authentication implemented by a message handler is at the route level.

Action Filter Another extensibility option provided by ASP.NET Web API is the action filter. However, from the perspective of implementing authentication, it isn’t a viable option simply because it runs aft er the authorization fi lters are run in the ASP.NET Web API pipeline. For authentication and authorization to work cor-rectly, authentication must precede authorization.

Authorization Filter Yet another extensibility option provided by ASP.NET Web API is the authorization fi lter. One of the most common ways of implementing custom authentication for scenarios requiring more granularity than message handlers can off er is to use an autho-rization fi lter. Th e major problem in using an authorization fi lter for both authentication and authorization is that the order of execution of authorization fi lters isn’t guaranteed by ASP.NET Web API. Basi-cally, this means your authorization fi lter performing authorization could very well run before your authorization filter performing

authentication could run, making the authorization fi lter option equally unsuitable for authentication as the action fi lter option is.

Authentication Filter Th e focal point of this article, this is the newest extensibility option available with ASP.NET Web API 2. Authentication fi lters run aft er message handlers but before all other fi lter types. Th ere-fore, they’re a better choice for implementing authentication concerns. Most important, authentication fi lters run before authorization fi lters. By using a fi lter that specifi cally targets either authentication or autho-rization, you can separate authentication and authorization concerns.

Moreover, authentication fi lters off er a level of control or gran-ularity that makes them particularly useful. Take the case of a Web API designed to be consumed by both native mobile applications and browser-based AJAX applications. Th e mobile app might pres-ent a token in the HTTP Authorization header while the AJAX app might use an authentication cookie as a credential. Further, suppose a subset of the API is sensitive and available only for the native mobile app and you want to ensure the action methods are accessed only by presenting a token and not a cookie (cookies are susceptible to cross-site request forgery [XSRF], while a token in an HTTP Authorization header is not). In this case, authentication must hap-pen at a fi ner level of granularity than is possible with a host-based option or even a message handler. An authentication fi lter fi ts this use case perfectly. You can apply the authentication fi lter based on the token on all those controllers or action methods where they must be used and the authentication fi lter based on the cookie in other places. Suppose, in this scenario, you have a few common action methods and you want them accessible through either a token or a cookie. You can simply apply both the cookie and token authentica-tion fi lters on those common action methods and one of the fi lters

will be able to successfully authenticate. Th is kind of control is the biggest value authentication fi lters bring to the table. When granular control of authentication is required, the right approach is to implement authen-tication concerns through an authentication fi lter and authorization concerns through an authorization fi lter.

It’s worth mentioning here that the out-of-box authentication fi lter, HostAuthenticationFilter, enables ASP.NET Web API authentication via OWIN middle-ware. While OWIN authentication middleware runs in a pipeline and tries to “actively” authenticate the incoming requests, it can also be confi gured to authenticate the request “passively,” only when asked. Th e HostAuthen-ticationFilter allows the running of passive OWIN authentication middleware by name later in the Web API pipeline. Th is approach enables authentication code that can be shared across frameworks (including the OWIN authentication middleware Microsoft provides) while still allowing per-action granularity for authentication.

Although you can mix host-level authentication with more-granular Web API pipeline-based authen-tication, you have to carefully consider how host-level authentication can aff ect Web API authentication. For example, you could have cookie-based authentication middleware at the host-level meant to be used with other frameworks, say ASP.NET MVC, but letting Web Figure 1 Security Filters in ASP.NET Web API Pipeline

AuthenticationFilter

Valid Credentials Present

Request withValid Credential

Response Message

context.Principal Is Set toan Authenticated Principal

Successfully Authorizes,Because Identity Is Authentic

Action Method

Action Method Runs andProduces a Response

AuthenticationFilter

No Action Taken Response Message

AuthorizationFilter

Invalid Credentials Present

Request withInvalid Credential

Unauthorized Responsewith Challenge

context.ErrorResult Is Setto UnauthorizedResult

Action Method

Does Not Execute

AuthenticationFilter

Adds Challenge Does Not Execute

401

Credentials Absent

Request withNo Credential

Unauthorized Responsewith Challenge

No Action TakenRejects the Request for the

Lack of Authenticated Principal

Action Method

Does Not Execute

AuthenticationFilter

Adds Challenge

AuthorizationFilter

Page 68: MSDN September 2014

msdn magazine58 ASP.NET

API use the cookie-based principal makes it susceptible to attacks such as XSRF. To help in such situations, the SuppressDefaultHost-Authentication extension method enables Web API to ignore any authentication confi gured at the host level. Th e default Web API Visual Studio template has cookies enabled at the host level, and uses bearer tokens at the Web API level. Because cookies are enabled at the host level and require XSRF mitigation, the template also uses SuppressDefaultHostAuthentication to prevent the Web API pipeline from using the cookie-based principal. Th is way, Web API will use only the token-based principal and you don’t need to build mechanisms for Web API to defend against XSRF attacks.

Making Authentication and Authorization Filters Work in TandemIn the ASP.NET Web API pipeline, authentication fi lters run fi rst—followed by the authorization fi lters— for the simple reason that authorization depends on the identity established, which is the out-come of authentication. Here’s how you can design the authentication and authorization fi lters to work together to secure ASP.NET Web API.

Th e basic tenet of this design is giving the authentication fi lter the one and only responsibility of validating the credential, and not having it deal with any other concerns. For example, the authen-tication fi lter will not reject a request with the 401 Unauthorized status code if credentials aren’t present. It simply doesn’t establish an authenticated identity, and leaves the question of how to handle anonymous requests to the authorization stage. An authentication fi lter basically takes three types of actions:

1. If the credential of interest isn’t present in the request, the fi lter does nothing.

2. If credentials are present and found to be valid, the fi lter establishes an identity in the form of an authenticated principal.

3. If credentials are present but found to be invalid, the fi lter notifi es the ASP.NET Web API framework by setting an error result, which basically results in an “unauthorized” response that gets sent back to the requestor.

If none of the authentication fi lters running in the pipeline can detect an invalid credential, the pipeline continues to run, even if an authenticated identity hasn’t been established. It’s up to the components running later in the pipeline to decide how to handle this anonymous request.

At the most fundamental level, an authorization fi lter simply checks whether the established identity is an authenticated identity. However, an authorization fi lter can also ensure that:

• Th e username of the authenticated identity is on the list of allowed users.

• At least one of the roles associated with the authenticated identity is on the list of allowed roles.

While the out-of-box authorization filter performs only the role-based access control as just described, a custom authorization fi lter that derives from the out-of-box authorization fi lter can per-form claims-based access control by checking the claims that are part of the identity established by the authentication fi lter.

If all the authorization fi lters are happy, the pipeline continues to execute and eventually the action method of the API con-troller generates a response for the request. If the identity isn’t

established or if there’s a mismatch in terms of the username or the role requirements, the authorization fi lter rejects the request with a 401 Unauthorized response. Figure 1 illustrates the part played by the two fi lters in three scenarios: credentials not present, invalid credentials present and valid credentials present.

Creating an Authentication FilterAn authentication fi lter is a class implementing the IAuthentication-Filter interface. Th is interface has two methods: AuthenticateAsync and ChallengeAsync, as shown by the following:

public interface IAuthenticationFilter : IFilter{ Task AuthenticateAsync(HttpAuthenticationContext context, CancellationToken cancellationToken); Task ChallengeAsync(HttpAuthenticationChallengeContext context, CancellationToken cancellationToken);}

Th e AuthenticateAsync method accepts HttpAuthentication-Context as an argument. Th is context is how the AuthenticateAsync method communicates the result of the authentication process back to the ASP.NET Web API framework. If the request message contains authentic credentials, the Principal property of the passed-in HttpAuthenticationContext object is set to the authen-ticated principal. If the credentials are invalid, the ErrorResult property of the HttpAuthenticationContext parameter is set to UnauthorizedResult. If the request message doesn’t contain the credential at all, the AuthenticateAsync method takes no action. The code in Figure 2 shows a typical implementation of the AuthenticateAsync method covering these three scenarios. Th e authenticated principal used in this example is a ClaimsPrincipal with just name and role claims.

You use the AuthenticateAsync method to implement the core authentication logic of validating the credentials in the request, and

public Task AuthenticateAsync(HttpAuthenticationContext context, CancellationToken cancellationToken){ var req = context.Request; // Get credential from the Authorization header (if present) and authenticate if (req.Headers.Authorization != null && "somescheme".Equals(req.Headers.Authorization.Scheme, StringComparison.OrdinalIgnoreCase)) { var creds = req.Headers.Authorization.Parameter; if(creds == "opensesame") // Replace with a real check { var claims = new List<Claim>() { new Claim(ClaimTypes.Name, "badri"), new Claim(ClaimTypes.Role, "admin") }; var id = new ClaimsIdentity(claims, "Token"); var principal = new ClaimsPrincipal(new[] { id });

// The request message contains valid credential context.Principal = principal; } else { // The request message contains invalid credential context.ErrorResult = new UnauthorizedResult( new AuthenticationHeaderValue[0], context.Request); } }

return Task.FromResult(0);}

Figure 2 The AuthenticateAsync Method

Page 69: MSDN September 2014

Untitled-2 1 3/27/14 12:42 PM

Page 70: MSDN September 2014

msdn magazine60 ASP.NET

the ChallengeAsync method to add the authentication challenge. An authentication challenge is added to a response when the status code is 401 Unauthorized, and to inspect the status code, you need the response object. But the ChallengeAsync method doesn’t allow you to inspect the response or set the challenge directly. In fact, this method executes before the action method, in the request process-ing part of the Web API pipeline. However, the parameter of the ChallengeAsync method HttpAuthenticationChallengeContext allows an action result object (IHttpActionResult) to be assigned to the Result property. The ExecuteAsync method of the action result object awaits the task producing the response, inspects the response status code, and adds the WWW-Authenticate response header. Th e code in Figure 3 shows a typical implementation of the ChallengeAsync method. In this example, I just add a hardcoded challenge. Th e ResultWithChallenge class is the action result class I created to add the challenge.

Th e following code shows the completed fi lter class: public class TokenAuthenticationAttribute : Attribute, IAuthenticationFilter{ public bool AllowMultiple { get { return false; } }

// The AuthenticateAsync and ChallengeAsync methods go here}

In addition to implementing the IAuthenticationFilter interface, I derive from Attribute so this class can be applied as an attribute at the class (controller) level or method (action method) level.

Thus, you can create an authentication filter with the single responsibility of authenticating a specifi c credential (a fi ctitious token in this example). An authentication fi lter has no authorization logic; its only purpose is to handle authentication: establishing an identity, if any, (while processing the request message) and return-ing a challenge, if any (while processing the response message). Authorization fi lters handle authorization concerns, such as check-ing whether the identity is an authenticated identity or whether it’s on the allowed list of users or roles.

Using an Authorization FilterTh e fundamental goal of using an authorization fi lter is to perform authorization—to determine whether a user should be allowed access to a requested resource. Web API provides an implementation of an authorization fi lter called AuthorizeAttribute. Applying this fi lter ensures the identity is an authenticated identity. You can also confi gure the authorize attribute with a list of specifi c usernames and the roles to allow. Th e code in Figure 4 shows the authorization fi lter applied at diff erent levels (globally, at the controller level and at the action method level), using diff erent attributes of the identity to authorize. Th e fi lter in this example globally ensures the identity is authenticated. Th e fi lter used at the controller level ensures the identity is authenticated and that at least one role associated with the identity is “admin.” Th e fi lter used at the action method level ensures the identity is authenticated and that the username is “badri.” One point to note here is that the authorization fi lter at the action method level also inherits the fi lters from the controller and global levels. Hence, for authorization to succeed all fi lters must pass: the username must be “badri,” one of the roles must be “admin” and the user must be authenticated.

Th e out-of-box AuthorizeAttribute is extremely useful, but if more customization is desired, you can sub-class it to implement additional authorization behavior. The following code shows a custom authorization fi lter:

public class RequireAdminClaimAttribute : AuthorizeAttribute{ protected override bool IsAuthorized(HttpActionContext context) { var principal = context.Request.GetRequestContext().Principal as ClaimsPrincipal; return principal.Claims.Any(c => c.Type == "http://yourschema/identity/claims/admin" && c.Value == "true"); }}

Th is fi lter simply checks for an “admin” custom claim, but you can use a principal and any other additional information from the HttpActionContext to perform custom authorization here.

In the fi rst version of ASP.NET Web API, custom authorization fi lters were oft en misused to implement authentication, but with ASP.NET Web API 2, authentication fi lters now have their own place in the pipeline and this helps the development of clean, modular code with authentication and authorization concerns clearly separated.

Filter OverridesAs I explained earlier, an authorization filter can be applied at the action method level, the controller level or globally. By specifying the Authorize fi lter globally, you can enforce authorization on all action method invocations across all controllers. If you want a few methods to be exempted from the globally confi gured check, it’s easier to accomplish this using the AllowAnonymous attribute.

Th e code in Figure 5 shows the use of the AllowAnonymous attribute at the controller level. Though the authorization filter is applied globally, the AllowAnonymous attribute used with PublicResourcesController exempts the requests coming to this controller from getting authorized.

AllowAnonymous provides a way a specifi c action can override authorization configured by a higher-level authorization filter.

public Task ChallengeAsync(HttpAuthenticationChallengeContext context, CancellationToken cancellationToken){ context.Result = new ResultWithChallenge(context.Result); return Task.FromResult(0);}

public class ResultWithChallenge : IHttpActionResult{ private readonly IHttpActionResult next;

public ResultWithChallenge(IHttpActionResult next) { this.next = next; }

public async Task<HttpResponseMessage> ExecuteAsync( CancellationToken cancellationToken) { var response = await next.ExecuteAsync(cancellationToken);

if (response.StatusCode == HttpStatusCode.Unauthorized) { response.Headers.WwwAuthenticate.Add( new AuthenticationHeaderValue("somescheme", "somechallenge")); } return response; }}

Figure 3 The ChallengeAsync Method

Page 71: MSDN September 2014

Pioneers of high-performance data visualization

The fastest rendering data visualization components

for WPF and WinForms...

Results compared to average of other chart controls. See details at www.LightningChart.com/benchmark. LightningChart results apply for Ultimate edition.

Opening large dataset LightningChart is up to faster977,000 %

WPF charts performance comparison

Winforms charts performance comparison

Real-time monitoring LightningChart is up to faster2,700,000 %

Opening large dataset LightningChart is up to faster37,000 %

Real-time monitoring LightningChart is up to faster2,300,000 %

�Entirely DirectX GPU accelerated

�Superior 2D and 3D rendering performance

�Optimized for real-time data monitoring

�Touch-enabled operations

�Supports gigantic data sets

�On-line and off-line maps

�Great customer support

�Compatible with Visual Studio 2005...2013

LightningChartLightningChart

Download a free 30-day evaluation from

www.LightningChart.com

HEAVY-DUTY DATA VISUALIZATION TOOLS FOR SCIENCE, ENGINEERING AND TRADING

Untitled-1 1 1/29/14 10:10 AM

Page 72: MSDN September 2014

msdn magazine62 ASP.NET

However, AllowAnonymous only allows you to override authori-zation. Suppose you want most actions to authenticate using HTTP Basic authentication, but one action to authenticate using just tokens. It would be nice to confi gure token authentication globally but then override authentication for this one action, similarly to how AllowAnonymous overrides authorization.

ASP.NET Web API 2 introduces a new fi lter type to address this scenario, the override fi lter. Unlike AllowAnonymous, the override fi lters introduced in ASP.NET Web API 2 can work with any type of fi lter. Override fi lters, as the name suggests, override the fi lters confi gured at higher levels. To override the authentication fi lters confi gured at higher levels, use the out-of-box attribute OverrideAuthentication. If you have an authentication fi lter applied globally and want to stop it from running for a specifi c action method or controller, you can simply apply OverrideAuthentication at the desired level.

Override filters are useful for far more than simply stopping certain filters from running. Say you have two authentication filters, one for authenticating a security token and another for authenticating a username/password in an HTTP basic scheme. Both fi lters are applied globally, making your API fl exible enough to accept either the token or username/password. Th e following code shows the two authentication fi lters applied globally:

public static class WebApiConfig{ public static void Register(HttpConfiguration config) { // Other Web API configuration code goes here config.Filters.Add(new TokenAuthenticator()); config.Filters.Add(new HttpBasicAuthenticator(realm: "Magical")); }}

Now, perhaps you’d like to ensure only the token is used as a credential to access a specifi c action method. How will Override-Authentication enable you to meet this need, given it just stops all fi lters from running? Here’s the important characteristic of the override fi lters—they wipe out all fi lters specifi ed at higher levels but don’t remove fi lters specifi ed at the same level as themselves. Th is basically means you can add one or more authentication fi lter at a specifi c level while eliminating everything else at higher levels. Going back to the requirement of using just the token as a creden-tial for accessing a specifi c action method, you can simply specify the OverrideAuthentication attribute and TokenAuthenticator at the action method level, as shown in the following code (this en-sures only TokenAuthenticator is run for the action method Ge-tAllowedForTokenOnly):

public class EmployeesController : ApiController{ [OverrideAuthentication] // Removes all authentication filters [TokenAuthenticator] // Puts back only the token authenticator public string GetAllowedForTokenOnly(int id) { return “Hello World”; }}

Th us, the override fi lters introduced with ASP.NET Web API 2 provide a lot more fl exibility in terms of specifying fi lters globally and running fi lters at lower levels selectively only where the global behavior has to be overridden.

In addition to the OverrideAuthentication attribute, there’s also an out-of-box attribute called OverrideAuthorization that removes authorization filters specified at higher levels. Compared with

AllowAnonymous, the diff erence is that OverrideAuthorization removes only the higher-level authorization fi lters. It doesn’t remove authorization fi lters specifi ed at the same level as itself. AllowAnony-mous makes ASP.NET Web API skip the authorization process all together—even if there are authorization fi lters specifi ed at the same level as AllowAnonymous, they’re simply ignored.

Wrapping UpYou can implement authentication in ASP.NET Web API using the options provided by the host, as well as the extensibility points provided by the ASP.NET Web API pipeline. Host-based options integrate well into the host pipeline and reject invalid requests earlier in the pipeline. ASP.NET Web API extensibility points offer a fi ner level of control over the authentication process. When you require more control of authentication, for example, you want to use diff erent authentication mechanisms for diff erent controllers or even diff erent action methods, the right approach is to implement authentication concerns through an authentication filter and authorization concerns through an authorization fi lter.

BADRINARAYANAN LAKSHMIRAGHAVAN is a senior consulting architect with a Fortune 500 company. He’s the author of the books, “Pro ASP.NET Web API Security” and “Practical ASP.NET Web API” both published by Apress in 2013. He occasionally blogs at lbadri.wordpress.com.

THANKS to the following Microsoft technical expert for reviewing this article: David Matson

public static class WebApiConfig{ public static void Register(HttpConfiguration config) { // Other Web API configuration code goes here config.Filters.Add(new AuthorizeAttribute()); // Global level }}

[Authorize(Roles="admin")] // Controller levelpublic class EmployeesController : ApiController{ [Authorize(Users="badri")] // Action method level public string Get(int id) { return “Hello World”; }}

Figure 4 Using an Authorization Filter at Three Different Levels

public static class WebApiConfig{ public static void Register(HttpConfiguration config) { // Other Web API configuration code goes here config.Filters.Add(new AuthorizeAttribute()); // Global level }}

[AllowAnonymous]public class PublicResourcesController : ApiController{ public string Get(int id) { return “Hello World”; }}

Figure 5 Using the AllowAnonymous Attribute

Page 73: MSDN September 2014

Untitled-1 1 8/5/14 10:28 AM

Page 74: MSDN September 2014

msdn magazine64

In machine learning (ML), a classification problem is one in which the goal is to create a model that predicts a result that takes on discrete, non-numeric values. For example, you might want to predict the political party (Democrat or Republican) of a person. Th ere are many diff erent classifi cation algorithms and techniques, including, for example, naive Bayes classifi cation, logistic regression classifi cation, and neural network classifi cation.

A very simple and interesting classifi cation technique is using the Winnow algorithm. (Th e English word winnow means to remove unwanted items). Th e best way to get a feel for what Winnow classifi cation is and to see where this article is headed is to take a look at the demo program in Figure 1.

Th e goal of the demo program is to predict the political party, Democrat or Republican, of a member of the U.S. House of Represen-tatives, based on the Representative’s votes on 16 bills. Th e House of Representatives has 435 members. A well-known benchmark data set contains 435 items stored in a simple text fi le. Th e fi rst three data items are:

republican,n,y,n,y,y,y,n,n,n,y,?,y,y,y,n,yrepublican,n,y,n,y,y,y,n,n,n,n,n,y,y,y,n,?democrat,?,y,y,?,y,y,n,n,n,n,y,n,y,y,n,n

Th e fi rst column in a line is either democrat or republican. Th e next 16 columns are either n (a no vote), y (a yes vote), or ? (missing, unknown or abstain). Th e fi rst column represents the member’s vote on a bill related to handicapped infants. Th e second is a bill related to a water project. And so on. You don’t need to know what bill is associated with each column, but if you’re inter-ested you can fi nd this data set (with descriptions) in many places on the Internet by doing a search for “UCI voting data.”

Winnow classification is designed for a very specific type of classifi cation problem: one where the class to predict can take one of two possible values (these are called binary classifi cation prob-lems), and the predictor variables (often called “features” in ML

terminology) also can take one of two possible values. The raw voting data set meets these requirements if the missing values are dealt with. The most common approach for dealing with miss-ing values is simply to delete any data item that has one or more missing values. However, in the case of voting data, a missing value oft en represents an implied “no” vote, so the demo program replaces all missing values with “no” votes.

Th e demo program uses the fi rst 100 data items in the voting set rather than all 435 items. Th e demo encodes independent variable “no” votes as 0 and “yes” votes as 1, and encodes the dependent political party X variable values “democrat” as 0 and “republican”

Winnow Classifi cation Using C#

TEST RUN JAMES MCCAFFREY

Code download available at msdn.microsoft.com/magazine/msdnmag0914.

Figure 1 Winnow Algorithm Classifi cation Demo

Page 75: MSDN September 2014

65September 2014msdnmagazine.com

as 1. The demo moves the dependent Y variable from the first column to the last column because using the last column for Y is more convenient when coding, and more common.

Th e demo randomly splits the 100-item encoded data set into an 80-item training set to generate the model, and a 20-item test set to evaluate the accuracy of the model. Th e demo uses the Winnow algorithm to fi nd 16 weights (one for each input): 0.2500, 0.500, . . , 0.0625. Using these weights, the demo model correctly predicts the political party of 97.50 percent of the training items (78 out of 80) and 95.00 percent of the test items (19 out of 20).

Th e demo concludes by using the model to predict the political party of a hypothetical Representative who voted “yes” on all 16 bills. Based on the model, the prediction is that the person is a Republican.

Th is article assumes you have at least intermediate program-ming skills but doesn’t assume you know anything about the Winnow classification algorithm. The demo is coded using C#, but you shouldn’t have much trouble if you want to refactor the code to another language, such as Visual Basic .NET or JavaScript.

Understanding the Winnow AlgorithmFor simplicity, suppose the training data is based on just fi ve votes rather than 16. For example:

1, 0, 1, 1, 0 -> 01, 1, 1, 0, 1 -> 10, 0, 0, 1, 0 -> 1

So, the fi rst line means “yes-vote,” “no-vote,” “yes-vote,” “yes-vote,” “no-vote,” “democrat.” Now suppose that a model is trained and yields weights { 0.75, 3.00, 1.00, 0.50, 0.40 }. To compute a pre-dicted output, the algorithm just multiplies each input value by the corresponding weight, sums the terms and then compares the accumulated sum against a threshold value. For example, for the fi rst item, the accumulated sum is:

(1 * 0.75) + (0 * 3.00) + (1 * 1.00) + (1 * 0.50) + (0 * 0.40) = 2.25

If the threshold value is 5.0 then, because the accumulated sum (2.25) is less than the threshold, the predicted Y is 0, which in this case is a correct prediction.

Training a model involves fi nding a set of weights so that when applied to training data with known output values, the computed outputs closely match the known outputs. In high-level pseudo-code the Winnow algorithm is:

initialize weightsloop until done for each training item compute Y if correct do nothing else if incorrect if computed Y is too large divide all relevant weights by 2.0 else if computed Y is too small multiply all relevant weights by 2.0 end forend loop

Suppose for the three data items mentioned earlier, weights are initialized to:

{ 2.50, 2.50, 2.50, 2.50, 2.50 }

Th e computed Y for the fi rst training item (1, 0, 1, 1, 0 -> 0) is:Y = (1 * 2.50) + (0 * 2.50) + (1 * 2.50) + (1 * 2.50) + (0 * 2.50) = 7.50 -> 1

This is an incorrect prediction where the computed Y of 1 is too big compared to the desired Y of 0, so the relevant weights are divided by a factor of 2.0. Th e relevant weights are those weights associated with 1 inputs. Th e new weights are:

{ 2.50 / 2, (no change), 2.50 / 2, 2.50 / 2, (no change) } = { 1.25, 2.50, 1.25, 1.25, 2.50 }

Now, the second training item (1, 1, 1, 0, 1 -> 1) is processed using the new weights:

Y = (1 * 1.25) + (1 * 2.50) + (1 * 1.25) + (0 * 1.25) + (1 * 2.50) = 7.50 -> 1

Th is is a correct prediction, so all weights are left alone. Th e third training item (0, 0, 0, 1, 0 -> 1) is processed using the current weights:

Y = (0 * 1.25) + (0 * 2.50) + (0 * 1.25) + (1 * 1.25) + (0 * 2.50) = 1.25 -> 0

Th is is an incorrect prediction where the computed Y of 0 is too small compared to the desired Y of 1, so relevant weights are multiplied by 2.0:

{ (no change), (no change), (no change), 1.25 * 2.0, (no change) }= { 1.25, 2.50, 1.25, 2.50, 2.50 }

using System;namespace WinnowPredict{ class WinnowProgram { static void Main(string[] args) { Console.WriteLine("Begin Winnow algorithm demo"); int[][] data = new int[100][]; data[0] = new int[] { 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1 }; // Etc. // Create, train and test matrices from data // Instantiate Winnow classifier // Train using training data // Compute accuracy // Predict party of hypothetical person

Console.WriteLine("End Winnow demo"); Console.ReadLine(); } // Main

static void MakeTrainTest(int[][] data, int seed, out int[][] trainData, out int[][] testData) { . . } static void ShowVector(double[] vector, int decimals, int valsPerRow, bool newLine) { . . } static void ShowMatrix(int[][] matrix, int numRows, bool indices) { . . } }

public class Winnow { private int numInput; private double[] weights; private double threshold; private double alpha; private static Random rnd;

public Winnow(int numInput, int rndSeed) { . . } public int ComputeOutput(int[] xValues) { . . } public double[] Train(int[][] trainData) { . . } public double Accuarcy(int[][] trainData) { . . } private static void Shuffle(int[][] trainData) { . . } }}

Figure 2 Overall Demo Program Structure

A very simple and interesting classifi cation technique is using

the Winnow algorithm.

Page 76: MSDN September 2014

msdn magazine66 Test Run

If you think about the Winnow training process a bit, you’ll notice two key characteristics. First, the algorithm uses only incorrect information. Second, the algorithm essentially drives the weights of irrelevant predictors to 0, winnowing them out. Th is oft en makes Winnow classifi cation extremely eff ective in situations where many of the predictor variables are irrelevant. Although the basic Winnow algorithm is quite simple, there are several implementation details to solve, such as deciding how to initialize the weights and deter-mining when to stop training.

Overall Program StructureTh e overall structure of the demo program, with a few WriteLine statements removed and minor edits to save space, is presented in Figure 2. To create the demo program, I launched Visual Studio and created a new C# console application named WinnowPredict. Th e demo has no signifi cant .NET version dependencies, so any version of Visual Studio should work. Aft er the template code loaded into the editor, I deleted all using statements except for the single refer-ence to the top-level System namespace. In the Solution Explorer window, I renamed fi le Program.cs to WinnowProgram.cs and Vi-sual Studio automatically renamed class Program for me.

Th e demo program is a bit too long to present in its entirety in this article, but you can fi nd the complete source code (WinnowProgram.cs) in the accompanying fi le download. All the Winnow classifi cation logic is contained in a program-defi ned class named Winnow.

Th e Main method begins by setting up a 100-item data set, as shown in Figure 3.

To create the data, I located the UCI voting data set on the Web, copied and pasted it into Notepad, and then used edit-replace, plac-ing the data directly into an array-of-arrays-style matrix. Even if you’re an experienced programmer, you might not be familiar with C# matrix syntax, but you’ll likely get used to the coding patterns

quickly. In a non-demo scenario, you’d write some sort of method to load the data from the text fi le into a matrix.

Next, the fi rst four lines and last line of the entire data set are displayed using a helper method, and the data set is split into a training set (80 items) and test set (20 items):

Console.WriteLine("\nFirst few lines of all data are: \n");ShowMatrix(data, 4, true);Console.WriteLine("\nSplitting data into 80% train" + " and 20% test matrices");int[][] trainData = null;int[][] testData = null;MakeTrainTest(data, 0, out trainData, out testData);

Method MakeTrainTest has a hardcoded 80 percent to 20 percent split (you might want to parameterize the percent to use as training data). Aft er displaying part of the training data to verify nothing went wrong, the demo instantiates a Winnow classifi er object and uses the Train method to create a model, that is, to fi nd a set of good weights:

Console.WriteLine("First few rows of training data are:");ShowMatrix(trainData, 3, true);

Console.WriteLine("Begin training using Winnow algorithm");int numInput = 16;Winnow w = new Winnow(numInput, 0);weights = w.Train(trainData);Console.WriteLine("Training complete");

Th e Winnow constructor requires the number of x-variables and a seed value for random number generation, which is used to pro-cess the training items in random order. Next, the demo displays the fi nal weights found by the Train method, and then computes the model’s accuracy on the training and test sets:

Console.WriteLine("Final model weights are:");ShowVector(weights, 4, 8, true);double trainAcc = w.Accuarcy(trainData);double testAcc = w.Accuarcy(testData);Console.WriteLine("Prediction accuracy on training data = " + trainAcc.ToString("F4"));Console.WriteLine("Prediction accuracy on test data = " + testAcc.ToString("F4"));

Th e demo concludes by predicting the political party of a hypo-thetical U.S. House Representative who voted “yes” on all 16 bills, as shown in Figure 4.

The Winnow ClassTh e Winnow class has fi ve data members:

private int numInput;private double[] weights; private double threshold;private double alpha;private static Random rnd;

Data member threshold holds the value used to determine if computed Y is 0 (below threshold) or 1 (above threshold). Data

using System;namespace WinnowPredict{ class WinnowProgram { static void Main(string[] args) { Console.WriteLine("Begin Winnow algorithm prediction demo"); int[][] data = new int[100][]; data[0] = new int[] { 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1 };...

Figure 3 The Main Method Setting up a 100-Item Data Set

... Console.WriteLine("Predicting party of Representative" + " with all 'yes' votes"); int[] unknown = new int[] { 1, 1, 1, 1, 1, 1, 1, 1, 1 , 1, 1, 1, 1, 1, 1, 1 }; int predicted = w.ComputeOutput(unknown); if (predicted == 0) Console.WriteLine("Prediction is 'democrat'"); else Console.WriteLine("Prediction is 'republican'");

Console.WriteLine("End Winnow demo"); Console.ReadLine();} // Main

Figure 4 Predicting the Political Party

The demo has no signifi cant .NET version dependencies,

so any version of Visual Studio should work.

Page 77: MSDN September 2014

67September 2014msdnmagazine.com

member alpha is the factor to decrease (called demotion in research literature) or increase (called promotion) weights when an incorrect Y is computed. Th e standard value for alpha is 2.0, as shown earlier in this article. You may want to experiment by using two diff erent values for promotion and demotion, instead of a single alpha value for both.

Th e Winnow constructor is defi ned like so:public Winnow(int numInput, int rndSeed){ this.numInput = numInput; this.weights = new double[numInput]; for (int i = 0; i < weights.Length; ++i) weights[i] = numInput / 2.0; this.threshold = 1.0 * numInput; this.alpha = 2.0; rnd = new Random(rndSeed);}

Th e threshold value is initialized to the number of input vari-ables, for example 16.0 in the demo. Th is value is standard for the Winnow algorithm, but you might want to experiment with alter-native values. Th e no-eff ect multiplication by 1.0 is there to suggest that diff erent values can be used, but they should be related to the number of input variables.

Th e weights array is allocated using the number of input vari-ables, 16 in the demo. Each of the weights is initialized to the number of input variables divided by 2, or 8.0 in the demo. Th is value is arbitrary and, again, you might want to experiment. Th e Winnow algorithm hasn’t been explored by research very much relative to many other, more commonly used classifi cation algorithms.

Method ComputeOutput is straightforward:public int ComputeOutput(int[] xValues){ double sum = 0.0; for (int i = 0; i < numInput; ++i) sum += weights[i] * xValues[i]; if (sum > this.threshold) return 1; else return 0;}

Notice that a 1 value is returned if the accumulated sum is strictly greater than the threshold value, as opposed to greater than or equal to the threshold. Th is is arbitrary and using “>=” instead of “>” will not have a signifi cant impact on the algorithm.

The Training MethodTh e Winnow algorithm training routine is one of the shortest and sim-plest of all ML classifi cation algorithms. Th e method defi nition begins:

public double[] Train(int[][] trainData){ int[] xValues = new int[numInput]; int target; int computed; Shuffle(trainData);...

Local array “xValues” holds the input values from a training item, but not the target output value. Local variable “target” holds the desired Y value from a training data item. Local variable “computed” stores the computed Y value, for a given set of input x-values and the current set of weights. Method Shuffl e randomizes the order of the training data using the Fisher-Yates mini-algorithm.

Next, the main training loop begins:for (int i = 0; i < trainData.Length; ++i){ Array.Copy(trainData[i], xValues, numInput); // Inputs target = trainData[i][numInput]; // Last value is target computed = ComputeOutput(xValues); // Update weights here}

As mentioned earlier, it’s not entirely clear how long to train. Th e demo iterates just once through the training data. An alternative is to iterate multiple times through the training data, stopping aft er a fi xed number of iterations, or perhaps when some desired accu-racy has been reached.

Inside the main training loop, weights are updated using the code in Figure 5.

Method Train concludes by copying the best weights found into a local return-array:

... } // end for double[] result = new double[numInput]; // = number weights Array.Copy(this.weights, result, numInput); return result;} // Train

Wrapping UpTh is article is based on the research paper that originally presented the Winnow algorithm, “Learning Quickly When Irrelevant Attributes Abound: A New Linear-Th reshold Algorithm” (1998), N. Littlestone. You can fi nd this paper in PDF format on the Web in several locations.

While doing background research for this article, I came across an interesting implementation of the Winnow algorithm written using the F# language. Th e implementation is in a personal blog post written by Mathias Brandewinder (bit.ly/1z8hfj6).

Although Winnow classification is designed specifically for binary classifi cation problems where the independent x-variables are all binary, you might want to experiment on problems where one or more x-variables are categorical. For example, suppose one predictor variable is “color” and can take one of three possible values: “red,” “green,” or “blue.” If you use 1-of-N encoding, red becomes (1, 0, 0), green becomes (0, 1, 0), blue becomes (0, 0, 1), and the Winnow algorithm can be applied.

DR. JAMES MCCAFFREY works for Microsoft Research in Redmond, Wash. He has worked on several Microsoft products including Internet Explorer and Bing. He can be reached at jammc@microsoft .com.

THANKS to the following technical experts at Microsoft Research for reviewing this article: Nathan Brown and Kirk Olynyk

if (computed == 1 && target == 0) // Decrease{ for (int j = 0; j < numInput; ++j) { if (xValues[j] == 0) continue; // Not relevant weights[j] = weights[j] / alpha; // Demotion }}else if (computed == 0 && target == 1) // Increase{ for (int j = 0; j < numInput; ++j) { if (xValues[j] == 0) continue; // Not relevant weights[j] = weights[j] * alpha; // Promotion }}

Figure 5 Updating Weights

Page 78: MSDN September 2014

THAT’S RIGHT, WE’RE TRANSPORTING Visual Studio Live! to our nation’s capital for the

developers, software architects, engineers and

to boldly code

where no visual studio live! has coded before

Explore HOT TOPICS like: Visual Studio 2013 IDE MVC 5 Breeze C# 6.0 Angular Entity Framework Xamarin And Many More!

PRODUCED BYSUPPORTED BY

magazine

WASHINGTON, D.C.

Washington Marriott at Metro Center

vslive.com/dc

Scan the QR code to register or for more event details.

YOUR GUIDE TO THE DEVELOPMENT

UNIVERSE

Use promo code DCSEP2

CONNECT WITH VISUAL STUDIO LIVE!

Untitled-5 2 7/29/14 1:10 PM

Page 79: MSDN September 2014

START TIME END TIME (Separate entry fee required)

7:30 AM 9:00 AM Pre-Conference Workshop Registration

9:00 AM 6:00 PM - Workshop: Deep Dive Into Visual Studio 2013, TFS, and Visual Studio Online - Brian Randell

- Workshop: SQL Serverfor Developers -

Andrew Brust & Leonard Lobel

- Workshop: Data-Centric Single Page Applications with Angular, Breeze, and Web API -

Brian Noyes

6:00 PM 9:00 PM Dine-A-Round Dinner

Visual Studio / .NET Framework

Windows Client

Cloud Computing

Windows Phone

Cross-Platform Mobile Development ASP.NET JavaScript /

HTML5 ClientSharePoint / SQL Server

START TIME END TIME

7:00 AM 8:00 AM Registration

8:00 AM 9:00 AM Keynote: To Be Announced

9:15 AM 10:30 AM - Great User Experiences with CSS 3 - Robert Boedigheimer

- What’s New in MVC 5 -Miguel Castro

- New IDE and Editor Featuresin Visual Studio 2013 -

Deborah Kurata

- Creating Universal Windows Apps for Business - Rockford Lhotka

10:45 AM 12:00 PM - Using jQuery to Replace the

Ajax Control Toolkit - Robert Boedigheimer

- ASP.NET Reloaded: Web Forms vs. MVC vs. Web API - Dino Esposito

- Introduction toIn Memory OLTP Using Hekaton in

SQL Server 2014 - Kevin Goff

- WPF Data Binding in Depth - Brian Noyes

12:00 PM 1:30 PM Lunch - Visit Exhibitors

1:30 PM 2:45 PM

- Build an Angular and Bootstrap Web Application in Visual Studio

from the Ground Up - Deborah Kurata

- What’s New in Web API 2 - Miguel Castro

- Making the Most of the Visual Studio Online -Brian Randell

- Moving Web Apps to the Cloud - Eric D. Boyd

3:00 PM 4:15 PM - JavaScript for the C# (and Java)

Developer -Philip Japikse

- Never Mind the Mobile Web; Here's the Device Web - Dino Esposito

- Cross-platform Dev (iOS, Android and Java) with TFS and Team Explorer Everywhere - Brian Randell

- Solving Security and Compliance Challenges with Hybrid

Clouds - Eric D. Boyd

4:15 PM 5:45 PM Exhibitor Welcome Reception

START TIME END TIME

7:00 AM 8:00 AM Registration

8:00 AM 9:00 AM Keynote: To Be Announced

9:00 AM 9:30 AM Networking Break

9:30 AM 10:45 AM - Writing Next Generation

JavaScript with TypeScript -Rachel Appel

- A Survey of Two Popular Visual Studio Tools - Web Essentials and

NuGet - John Petersen

- Getting Started with Xamarin - Walt Ritscher

- SQL for Application Developers - Attendees Choose -

Kevin Goff

11:00 AM 12:15 PM - Building Single-Page Web

Applications Using Kendo UI and the MVVM Pattern - Ben Hoelting

- ASP.NET MVC - Rudiments of Routing - Walt Ritscher

- Getting Started with Windows Phone Development - Nick Landry

- Database Development with SQL Server Data Tools - Leonard Lobel

12:15 PM 1:30 PM Birds-of-a-Feather Lunch - Visit Exhibitors

1:30 PM 2:45 PM - Introduction to AngularJS - John Petersen

- Slice Development Time with ASP.NET MVC, Visual Studio, and

Razor - Philip Japikse

- The Great Mobile Debate: Native vs. Hybrid App Development

- Nick Landry

- Learning Entity Framework 6 - Leonard Lobel

3:00 PM 4:15 PM - Creating Angular Applications

Using Visual Studio LightSwitch -Michael Washington

- Build Data Driven Web Sites with WebMatrix 3 and ASP.NET

Web Pages - Rachel Appel

- Busy .NET Developer's Guide to iOS - Ted Neward

- Team Foundation Server for Scrum Teams - Richard Hundhausen

4:30 PM 5:45 PM - To Be Announced - Build Real Time Websites and Apps with SignalR - Rachel Appel

- Busy .NET Developer's Guide to Android - Ted Neward

- Team Foundation Server: Must-Have Tools and Widgets -

Richard Hundhausen

START TIME END TIME

7:30 AM 8:00 AM Registration

8:00 AM 9:15 AM - Excel, Power BI and You: An Analytics Superhub - Andrew Brust

- What's New inWPF 4.5 - Walt Ritscher

- Visual Studio 2013, Xamarin and Windows Azure Mobile Services:

A Match Made in Heaven -Rick Garibay

- What's New in the .NET 4.5.1 BCL - Jason Bock

9:30 AM 10:45 AM - Big Data 101 with HDInsight - Andrew Brust

- WPF for the Real World - Brian Lagunas

- Building Your First Windows Phone 8.1 Application - Brian Peek

- Essential C# 6.0 -Mark Michaelis

11:00 AM 12:15 PM - Cloud or Not, 10 Reasons

Why You Must Know “Web Sites” - Vishwas Lele

- Deploying WinRT Apps Without the Store -

Rockford Lhotka

- Building Games for Windows and Windows Phone - Brian Peek - To Be Announced

12:15 PM 1:15 PM Lunch

1:15 PM 2:30 PM - Loosely Coupled Applications

with Service Bus and Document-centric Data Stores - Vishwas Lele

- Creating Cross Platform Games with Unity - Brian Lagunas

- Visual Studio Cloud Business Apps - Michael Washington

- Asynchronous Debugging in .NET - Jason Bock

2:45 PM 4:00 PM

- Not Your Father's BizTalk Server: Building Modern Hybrid Apps with Windows Azure BizTalk Services

- Rick Garibay

- Use Your .NET Code inWinRT with Brokered Assemblies -

Rockford Lhotka

- Best Practices: Building Apps

Mark Michaelis

- Adventures in Unit Testing: TDD vs. TED - Ben Hoelting

4:15 PM 5:15 PM Conference Wrap-Up - Andrew Brust (Moderator), Jason Bock, Ben Hoelting, Rockford Lhotka, & Brian Peek

Sessions and speakers subject to change

Untitled-5 3 7/29/14 1:10 PM

Page 80: MSDN September 2014

msdn magazine70

Welcome back. In my last column, “Fun with C#” (msdn.microsoft.com/magazine/dn754595), I talked briefl y about how familiarity with other programming languages can help clarify your thinking around a design problem that might otherwise seem intractable. I introduced a problem I encountered years ago during a consulting engagement in which I was required to reconcile a list of transactions stored locally with a supposedly equal list of transactions stored remotely. I had to either match them by transaction amount—nothing else was guaranteed to match for even the exact same transaction—or fl ag the unmatched items in the resulting list.

I chose to use F# for that exercise because it’s a language with which I’m familiar. Quite frankly, it could easily have been another language like Scala, Clojure or Haskell. Any functional language would have worked in a similar fashion. Th e key here isn’t the language itself or the platform on which it ran, but the concepts involved in a functional language. Th is was a pretty functional-friendly problem.

The F# SolutionJust to revisit, look at the F# solution in Figure 1 before looking at how it would translate into C#.

Look at the previous column to see a brief recap of the F# syntax used in Figure 1, especially if you aren’t familiar with F#. I’m also going to be going over it as I transform it into C#, so you could also just dive in.

The C# SolutionAt the starting point, you need the Transaction and Register types. Th e Transaction type is easy. It’s a simple structural type with three named elements, making it easy to model as a C# class:

class Transaction{ public float Amount { get; set; } public DateTime Date { get; set; } public String Comment { get; set; }}

Th ose automatic properties make this class almost as short as its F# cousin. In all honesty, if I was going to really make it a one-to-one translation of what the F# version does, I should introduce overridden Equals and GetHashCode methods. For the purpose of this column, though, this will work.

Th ings get tricky with the discriminated union Register type. Like an enumeration in C#, an instance of a Register type can only be one of three possible values (RegEntry, MissingLocal or Missing-Remote). Unlike a C# enumeration, each of those values in turn can contain data (the two Transactions that matched for RegEntry, or the missing Transaction for either MissingLocal or Missing-Remote). While it would be easy to create three distinct classes in C#, these three classes must be somehow related. We need a List that can contain any of the three—but only those three—for the returned output, as shown in Figure 2. Hello, inheritance.

It’s not ridiculously complicated, just more verbose. And if this were production-facing code, there are a few more methods I should add—Equals, GetHashCode and, almost certainly, ToString. Although there might be a few ways to make it more idiomatically C#, I’ll write the Reconcile method fairly close to its F# inspiration. I’ll look for idiomatic optimizations later.

Th e F# version has an “outer,” publicly accessible function recur-sively called into an inner, encapsulated function. However, C# has no concept of nested methods. Th e closest I can approximate is with two methods—one declared public and one private. Even then,

Fun with C#, Part 2

THE WORKING PROGRAMMER TED NEWARD

type Transaction = { amount : float32; date : DateTime; comment : string }

type Register = | RegEntry of Transaction * Transaction | MissingRemote of Transaction | MissingLocal of Transaction

let reconcile (local : Transaction list) (remote : Transaction list) : Register list = let rec reconcileInternal outputSoFar local remote = match (local, remote) with | [], _ | _, [] -> outputSoFar | loc :: locTail, rem :: remTail -> match (loc.amount, rem.amount) with | (locAmt, remAmt) when locAmt = remAmt -> reconcileInternal (RegEntry(loc, rem) :: outputSoFar) locTail remTail | (locAmt, remAmt) when locAmt < remAmt -> reconcileInternal (MissingRemote(loc) :: outputSoFar) locTail remote | (locAmt, remAmt) when locAmt > remAmt -> reconcileInternal (MissingLocal(rem) :: outputSoFar) local remTail | _ -> failwith "How is this possible?"

reconcileInternal [] local remote

Figure 1 The F# Solution for Resolving Disparate Transactions

class Register { }

class RegEntry : Register { public Transaction Local { get; set; } public Transaction Remote { get; set; } } class MissingLocal : Register { public Transaction Transaction { get; set; } } class MissingRemote : Register { public Transaction Transaction { get; set; } }

Figure 2 Use Inheritance to Include Three Distinct Classes

Page 81: MSDN September 2014

71September 2014msdnmagazine.com

this isn’t quite the same. In the F# version, the nested function is encapsulated from everyone, even other functions in the same module. But it’s the best we can get, as you can see in Figure 3.

As a side note, I can now accomplish the “hidden from every-body” recursive approach by writing the internal function entirely as a lambda expression referenced as a local variable inside Recon-cile. Th at said, that’s probably a little too much slavish adherence to the original and entirely not idiomatic to C#.

It isn’t something most C# developers would do, but it would have almost the same eff ect as the F# version. Inside of Reconcile-Internal, I have to explicitly extract data elements used. Then I explicitly write it in an if/else-if tree, as opposed to the more suc-cinct and terse F# pattern match. However, it’s really the exact same code. If either the local or remote list is empty, I’m done recursing. Just return the output and call it a day, like so:

static List<Register> ReconcileInternal(List<Register> Output, List<Transaction> local, List<Transaction> remote){ if (local.Count == 0) return Output; if (remote.Count == 0) return Output;

Th en, I need to extract the “heads” of each list. I also need to keep a reference to the remainder of each list (the “tail”):

Transaction loc = local.First();List<Transaction> locTail = local.GetRange(1, local.Count - 1);

Transaction rem = remote.First();List<Transaction> remTail = remote.GetRange(1, remote.Count - 1);

Th is is one place where I can introduce a huge performance hit if I’m not careful. Lists are immutable in F#, so taking the tail of a

list is simply taking a reference to the second item in the list. No copies are made.

C#, however, has no such guarantees. Th at means I could end up making complete copies of the list each time. Th e GetRange method says it makes “shallow copies,” meaning it will create a new List. However, it will point to the original Transaction elements. Th is is probably the best I can hope for without getting too exotic. Having said that, if the code becomes a bottleneck, get as exotic as necessary.

Looking again at the F# version, what I’m really examining in the second pattern match is the amounts in the local and remote transaction, as shown in Figure 4. So I extract those values as well, and start comparing them.

Each branch of the tree is pretty easy to understand at this point. I add the new element to the Output list, then recurse with the unprocessed elements of the local and remote lists.

Wrapping UpIf the C# solution is really this elegant, why bother taking the stop through F# in the fi rst place? It’s hard to explain unless you go through the same process. Essentially, I needed the stop through F# to fl esh out the algorithm in the fi rst place. My fi rst attempt at this was an absolute disaster. I started by iterating through the two lists using double “foreach” loops. I was trying to track the state along the way, and I ended up with a huge, steaming mess I would never have been able to debug in a million years.

Learning how to “think diff erently” (to borrow a famous com-puter company’s marketing line from a few decades ago) yields results, not the choice of language itself. I could’ve easily told this story going through Scala, Haskell or Clojure. Th e point wasn’t the language feature set, but the concepts behind most functional lan-guages—recursion, in particular. Th at’s what helped break through the mental logjam.

Th is is part of the reason developers should learn a new pro-gramming language every year, as first suggested by one of the Pragmatic Programmers, Dave Th omas, of Ruby fame. Your mind can’t help but be exposed to new ideas and new options. Similar kinds of ideas emerge when a programmer spends some time with Scheme, Lisp or with a stack-based language such as Forth—or with a prototype-based language like Io.

If you’d like a lightweight introduction to a number of diff erent languages all off the Microsoft .NET Framework platform, I highly recommend Bruce Tate’s book, “Seven Languages in Seven Weeks” (Pragmatic Bookshelf, 2010). Some of them you wouldn’t use directly on the .NET platform. Th en again, sometimes the win is in how we think about the problem and frame the solution, not necessarily reusable code. Happy coding!

TED NEWARD is the CTO at iTrellis, a consulting services company. He has written more than 100 articles and authored and coauthored a dozen books, including “Professional F# 2.0” (Wrox, 2010). He’s a C# MVP and speaks at con-ferences around the world. He consults and mentors regularly—reach him at [email protected] or [email protected] if you’re interested in having him come work with your team, and read his blog at blogs.tedneward.com.

THANKS to the following Microsoft technical expert for reviewing this article: Lincoln Atkinson

class Program{ static List<Register> ReconcileInternal(List<Register> Output, List<Transaction> local, List<Transaction> remote) { // . . . } static List<Register> Reconcile(List<Transaction> local, List<Transaction> remote) { return ReconcileInternal(new List<Register>(), local, remote); }}

Figure 3 The Nested Function Is Encapsulated Here

float locAmt = loc.Amount; float remAmt = rem.Amount;

if (locAmt == remAmt) { Output.Add(new RegEntry() { Local = loc, Remote = rem }); return ReconcileInternal(Output, locTail, remTail); } else if (locAmt < remAmt) { Output.Add(new MissingRemote() { Transaction = loc }); return ReconcileInternal(Output, locTail, remote); } else if (locAmt > remAmt) { Output.Add(new MissingLocal() { Transaction = rem }); return ReconcileInternal(Output, local, remTail); } else throw new Exception("How is this possible?");}

Figure 4 The F# Version Examines the Local and Remote Amounts

Page 82: MSDN September 2014

msdn magazine72

If you develop for the Windows platform, you can now write apps that target both Windows 8.1 and Windows Phone 8.1 with a single, shared codebase by creating a Universal App. Universal Apps are new to Windows. Th ey let you share signifi cant portions of your JavaScript, C#/Visual Basic, and C++ code across the Windows ecosystem.

At the Build 2014 conference, Microsoft stated it will extend the Universal App concept to Xbox in the future (bit.ly/1p19O7O). You can do it now, but you’d need Visual Studio 2012 and a few work-arounds. Th is is particularly exciting news for those who build games and media apps. You now have a head start building for the various Windows platforms, and adding an Xbox project later. Here, I’ll stick to Windows and Windows Phone.

Outside the Windows and Xbox platforms, you can use Universal Apps to write cross-platform apps with HTML and JavaScript. You can write strictly HTML5. You can eschew the Windows Library for JavaScript (WinJS) for iOS and Android. You can also use WinJS just for native features in the Windows ecosystem. If you’re using XAML with C#, you can use a tool like Xamarin to publish across the major platforms.

Get Started with Universal AppsYou can build Universal Apps using Visual Studio 2013 Update 2 on Windows 8.1 using project templates for JavaScript, C#/Visual Basic and C++. Th is means you can continue to use your favorite language to build apps in this latest Windows update.

Th e structure of the new Universal App is a Visual Studio solu-tion with at least three projects—Windows, Windows Phone and Shared. Coincidentally, there are three project types of Universal Apps from which to choose—the Blank, Hub and Navigation tem-plates. You can use the New Project dialog in Visual Studio to create a Universal App with any of these three new templates.

Because Visual Studio creates a solution containing three proj-ects, you would rightfully expect the Shared project is where the shared code goes. Put as much code here as possible. Code sharing and reuse has many benefi ts, such as easier maintenance and less-expensive bug fi xes. Of course, you can have too much of a good thing. If you try to share everything, you’ll end up with too many branching con-structs in your code, such as if and

switch statements that will become unruly. As a rule of thumb, if you fi nd yourself copying and pasting code to use in multiple places, you should separate the code into the separate projects. Th is concept is called DRY—short for Don’t Repeat Yourself. Th e DRYer the code is, the better.

A Shared project is a project fi le with a .shproj extension. Shared projects behave like regular projects, except they don’t create compiled output or a package. Th ey’re simply a way to make code available for two or more projects without having to reference or copy and paste. You can share code like this because in Windows 8.1, the Windows Runtime extends across both OSes. Some API members aren’t compatible between platforms, but calls to those can go in their corresponding projects.

Figure 1 shows the architecture for a simple Universal App. Th is app, called Countdown, displays the number of days to an event date the user enters alongside number of days until the event.

As you can see in Figure 1, each project contains its own UI code. Th e Shared project contains a few JavaScript fi les, as well as a shared home page.

Sharing Code Across Projects Each platform project has a default.html and .js fi le that acts as the app starting point. Th ese reference the corresponding platform-specific JavaScript files. For this example, you don’t need any special code for lifecycle management. If you do, though, you might need to separate those fi les depending on how OS-specifi c your needs are for the app.

Th ese are the Windows default.html references:<script src="//Microsoft.WinJS.2.0/js/base.js"></script><script src="//Microsoft.WinJS.2.0/js/ui.js"></script>

Th ese are the Windows Phone default.html references:<script src="//Microsoft.Phone.WinJS.2.1/js/base.js"></script><script src="//Microsoft.Phone.WinJS.2.1/js/ui.js"></script>

Build Universal Apps for the Windows Platform

MODERN APPS RACHEL APPEL

Figure 1 Side-by-Side Views of Windows 8.1, Windows Phone 8.1 and a Shared Project

Page 83: MSDN September 2014

73September 2014msdnmagazine.com

These are references to the WinJS 2.0 for Windows and the WinJS 2.1 for Windows Phone. Th e latter contains the JavaScript that takes advantage of any diff erences on Windows Phone.

In the sample Countdown app, there’s a page directory in each plat-form project. Each directory contains subdirectories for each page. Th e subdirectories include the page itself and related items such as CSS or JS fi les. In Figure 1, you can see the pages are home, addEvent and privacy. These folders merge between the platform and shared projects at run time. You may only have one fi le with a unique name in each folder. For example, you can save the home.html page in the /pages/home/ directory, but only in one project. In this case, I’ve put it in the Shared project folder.

Th e home page is the main part of the app where the countdown events display. Figure 2 shows the shared UI code for home.html. Notice the corresponding home.css fi les are located in their respective projects. Th is means if you use the same CSS class names across projects, you can use the same HTML. But these would be restyled with the varying CSS for each platform, as you can see in Figure 2. You can have one base of HTML and style with diff ering CSS for each platform project.

Figure 3 converts the <div id="addEventHTMLControl"> element from Figure 2 into a WinJS.UI.HtmlControl on Windows. Th is means you can store the add event code in the addEvent.html fi le.

Within the shared home.js, there are a few points where you need to write some conditional code. Th is determines which platform you’re using and acts accordingly. Check for the package name to determine which platform is running. Th e package name is in the package.appmanifest under the Packaging tab. By default, this is a GUID. You can change it to something friendly to use in code. Once

you’ve done that, you can query it to determine the current platform at run time. Figure 3 shows a sample of what this code looks like when determining which events to wire up and which UI component to use.

As you can see, Figure 3 wires the appBar buttons to features that are distinct to each app type. Th is could be a Flyout versus an entire page for both adding events and viewing privacy settings. It’s easy in Windows. Th e privacy page is part of the app settings, launched from the Settings charm. Th e code that sets up Charms usually goes in default.js on activated event. Because Windows Phone doesn’t have the notion of Charms, use the appBar as a way to navigate to the privacy page, as refl ected in Figure 3.

Th e best way to add events is to use a Flyout in Windows. Th en, due to the diff ering form factors, create a complete HTML page on Windows Phone. Popups and dialogs just don’t do well on phone-sized

Figure 2 The HTML and CSS that Create the Home Page for Both Projects

<!DOCTYPE html><html><head> <meta charset="utf-8" /> <title>Countdown</title> <link href="/pages/home/home.css" rel="stylesheet" /> <script src="/js/MobileServices.js"></script> <script src="/js/data.js"></script> <script src="/pages/home/home.js"></script> </head><body> <div id="contenthost"> <h1 id="title" class="title">Countdown from</h1> <div id="maincontent"> <div id="listViewTemplate" data-win-control="WinJS.Binding.Template" class="win-container"> <div data-win-bind="style.background: color" class="win-item"> <h1 class="h1" data-win-bind="textContent: daysToGo"></h1> <h2 class="h2"> days to go until</h2> <h2 class="h2" data-win-bind="textContent: eventTitle"></h2> <h2 class="h2" data-win-bind="textContent: eventDate"></h2> </div> </div> <div id="listView" data-win-control="WinJS.UI.ListView" class="win-listview" data-win-options="{ selectionMode: 'single' }"> </div> </div> <div id="addEventHTMLControl"> </div> </div></body></html>

<!-- CSS for the Windows ListView -->#listView {

height:500px;}

#listView .win-viewport { height:415px;}

#listView .win-item { width:300px; height:185px; padding: 0 0 0 5px;}

.h1 { font-size:1.5em; }

.h2 { font-size:1em; }

<!-- CSS for the Windows.Phone ListView -->#listView .win-item { width:100%; height:125px; padding: 5px 0 0 5px;}.h1 { font-size:2em; }

.h2 { font-size:1.5em; }

var listView = document.querySelector("#listView").winControl; var packageName = Windows.ApplicationModel.Package.current.id.name;if (packageName === "Countdown.WindowsPhone") { document.querySelector("#privacyButton").addEventListener("click", this.navigateToPrivacyPage); document.querySelector("#addButton").addEventListener("click", this.navigateToaddEventPage); listView.layout = new WinJS.UI.ListLayout();}else if (packageName === "Countdown.Windows") { document.querySelector("#addButton").addEventListener("click", this.showAddEventFlyout); var htmlControl = new WinJS.UI.HtmlControl(document.querySelector("#addEventHTMLControl"), { uri: '/pages/addEvent/addEvent.html' }); listView.layout = new WinJS.UI.GridLayout();}

Figure 3 Part of the Home.js Ready Function That Determines the OS and Builds the UI

Page 84: MSDN September 2014

msdn magazine74 Modern Apps

devices. Th e addEvent Flyout or page is where the user enters new event details. Th e HTML for the addEvent Flyout is also in Figure 3.

Also notice in Figure 3 the ListView layout changes between a grid and list layout in the code, depending on which platform is detected. Th e ListLayout property is handy, because you need just one block of HTML from Figure 2. Combining this with one shared chunk of code from Figure 3 does the legwork to switch between layouts.

In the js folder, you’ll fi nd the same data.js and navigator.js fi les as their counterparts in any given solution based on the Navigation template. Apps on both platforms need the same data and navi-gation scheme, so these fi les can stay in the Shared project. Th e following code is the defi nition for the Data namespace, which is familiar to WinJS developers:

var list = new WinJS.Binding.List();

WinJS.Namespace.define("Data", { loadEventData: loadEventData, saveEventItem: saveEventItem, deleteEventItem: deleteEventItem, items: list, });

Both platform projects consume the data the exact same way, by JSON data put into a WinJS.Binding.List object. The only diff erence is how they style the data.

When developing Universal Apps, you should write unit tests and make changes in the shared codebase. This means at some point, you’ll need to run the project to verify the results. When debugging, choose the project you want to debug, right-click on that project in the Solution Explorer and choose Set as Start Project.

Th is will make the project appear bold in Solution Explorer. When you click Run, press F5, or launch the project, then the Start Project is the one that runs. You can switch between projects as the starting project as needed.

Th e Shared project can’t be the Start Project. When you run a specifi c project, Visual Studio packages, deploys and loads that project’s assets, as well as the ones from the Shared project. Th en it starts the corresponding emulator if it isn’t already and you’re good to go. To learn more about debugging Windows Store apps, see my blog post at bit.ly/1hTpxHB.

Create Native UIsTh e UI will share the least amount of code. Various form factors dictate both the amount and presentation of data. Present data with

HTML and make it look good with CSS. Dealing with different HTML and CSS is simpler if you split it into separate projects, including the CSS Media Queries for each range of devices per platform.

In the case of the Countdown app, you want a grid display on Windows and a vertical list on phones. Do this by placing the home.html fi le in the Shared project, and the home.css fi les in separate projects. Th e addEvent and privacy pages go in their corresponding platform projects. To see this folder structure, look back at Figure 1.

In the Countdown.Windows app, the user adds an event by tapping or clicking the Add appBar button. Th is displays a popup dialog using a Flyout control. In Count-down.WindowsPhone, the app takes the user to an entire addEvent page. Here’s the code that designs the Flyout in Countdown.Windows:

<div id="eventFlyoutPanel" data-win-control="WinJS.UI.Flyout"> <table width="100%" height="100%"> <tr><td>Date:</td><td><span id="eventDate" data-win-control="WinJS.UI.DatePicker"></span></td></tr> <tr><td>Event:</td><td><input type="text" id="eventTitle" /></td></tr> <tr><td>&nbsp;</td><td><input type="button" id="confirmButton" value="Submit" /></td></tr> </table></div>

It’s a small table containing a DatePicker and TextBox. Neither Flyouts nor DatePickers run on Windows Phone. Th is Flyout is con-fi gured in home.html as a WinJS.UI.HtmlControl. Figure 4 gives you a look at the runtime appearance of the screen this code creates.

The Countdown.WindowsPhone project is much different. Instead of a Flyout, you must navigate to the addEvent page. Having no DatePicker is no problem. You can collect the event’s date with the proven mobile technique of creating three <select> elements, one for each part of the date (Day/Month/Year). Figure 5 contains a sample of the Countdown.Windows addEvent HTML code and Figure 6 shows what it will look like at run time on Windows Phone.

You need to ensure the controls you want to use are available across OSes. Hub, Flyout, DatePicker and TimePicker controls aren’t available on Windows Phone. Th e Pivot control isn’t avail-able on Windows. Fortunately, if you’re using the popular Hub or Pivot controls, they’re usually interchangeable. So you can use Hub on Windows and Pivot on the phone and get the same things done. Simple dropdown controls work for capturing dates. Figure 6 shows what this will look like on the Windows phone.

Review your code and separate code targeting OS-specifi c tasks. Th e more of these types of tasks, the more it should be separated into its own project. If there are only a few blocks, then it’s OK to leave it in the Shared project.

More Ways to Share CodeYou can apply architectural patterns as a way to organize, main-tain and share code, such as Model-View-ViewModel (MVVM) or Model-View-Controller (MVC). In the case of the Countdown app, sharing code in the Shared project works fi ne.

Another exciting announcement from the Build conference is that the Windows Runtime now supports any third-party JavaScript framework. Th is means you can use popular packages such as Knockout, Angular or Breeze.js to implement these patterns.

Figure 4 The Runtime Appearance of the Countdown App Flyout

Page 85: MSDN September 2014

75September 2014msdnmagazine.com

Th e Models and ViewModels in Shared project work seamlessly across the other projects with little or no modifi cation. Th is leaves only code in the Views that may need duplication or customization. Sometimes this is unavoidable. Th ere are vastly diff erent device sizes and form factors to consider. Th ere are also wide varieties of input devices including touch, keyboard, mouse, voice and so on. Code to handle these variables oft en needs to be separate.

In JavaScript apps, you can put Process Lifecycle Management code in the default.js in each individual project. You can also store models, ViewModels and any app logic there. Th e OSes handle protocol activa-tions diff erently. However, most projects have some general-purpose utility code, which should be added to a script in the Shared project.

Th ere are several other ways to share code across projects: • Conditional Compilation: Segment blocks of code to

compile specifi cally for one OS or another. Th is applies to C#/Visual Basic and C++. Use regular if statements in WinJS. Learn more about this at bit.ly/UzdBAa.

• Runtime Components: Components built with the Windows Runtime expose code to both Windows and Windows Phone apps, which allows code sharing.

• Add Link: You can treat a pointer to a fi le in another project as if it were part of the current project.

• Portable Class Library (PCL): Th is is the Microsoft .NET Framework way to share code. Th e Windows Runtime (WinRT) supports these legacy components, so you can use them in your apps. Th ese are best to use if you already have an existing PCL. You might want to add WinRT components if you’re creating new components.

Clearly, a Shared project isn’t the only way to share code. You can reuse .NET code you already have lying around. For example, you may have some hefty performance requirements when creating a live action game that needs the help of C++. UsingWinRT components is a great way to share that kind of code.

Use Fragments whenever possible. These are just snippets of HTML both projects can use. UI components such as appBars and Flyouts don’t work well across form factors, so you’ll want to keep those in their corresponding projects. Code that sets general app settings and the like can go in the Shared project.

Wrapping UpWhile Universal Apps don’t exactly provide a “write once and magically run everywhere” scenario, they do come close. Th ere are some API changes, but with the single Windows Runtime behind the apps, it’s quite easy to work on an app that runs in the entire Windows ecosystem. You can even get your apps running on non-Microsoft platforms with the help of Visual Studio extensions from Xamarin. Also promised at Build was future support for Xbox One Achievements, Challenges, OneGuide and more. Th ere are exciting things happening for Microsoft app developers.

RACHEL APPEL is a consultant, author, mentor and former Microsoft employee with more than 20 years of experience in the IT industry. She speaks at top industry conferences such as Visual Studio Live!, DevConnections, MIX and more. Her expertise lies within developing solutions that align business and technology focusing on the Microsoft dev stack and open Web. For more about Appel, visit her Web site at rachelappel.com.

THANKS to the following Microsoft technical expert for reviewing this article: Frank La Vigne

<h1 id="title" class="title"> Add event </h1> <div> Month <select id="eventMonth"> <option value="--Select--">--Select--</option> <option value="01">January</option> <option value="02">February</option> <option value="03">March</option> <option value="04">April</option> <option value="05">May</option> <!-- options 6-11, cut for brevity --> <option value="12">December</option> </select> Day <select name="day" id="day"> <option value="--Select--">--Select--</option> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> <!-- options 6-30, cut for brevity --> <option value="31">31</option> </select> Year<select id="eventYear"> <option value="--Select--">--Select--</option> <!-- all other options created via client script --> </select> </div> <div>Event<input type="text" id="eventTitle" /></div> <div> <input type="button" id="backButton" value="Back" /> <input type="button" id="confirmButton" value="Submit" /> </div><script type="text/javascript"> (function () { var yearSelect = document.querySelector("#eventYear"); for (var i = 2014; i < 2075; i++) { yearSelect.options[i] = new Option(i, i); } })();</script>

Figure 5 A Sample of the Countdown.Windows addEvent HTML Code

Figure 6 The Countdown and Add Event Page as Generated on a Windows Phone

Page 86: MSDN September 2014

msdn magazine76

In 1975, the artist Richard Haas painted the fl at side of a building in the Soho district of Manhattan to resemble the façade of a classic cast-iron building, including such features as a cat in a window. Time hasn’t been kind to this painting, but in its early days, it looked very real and fooled many people.

Such paintings—called trompe-l’œil, meaning “deceive the eye”—use shadows and shading to bring out a third dimension on a fl at two-dimensional surface. We tend to be tickled by such illusions, but at the same time eager to satisfy ourselves that we can discern the trick. One simple way is to try observing the painting from diff erent perspectives to see if it looks the same.

A similar mental process occurs when a computer program dis-plays some graphics that seem to straddle the line between 2D and 3D. Is it really 3D? Or just 2D with some clever overlapping and shading? We can’t move our heads from side to side to establish the facts, but we might be able to persuade the program to rotate its graphics to see what happens.

Th e image in Figure 1 looks a lot like the screen displayed by the Th reeTriangles program in the previous installment of this column (msdn.microsoft.com/magazine/dn768854). But the downloadable program for this column, called Th reeRotatingTriangles, does indeed rotate that assemblage of three triangles. Th e eff ect is visually quite interesting, and as the three triangles move in relation to each other, the program does establish that there is indeed some 3D graphics processing going on. However, if you look at the code, you’ll discover that the program is still written entirely with Direct2D rather than Direct3D, using the powerful feature of Direct2D eff ects.

Getting Data into an EffectTh e overall organization of the earlier Th reeTriangles program has been preserved in Th reeRotatingTriangles. Th e class that provides the Direct2D effect implementation is now named Rotating-TriangleEff ect rather than SimpleTriangleEff ect, but it continues to implement the ID2D1Eff ectImpl (“eff ect implementation”) and ID2D1DrawTransform interfaces.

Th e earlier SimpleTriangleEff ect wasn’t versatile at all. It contained hardcoded vertices to display three overlapping triangles. Rotating-TriangleEff ect allows the vertices to be defi ned from outside the class, and both the eff ect implementation and the vertex shader have been enhanced to accommodate matrix transforms.

Generally, an eff ect implementation such as RotatingTriangle-Effect contains a static method that registers itself by calling RegisterEff ectFromString and associating itself with a class ID. In the ThreeRotatingTriangles program, the ThreeRotating-TrianglesRenderer class calls this static method in its constructor to register the eff ect.

Th reeRotatingTrianglesRenderer also defi nes an object of type ID2D1Eff ect as a private fi eld:

Microsoft::WRL::ComPtr<ID2D1Effect> m_rotatingTriangleEffect;

To use the eff ect, the program must create this object by referencing the eff ect’s class ID in a call to CreateEff ect. In the Th reeRotating-TrianglesRenderer class, this occurs in the CreateDeviceDependent-Resources method:

d2dContext->CreateEffect( CLSID_RotatingTriangleEffect, &m_rotatingTriangleEffect);

Th e eff ect can then be rendered with a call to the DrawImage method. Here’s how Th reeRotatingTrianglesRenderer makes the call in its Render method:

d2dContext->DrawImage(m_rotatingTriangleEffect.Get());

But there’s more that can be done between those two calls. ID2D-1Eff ect derives from ID2D1Properties, which has methods named SetValue and GetValue that allow a program to set properties on the eff ect. Th ese properties can range from simple eff ect options expressed as Boolean fl ags to large buff ers of data. However, SetValue and GetValue aren’t oft en used. Th ey require identifying the partic-ular property by index, and greater program clarity is obtained by instead using the methods SetValueByName and GetValueByName.

Keep in mind that these SetValueByName and GetValueByName methods are part of the ID2D1Eff ect object, which is the object returned from the CreateEff ect call. Th e ID2D1Eff ect object passes

Vertex Shaders and Transforms

DIRECTX FACTOR CHARLES PETZOLD

Code download available at msdn.microsoft.com/magazine/msdnmag0914.Figure 1 The ThreeRotatingTriangles Program Display

Page 87: MSDN September 2014

77September 2014msdnmagazine.com

the values of these properties to the eff ect implementation class you’ve written—the class that implements the ID2D1Eff ectImpl and ID2D1DrawTransform interfaces. Th is seems a bit roundabout, but it’s done this way so registered eff ects can be used without access to the classes that implement the eff ect.

But this means that an effect implementation such as the RotatingTriangleEff ect class must itself indicate that it can accept properties of various types, and it must provide methods for setting and getting those properties.

Th is information is provided by the eff ect implementation when it registers itself using RegisterEff ectFromString. Required in this call is some XML that includes the names and types of the various properties the eff ect implementation supports. RotatingTriangle-Effect supports four properties, with the following names and data types:

• VertexData of type blob, that is, a memory buff er referenced by a byte pointer.

• ModelMatrix of type matrix4x4.• ViewMatrix of type matrix4x4.• ProjectionMatrix of type matrix4x4.

Th e names of these data types are specifi c to Direct2D eff ects. When an effect that supports properties is registered, the effect implementation must also supply an array of D2D1_VALUE_TYPE_BINDING objects. Each of the objects in this array associates a named property, for example VertexData, with two methods in the eff ect implementation that set and get the data. For VertexData, the two methods are named SetVertexData and GetVertexData.

(When you defi ne these Get methods, make sure to include the const keyword, or you’ll get one of those weird template errors that will be completely baffl ing.)

Similarly, the RotatingTriangleEffect class defines methods named SetModelMatrix and GetModelMatrix, and so forth. Th ese methods aren’t called by any application program—indeed, they’re private to RotatingTriangleEffect. Instead, the program calls the SetValueByName and GetValueByName methods on the ID2D1Eff ect object, which then calls the Set and Get methods in the eff ect implementation.

The Vertex BufferTh e Th reeRotatingTrianglesRenderer class registers the Rotating-TrianglesEffect in its constructor, and renders the effect in its Render method. But between those two calls, the renderer class calls SetValueByName on the ID2D1Eff ect object to pass data into the eff ect implementation.

Th e fi rst of the four eff ect properties listed earlier is VertexData, which is a collection of vertices used to defi ne a vertex buff er. For Direct2D eff ects, the number of items in a vertex buff er must be a multiple of three, grouped into triangles. Th e Th reeRotatingTriangles program displays only three triangles with three vertices each, but the eff ect can handle a larger buff er.

Th e format of the vertex buff er expected by RotatingTriangle-Eff ect is defi ned in a structure in RotatingTriangleEff ect.h:

struct PositionColorVertex{ DirectX::XMFLOAT3 position; DirectX::XMFLOAT3 color;};

Th is is the same format used by SimpleTriangleEff ect, but defi ned somewhat diff erently. Figure 2 shows how the CreateDeviceDepen-dentResources method in Th reeRotatingTrianglesRenderer transfers the vertex array to the eff ect aft er the eff ect has been created.

Th e X and Y coordinates are based on sines and cosines of angles in 40-degree increments with a radius of 1,000. Th e Z coordinates range from –1,000 for the foreground to 1,000 for the background. In the earlier SimpleTriangleEffect I was very careful to set Z between 0 and 1 because of the conventions used to clip 3D out-put. As you’ll see, that’s not necessary here because actual camera transforms will be applied to the vertices.

The SetValueByName call with a name of VertexData causes the ID2D1Effect object to call the SetVertexBuffer method in RotatingTriangleEff ect to pass along the data. Th is method casts the byte pointer back to its original type and calls CreateVertex-Buff er to store the information in a way that allows it to be passed to the vertex shader.

void ThreeRotatingTrianglesRenderer::CreateDeviceDependentResources(){ ID2D1DeviceContext1* d2dContext = m_deviceResources->GetD2DDeviceContext();

// Create the effect DX::ThrowIfFailed(d2dContext->CreateEffect( CLSID_RotatingTriangleEffect, &m_rotatingTriangleEffect) );

// Set the vertices std::vector<PositionColorVertex> vertices = { // Triangle 1 { XMFLOAT3(0, -1000, -1000), XMFLOAT3(1, 0, 0) }, { XMFLOAT3(985, -174, 0), XMFLOAT3(0, 1, 0) }, { XMFLOAT3(342, 940, 1000), XMFLOAT3(0, 0, 1) },

// Triangle 2 { XMFLOAT3(866, 500, -1000), XMFLOAT3(1, 0, 0) }, { XMFLOAT3(-342, 940, 0), XMFLOAT3(0, 1, 0) }, { XMFLOAT3(-985, -174, 1000), XMFLOAT3(0, 0, 1) },

// Triangle 3 { XMFLOAT3(-866, 500, -1000), XMFLOAT3(1, 0, 0) }, { XMFLOAT3(-643, -766, 0), XMFLOAT3(0, 1, 0) }, { XMFLOAT3(643, -766, 1000), XMFLOAT3(0, 0, 1) } };

DX::ThrowIfFailed( m_rotatingTriangleEffect->SetValueByName(L"VertexData", (byte *) &vertices) ); // Ready to render! m_readyToRender = true;}

Figure 2 Creating the Effect and Setting the Vertex Buffer

For Direct2D effects, the number of items in a vertex buffer must be a multiple of three, grouped

into triangles.

Page 88: MSDN September 2014

msdn magazine78 DirectX Factor

Applying the TransformsFigure 3 shows the Update method in ThreeRotatingTriangles-Renderer calculating three matrix transforms and making three calls to SetValueByName. Th e code has been slightly simplifi ed to remove checks for errant HRESULT returns.

As usual, Update is called at the frame rate of the video display. Th e fi rst matrix it calculates is applied to the vertices to rotate them around the Y axis. Th e second matrix is a standard camera view transform that results in shift ing the scene so the viewer is on the origin of the three-dimensional coordinate system and looking straight along the Z axis. Th e third is a standard projection matrix, which results in X and Y coordinates being normalized to values between –1 and 1, and Z coordinates between 0 and 1.

Th ese matrices must be applied to vertex coordinates. So why doesn’t the program just multiply them by the array of vertices defi ned in the CreateDeviceDependentResources method and then set a new vertex buff er in the RotatingTrianglesEff ect?

It’s certainly possible to define a dynamic vertex buffer that changes at the frame rate of the video display, and in some cases it’s necessary. But if the vertices need only be modifi ed by matrix transforms, a dynamic vertex buff er isn’t as effi cient as maintaining the same buff er throughout the program and applying the trans-forms later on in the pipeline—specifi cally, in the vertex shader that’s running on the video GPU.

Th is means the vertex shader needs new matrix transforms for every frame of the video display, and that raises another issue: How does an eff ect implementation get data into the vertex shader?

The Shader Constant Buffer Data is transferred from application code into a shader through a mechanism called a constant buff er. Don’t let the name deceive you into thinking its contents remain constant throughout the course of the program. Th at’s defi nitely not the case. Very oft en the constant buff er changes with every frame of the video display. However, the contents of the constant buff er are constant for all the vertices in each frame, and the format of the constant buffer is fixed at compile time by the program.

Th e format of the vertex shader constant buff er is defi ned in two places: in C++ code and in the vertex shader itself. In the effect implementation, it looks like this:

struct VertexShaderConstantBuffer{ DirectX::XMFLOAT4X4 modelMatrix; DirectX::XMFLOAT4X4 viewMatrix; DirectX::XMFLOAT4X4 projectionMatrix;} m_vertexShaderConstantBuffer;

When the Update method in the renderer calls SetValueByName to set one of the matrices, the ID2D1Eff ect object calls the appropri-ate Set method in the RotatingTrianglesEff ect class. Th ese methods are named SetModelMatrix, SetViewMatrix, and SetProjection-Matrix, and they simply transfer the matrix to the appropriate fi eld in the m_vertexShaderConstantBuff er object.

Th e ID2D1Eff ect object assumes that any call to SetValueByName results in a change to the eff ect that probably involves a corresponding change to graphical output, so the PrepareForRender method is called in the eff ect implementation. It’s here the eff ect implementation can take the opportunity to call SetVertexShaderConstantBuff er to transfer the contents of the VertexShaderConstantBuff er to the vertex shader.

The New Vertex ShaderNow, finally, you can look at the High Level Shader Language (HLSL) code that’s doing much of the work in rotating the vertices of those three triangles and orienting them in 3D space. Th is is the new and improved vertex shader, shown in its entirety in Figure 4.

Notice how the structures are defi ned: Th e VertexShaderInput in the shader is the same format as the PositionColorVertex structure defi ned in the C++ header fi le. Th e VertexShaderConstantBuff er is the same format as the same-named structure in C++ code. Th e VertexShaderOutput structure matches the PixelShaderInput struc-ture in the pixel shader.

In the vertex shader associated with the SimpleTriangleEff ect in last month’s column, a ClipSpaceTransforms buff er was provided automatically to convert from scene space (the pixel coordinates used for the vertices of the triangles) to clip space, which involves normalized X and Y coordinates ranging from –1 to 1, and Z coordinates that range from 0 to 1.

Th at’s no longer necessary, so I removed it without any unfortunate consequences. Instead, the projection matrix does the equivalent job. As you can see, the main function applies the three matrices to the input vertex position, and sets the result to the clipSpaceOuput fi eld of the output structure.

void ThreeRotatingTrianglesRenderer::Update(DX::StepTimer const& timer){ if (!m_readyToRender) return;

// Apply model matrix to rotate vertices float angle = float(XM_PIDIV4 * timer.GetTotalSeconds()); XMMATRIX matrix = XMMatrixRotationY(angle); XMFLOAT4X4 float4x4; XMStoreFloat4x4(&float4x4, XMMatrixTranspose(matrix)); m_rotatingTriangleEffect->SetValueByName(L"ModelMatrix", float4x4);

// Apply view matrix matrix = XMMatrixLookAtRH(XMVectorSet(0, 0, -2000, 0), XMVectorSet(0, 0, 0, 0), XMVectorSet(0, 1, 0, 0)); XMStoreFloat4x4(&float4x4, XMMatrixTranspose(matrix)); m_rotatingTriangleEffect->SetValueByName(L"ViewMatrix", float4x4);

// Base view width and height on coordinates of model float width = 2000; float height = 2000;

// Adjust width and height for landscape and portrait modes Windows::Foundation::Size logicalSize = m_deviceResources->GetLogicalSize();

if (logicalSize.Width > logicalSize.Height) width *= logicalSize.Width / logicalSize.Height; else height *= logicalSize.Height / logicalSize.Width;

// Apply projection matrix matrix = XMMatrixOrthographicRH(width, height, 500, 4000); XMStoreFloat4x4(&float4x4, XMMatrixTranspose(matrix)); m_rotatingTriangleEffect->SetValueByName(L"ProjectionMatrix", float4x4);}

Figure 3 Setting the Three Transform Matrices

As usual, Update is called at the frame rate of the video display.

Page 89: MSDN September 2014

79September 2014msdnmagazine.com

Th at clipSpaceOutput fi eld is required. Th is is how the depth buff er is managed, and how the results are mapped to the display surface. However, the sceneSpaceOutput fi eld of the VertexShader-Output structure isn’t required. If you remove that fi eld—and also remove the fi eld from the PixelShaderInput structure of the pixel shader—the program will run the same.

Row Major and Column MajorTh e shader performs three multiplications of positions by matrices:

pos = mul(pos, modelMatrix);pos = mul(pos, viewMatrix);pos = mul(pos, projectionMatrix);

In mathematical notation, these multiplications look like this:

m11 m12 m13 m14m21 m22 m23 m24m31 m32 m33 m34m41 m42 m43 m44

|x y z w| ×

When this multiplication is performed, the four numbers that describe the point (x, y, z, w) are multiplied by the four numbers in the fi rst column of the matrix (m11, m21, m31, m41) and the four

products are summed, and then the process continues with the second, third and fourth columns.

Th e vector (x, y, z, w) consists of four numbers stored in adjacent memory. Consider hardware that implements parallel processing of matrix multiplication. Do you think it might be faster to perform these four multiplications in parallel if the numbers in each column were also stored in adjacent memory? Th is seems very likely, which implies the optimum way to store the matrix values in memory is the order m11, m21, m31, m41, m12, m22 and so forth.

Th at’s known as column-major order. Th e memory block begins with the fi rst column of the matrix, then the second, third and fourth. And this is what vertex shaders assume to be the organization of matrices in memory when performing these multiplications.

However, this isn’t the way DirectX normally stores matrices in memory. Th e XMMATRIX and XMFLOAT4X4 structures in the DirectX Math library store matrices in row-major order: m11, m12, m13, m14, m21, m22 and so forth. Th is seems like a more natural order to many of us because it’s similar to the order that we read lines of text—across and then down.

Regardless, there’s an incompatibility between DirectX and shader code, and that’s why you’ll notice in the code in Figure 3that every matrix is subjected to an XMMatrixTranspose call before being sent off to the vertex shader. Th e XMMatrixTranspose function converts row-major matrices to column-major matrices, and back again if you need that.

Th at’s the most common solution to this problem but it’s not the only solution. You can alternatively specify a fl ag to compile the shader for row-major order, or you can leave the matrices untransposed and just switch around the order of the matrix and the vector in the multiplications:

pos = mul(viewMatrix, pos);

The Final StepThe shading of the three triangles certainly demonstrates that vertex colors are interpolated over the surface of each triangle, but the result is rather crude. Surely I can do better in using this powerful shading tool to mimic the refl ection of light. Th at will be the fi nal step in this plunge into the versatile world of Direct2D.

CHARLES PETZOLD is a longtime contributor to MSDN Magazine and the author of “Programming Windows, 6th Edition” (Microsoft Press, 2013), a book about writing applications for Windows 8. His Web site is charlespetzold.com.

THANKS to the following Microsoft technical expert for reviewing this article: Doug Erickson

// Per-vertex data input to the vertex shaderstruct VertexShaderInput{ float3 position : MESH_POSITION; float3 color : COLOR0;};

// Per-vertex data output from the vertex shaderstruct VertexShaderOutput{ float4 clipSpaceOutput : SV_POSITION; float4 sceneSpaceOutput : SCENE_POSITION; float3 color : COLOR0;};

// Constant buffer provided by effect.cbuffer VertexShaderConstantBuffer : register(b1){ float4x4 modelMatrix; float4x4 viewMatrix; float4x4 projectionMatrix;};

// Called for each vertex.VertexShaderOutput main(VertexShaderInput input){ // Output structure VertexShaderOutput output;

// Get the input vertex, and include a W coordinates float4 pos = float4(input.position.xyz, 1.0f);

// Pass through the resultant scene space output value output.sceneSpaceOutput = pos;

// Apply transforms to that vertex pos = mul(pos, modelMatrix); pos = mul(pos, viewMatrix); pos = mul(pos, projectionMatrix);

// The result is clip space output output.clipSpaceOutput = pos;

// Transfer the color output.color = input.color;

return output;}

Figure 4 The Vertex Shader for the Rotating Triangle Effect

It’s certainly possible to defi ne a dynamic vertex buffer that

changes at the frame rate of the video display, and in some cases

it’s necessary.

Page 90: MSDN September 2014

msdn magazine80

I am 14 years old: a teenager who may one day join your geeky ranks (I’m also Dave’s daughter, but I try not to think about that). But before you dismiss me as a kid, consider this: I am your future. And this is how I see you.

We live in the golden age of geeks. Society would be helpless without you behind the scenes, running programs, slinging code and fi guring out ways to make devices and soft ware talk to each other. Without you, people would still be hunting and gathering and using Windows XP. Th e hours might be terrible, but at least you enjoy the respect of the lay folk

I can assure you that no such respect extends to middle school, where knowledge of who’s dating whom matters more than car-ing about and understanding the nuts and bolts on which our so-ciety and world depend. Schools don’t hang banners for academic achievements, or throw pep rallies for the coding team.

Th is irritates me. I have always carried an intense desire to know how things work. When I fi rst started reading, the only text editor software I knew of was NotePad. I wondered how the italics in books were done—handwritten in every copy of the book ever printed? When I was exposed to Microsoft Word, my world sud-denly expanded. My earliest questions were answered, but more emerged: How were diff erent-shaped and -sized letters and colors made? When I discovered fonts and colors, I had to change the

formatting of every paragraph because it was fun. I began to have the makings of a geek.

Geeks care about how things work—the universe, plants, car engines, atomic structure, anything. As author John Green says, “When people call you a [geek], they’re basically saying, ‘You like stuff .... You are too enthusiastic about the miracle of human consciousness!’”

But as a teenage girl, the challenge to be taken seriously as a geek is continual and exhausting. It has some advantages, such as intel-ligent discussions—three of my friends and I spent an entire study hall theorizing about time travel. It also comes with disadvantages, such as hanging out with guys who smell really bad, think they’re smarter than you when exactly the opposite is true, undermine your ideas because you’re a girl, or all of the above.

I’ve seen the soft ware industry’s eff orts to recruit more women in college, and sometimes high school. Let me tell you, that’s way too late. We’re making up our minds now—in seventh grade or even sixth. My teachers have (too oft en) expounded that during our middle school years we grow more than any other time of our lives outside of infancy. It is the perfect time to present soft ware as a career, at the moment when we are most malleable.

It wouldn’t be hard. Start coding clubs in middle school rather than high school. Have advisers personally reach out to invite girls, and encourage them to bring their friends. Have women from the industry present technical topics that we middle schoolers would fi nd cool. Imagine Parisa Tabriz, Google’s self-described “security princess,” talking about how to keep your accounts safe from prying parents!

Th at’s why I suggested to Dave at the beginning of the summer that I intern with him to experience what being a full-time geek really entails. He’s having me convert his favorite text-based Star Trek game to a Windows Forms program, and then to tablets and phones. (He’s such an old fart, but I do have to admit that blowing up Klingons is kind of addicting.) By the time you read this, I’ll have some idea if joining the geek ranks is what I want. I suppose a lot will depend on whether either of us is still alive.

Wish me luck, or better yet, wish Dave luck. He’s going to need it.

ANNABELLE ROSE PLATT is about to enter eighth grade in Ipswich, Mass. Her world greatly expanded at age 2, when she peeled the tape off her fi ngers and discov-ered the numbers 9 and 10. She does not agree with everything her father says.

A Girl’s Road to Geekdom

DON’T GET ME STARTED DAVID S. PLATT

I’ve seen the software industry’s efforts to recruit

more women in college, and sometimes high school. Let me

tell you, that’s way too late. We’re making up our minds now—in seventh grade or even sixth.

Page 91: MSDN September 2014

Untitled-2 1 5/31/13 10:57 AM

Page 93: MSDN September 2014

14 – 17 OCTOBER 2014 | HOTEL RUSSELL, LONDON

soft

war

e-ar

chit

ect.

co.u

k

SOFTWAREARCHITECT CONFERENCE

2014

World-renowned speakers, including

ALLEN HOLUB SIMON BROWN

RUTH MALAN NEAL FORD

and many more

Featuring 42 BREAKOUT

SESSIONS12 FULL-DAY WORKSHOPS

AGILE | ARCHITECTURE | BIG DATA | CLOUD | DATABASE | LEADERSHIP | MOBILE | PATTERNS PROGRAMMING | PROJECT MANAGEMENT | SECURITY | TEST | UI/UX | WEB

From the organisers of

THE TECHNICAL CONFERENCE FOR SOFTWARE ARCHITECTS AND SOFTWARE DEVELOPERS

BOOK NOWBOOK YOUR PLACE BY 1 AUGUST AND SAVE

UP TO £200

8 TH ANNUAL

Page 94: MSDN September 2014

S O F T W A R E A R C H I T E C TINTRODUCTION

We are delighted to announce that the 8th annual Software Architect Conference will be returning to London once again this October.

Software Architect returns in 2014 with more content than ever before. Featuring 12 full-day workshops and 42 focused 90-min breakout sessions, our expert speakers will ensure you and your team understand the fundamentals of software architecture and are up to date with the latest developments, ideologies and best practices.

A mixture of practical ‘real-world’ sessions alongside theoretical overviews and industry perspectives will allow you to walk away with new ideas and approaches on how to perform your job more e ectively.

So, if you are – or want to become – a software architect, we hope to see you in October!

The Software Architect Team

Welcome

2 | SOFTWARE ARCHITECT | so�ware-architect.co.uk

21

2014SPEAKERSSPEAKERS

MEET THE EXPERTSMEET THE EXPERTS

Top reasons to attend Software Architect 2014

12 Full-day workshopsThe pre- and post-conference workshops will ensure you increase your knowledge and gain practical advice to take back to the o�ce.

The wide range of workshops, covering topics such as mobile apps, Big Data, BDD, agile and much more, means there is something for everyone. Find out more about the workshops we have available on pages 6-7 and 12-13.

Create your own agendaThe main conference features six streamed tracks, covering a wide range of topics. As such, you can create your perfect agenda and make the most of your time at Software Architect.

To help you plan your time, the Software Architect website has an interactive agenda tool, allowing you to select the talks you want to attend and email your personalised agenda to yourself, your colleagues or even your boss – the perfect way to convince your management of why you need to attend! software-architect.co.uk/agenda

The 2014 speaker faculty is our most impressive yet! They are acknowledged experts in their field, many with international recognition. We are delighted to confirm that Allen Holub and Neal Ford will be delivering the keynote presentations this year, while the event also features sessions and workshops from highly-regarded authorities such as Simon Brown, Eoin Woods, Sander Hoogendoorn, Ruth Malan, Dino Esposito and many, many more! For a full run down on our 2014 speakers, please refer to pages 14-15.

Page 95: MSDN September 2014

VENUETHE HOTEL RUSSELL

INTRODUCTIONS O F T W A R E A R C H I T E C T

so�ware-architect.co.uk | SOFTWARE ARCHITECT | 3

To help you navigate the wealth of content at Software Architect 2014, all breakout sessions and workshops within this brochure have been colour-coded as a reference to the top-level topic they are covering. Please refer to the agenda guide below. A quick, at-a-glance agenda of the main conference days is available on pages 4-5. The full agenda for all four days, with presentation abstracts, can be found on pages 6-13. For more detailed presentation abstracts, please visit software-architect.co.uk/agenda

Agile Architecture Big Data Cloud Database Leadership/ Project

Management Mobile Patterns Programming Security Test UI/UX Web

Did you know?You can highlight your favourite sessions and create your own personalised agenda by using the interactive agenda at software-architect.co.uk/agenda

3 4

Agenda guide VenueWhen visiting the United Kingdom’s capital, there is no destination quite like the Hotel Russell. Situated in the very centre of London, in the heart of Bloomsbury, this historic building dominates the east side of Russell Square. Enjoy the peaceful, tranquil greenery of Russell Square Garden, while being close to all the attractions, financial and commercial districts of London. The Hotel Russell is ideally located, being only a 10-minute walk from Euston, St Pancras and Kings Cross stations. Right next door to the hotel you will find the Russell Square tube station, where a short journey on the Piccadilly Line will take you to Covent Garden, Piccadilly Circus and Leicester Square.

For more information, please visit hotelrusselllondon.co.uk

Address:Hotel Russell1-8 Russell SquareLondonWC1B 5BE

Phone:+44 (0) 2078 376 470

Share your ticketWith so much relevant content, we advise that you attend the whole event and bring some colleagues with you to ensure you see as many of the available sessions first-hand.

However, if you only have time to attend one day or others in your team need to attend in your place, you can share your ticket and ensure your company makes the most out of the full four days of sessions and workshops. Full details on how to share your ticket are outlined during the online booking process at software-architect.co.uk/book

Don’t miss a sessionCan’t be in two places at once? Catch up with any vital breakout sessions you missed, online, after the event.

With six concurrent tracks, there will inevitably be times when you have to choose between two equally important sessions. This year, you won’t miss out! All breakout sessions will be filmed and provided online for all registered delegates.

Page 96: MSDN September 2014

DAY 1 Pre-conference all-day workshops | Tuesday

WELCOME ADDRESS AND KEYNOTE PRESENTATION

DAY 2 Main conference | Wednesday11.30 14.009.30 16.00

S O F T W A R E A R C H I T E C TAT-A-GLANCE AGENDA

This at-a-glance agenda provides an overview of all the workshops and breakout sessions that are taking place over all four days of the event, allowing you to quickly highlight the key sessions you want to attend.

4 | SOFTWARE ARCHITECT | so�ware-architect.co.uk

AGILE/DESIGN FROM START TO FINISH

Workshop ref: SA01

Allen Holub

DESIGNING AND PROTOTYPING MOBILE APPLICATIONS

Workshop ref: SA02

Nathaniel Schutta

FORECASTING HORSE RACING FOR FUN AND PROFIT

Workshop ref: SA03

Gary Short

SECURING ASP.NET APPLICATIONS AND SERVICES: FROM A-Z

Workshop ref: SA04

Ido Flatow

ARCHITECTING: IT’S (NOT) WHAT YOU THINK

Workshop ref: SA05

Ruth Malan

BDD BY EXAMPLE

Workshop ref: SA06

Seb Rose

MIND THE GAP: ARCHITECTING UIS IN THE ERA OF DIVERSE DEVICES

Nathaniel Schutta

Austin Bingham

OPEN DECISIONS IN ARCHITECTURAL EVOLUTION

Eoin Woods

SYSTEM SECURITY BEYOND THE LIBRARIES

Sander Hoogendoorn

SHAPING SERVICE ORIENTATION WITH SMART USE CASES

Jules May

IF CONSIDERED HARMFUL: HOW TO ERADICATE 95% OF ALL YOUR BUGS IN ONE SIMPLE STEP

Michael Kennedy

HIGH-PERFORMANCE NOSQL TECHNIQUES IN .NET

MODERN BACKENDS FOR MOBILE APPS

Sasha Goldshtein

Howard Deiner

LEAN THINKING AND WHAT IT MEANS TO THE AGILE MINDSET

Ed Courtenay

AN INTRODUCTION TO TYPESCRIPT

Neal Ford

EMERGENT DESIGN

Seb Rose

MUTATION TESTING – BETTER CODE BY MAKING BUGS

Gary Short

FROM ZERO TO HADOOP

THE SKETCHY THING AND THE COMEBACK OF FLOWCHARTS AND TOP-DOWN DESIGN

Dino Esposito

Brian A. Randell

BUILDING A DEVOPS CULTURE

Ido Flatow

BUILDING SCALABLE, DURABLE AND SECURED WEB APPLICATIONS WITH THE MICROSOFT AZURE PLATFORM

Nuno Filipe Godinho

IOT & M2M: HOW ARE THEY CHANGING THE WORLD WE LIVE IN?

Allen Holub

TDD, BDD & ATDD: TEST-, BEHAVIOUR- AND ACCEPTANCE-TEST-DRIVEN DEVELOPMENT

Jules May

BIG DATA AND PRIVACY

BOOK NOW

BOOK YOUR PLACE BY 1 AUGUST AND SAVE

UP TO £200

Neal Ford

Allen Holub

THIS IS WATERIn this keynote, Neal will describe the water you swim in but cannot see anymore, such as relational databases and application servers. And he will jerk you out of this water (briefly) to describe a strange, fantastical world with things such as immutable database servers and phoenix machines.

THE DEATH OF AGILEIn this keynote, Allen will look at the state of the agile community as it moves away from the basic principles of agility, at how we got to that state, and at what we need to do to fix things (or get o« on the right foot if you’re just starting the journey).

Page 97: MSDN September 2014

DAY 3 Main conference | Thursday11.30 14.009.30 16.00

CONTINUOUS DELIVERY

Workshop ref: SA07

Neal Ford

END-TO-END SPA DEVELOPMENT

Workshop ref: SA08

Gil Fink & Ido Flatow

LIGHTWEIGHT AGILE SOFTWARE ARCHITECTURE FOR TEAMS

Workshop ref: SA09

Ralf Westphal

A DAY OF DESIGN PATTERNS AND TESTING

Workshop ref: SA10

Andy Clymer & Richard Blewett

BUILDING DATA-DRIVEN MOBILE APPS USING AMAZON WEB SERVICES

Workshop ref: SA11

Paul Ardeleanu

APPLIED BDD WITH CUCUMBER, CUCUMBER-JVM AND SPECFLOW

Workshop ref: SA12

Seb Rose

DAY 4 Post-conference all-day workshops | Friday

AT-A-GLANCE AGENDAS O F T W A R E A R C H I T E C T

so�ware-architect.co.uk | SOFTWARE ARCHITECT | 5

ALSO EACH DAY: ®8 8.30 Co«ee & registration | ® 11.00 Co«ee break | 13.00 Lunch break | ® 15.30 Co«ee break3

C# EVERYWHERE: CROSS-PLATFORM APPS WITH XAMARIN

Sasha Goldshtein

Sander Hoogendoorn

INDIVIDUALS AND INTERACTIONS OVER PROCE$$E$ AND FOOLS

Nuno Filipe Godinho

ARCHITECTURE BEST PRACTICES ON WINDOWS AZURE

Brian A. Randell

VISUAL STUDIO ONLINE: AN UPDATE EVERY THREE WEEKS

Dino Esposito

DDD MISCONCEPTIONS

Gary Short

BEST PRACTICE ARCHITECTURE IN HETEROGENEOUS BIG DATA STORES

MOBILISING WEBSITES

Jules May

Robert Smallshire

CONDUCTING A SOFTWARE ARCHITECTURE REVIEW

Shay Friedman

ANGULARJS: THE ONE FRAMEWORK TO RULE THEM ALL

Simon Brown & Eoin Woods

MODELS, SKETCHES AND EVERYTHING IN BETWEEN

Ed Courtenay

WHAT ARE AUTO-MOCKING CONTAINERS AND WHY SHOULD YOU USE THEM?

János Fehér

CREATING ADAPTIVE ARCHITECTURE WITH ZEROMQ

SWIFT: APPLE’S NEW PROGRAMMING LANGUAGE FOR IOS AND OS X

Sasha Goldshtein

Seb Rose

LIES, DAMN LIES AND ESTIMATES

Brian A. Randell

APPLICATION ANALYTICS – ADD THE RIGHT FEATURES TO YOUR APP

Neal Ford

CONTINUOUS DELIVERY FOR ARCHITECTS

Allen Holub

DESIGN PATTERNS IN THE REAL WORLD

Nuno Filipe Godinho

BIG DATA IN THE ENTERPRISE

BUILDING A MOBILE COMPETENCY CENTRE

Nathaniel Schutta

Howard Deiner

AGILE/LEAN STARTUP IT PORTFOLIO MANAGEMENT – NO LONGER OXYMORPHIC!

Allen Holub

WEB APPLICATION ARCHITECTURE: THE WHOLE STACK

Ralf Westphal

LET SOFTWARE DESIGN COME TO LIFE USING SOFTWARE CELLS

Gil Fink

QUICK TOUR TO FRONT-END TESTING USING JASMINE

Michael Kennedy

APPLIED NOSQL WITH MONGODB AND PYTHON

Page 98: MSDN September 2014

S O F T W A R E A R C H I T E C T

The following workshops run for a full day, from 09:30 to 17:30 with a short break in the morning and afternoon, and a lunch break at 13:00. You either require a one-day workshop pass to attend OR you can book a 3-day Pass or Universal Pass and attend the main conference sessions as well.

AGILE/DESIGN FROM START TO FINISH

Agile systems are, by necessity, tightly coupled to the user’s notion of what the system is doing. Without that connection, the software can’t stand up to the stress of constant change that all agile processes mandate. Moreover, the process that you use influences the architecture of your system. That’s why hybrid processes that attempt to mix agile and traditional practices often fail. The hybrid architectures that come out of those processes are unworkable.

In this workshop, Allen talks about both process and architecture. We’ll look at how agile processes work, and show how both architecture and low-level design naturally fall out of those processes. Specifically, we’ll look closely at the role of stories, at how they’re created and developed, and how they flow through the process, with a focus on how to develop an optimal architecture that closely mirrors both the stories themselves and the assumptions that underlie the stories.

We’ll also work through a real-world example that demonstrates the process from front to back: requirements gathering and problem-statement definition, story development (use-case analysis), and the simultaneous construction of the light-weight dynamic and static models that underlie the code.

Workshop ref: SA01

Allen Holub

DESIGNING AND PROTOTYPING MOBILE APPLICATIONS

Nathaniel Schutta

FORECASTING HORSE RACING FOR FUN AND PROFIT

Data Science and Big Data are both hot topics at the moment, and while it is true that data science can be hard, it can also be fun! Trying to learn the techniques in classical and Bayesian statistics from abstract example in textbooks and web pages can be a real challenge, and when you throw in Machine Learning, it can become almost impossible to fathom.

In this workshop, Gary will use the medium of predicting horse racing results in order to anchor your learning in something concrete (and fun). Throughout the day, we’ll explore and implement a number of regression models from classic statistics, before going on to look at the impact Bayesian Inference can have on the problem. After lunch, we’ll throw a few Machine Learning techniques into the mix, to ensure you have a view of the problem using all the “data science toys”.

Lastly, we’ll round out the day by combining a few of these into a powerful “mixed model” prediction engine, learning how to weight the output from each model, thus creating a powerful prediction engine that we can use to predict horse racing results.

Workshop ref: SA03

Gary Short

Tues

day

14 O

ctob

erDAY 1: ALL-DAY PRE-CONFERENCE WORKSHOPS

6 | SOFTWARE ARCHITECT | so�ware-architect.co.uk

BOOK BOOK NOW

BOOK YOUR PLACE BOOK YOUR PLACE BY BY B1 AUGUST AND SAVE 1 AUGUST AND SAVE

UP TO £200UP TO £200

DAY 1 Pre-conference all-day workshops | Tuesday

The word just came down from the VP: you need a mobile app and you need it yesterday. Wait, you’ve never built a mobile app... It’s pretty much the same thing as you’ve built before, just smaller, right? Wrong. The mobile experience is di«erent and far less forgiving. How do you design an application for touch? How does that di«er from a mouse? Should you build a mobile app or a mobile web site?

In this workshop, Nathaniel will get you started designing for a new and exciting platform. Whether that means iPhone, Android, Windows Phone or something else, you need a plan – and this workshop will help.

We’ll start by discussing what it means to design within the constraints of mobile devices. Using a widely used web site, we’ll drive through the design process, creating personas and talking about what capabilities they would need in a mobile context.

In the second part of this all-day workshop, we’ll leverage jQuery Mobile to prototype the designs we created in the morning. Even if you decide to build a native application, jQuery Mobile is an invaluable tool; using HTML5 and simple conventions, you can quickly and painlessly build interactive web sites.

Workshop ref: SA02

Great range of speakers & topics, giving plenty of food for thought and tools to take back to work.TECHNICAL ARCHITECT

Page 99: MSDN September 2014

SECURING ASP.NET APPLICATIONS AND SERVICES: FROM A-Z

When you think of ASP.NET security, the first thing that comes to mind are Windows authentication and Forms authentication using ASP.NET Membership. For years, those were the common authentication techniques for ASP.NET applications and services. But with the new releases to the ASP.NET Identity system, those days are long gone. For the enterprise, ASP.NET broadened its support from the on-premises Active Directory to include Microsoft Azure Active Directory. By supporting external identity providers, such as Facebook, Microsoft Account and Twitter, the new ASP.NET Identity system makes the process of securing an application less scary than ever.

In this workshop, Ido will start from the basics: getting to know concepts such as SSL, OAuth, OpenID and claim-based authorisation. From there we will continue to explore the various scenarios of using self-managed identities, Active Directory and ADFS, external identity providers (Facebook, Google, Microsoft), and Microsoft Azure Active Directory.

Workshop ref: SA04

Ido Flatow

ARCHITECTING: IT’S (NOT) WHAT YOU THINK

The arc of software architecture encompasses various decisions and considerations, resolving important sets of interacting tensions. Among them:

• Strategic and structural significance: identifying strategic outcomes and defining challenges; design of system capabilities and system structure; system qualities and mechanism design

• Decision scope: decisions at broader scopes (system, mechanism, service) and decisions at narrow or local scopes (units), considering intentionality and emergence

• Timing of decisions: clearing the fog of uncertainty/putting ground under the feet and the “last responsible moment”, iteration and evolution

In this workshop, we will spend time with the

usual suspects – (re)factoring, dependencies, naming, forces, trade-o s, mechanism design, system and component boundaries and interaction surfaces. And some sketchy ones – making the system design visual and drawing people in. We will take some silver bullets – relationships of goodwill and commitment to objectivity – to heart, and be playful. And we will take our fallibilities, biases and foibles into account.

How? That is indeed it. Our focus will be on how.

We will create a draft (set of views of the) software architecture to situate our discussions and practice system thinking and modelling, strategic thinking (understanding what is shapingly important in the user context and business and technology space), and design improvement strategies. Our orientation is the co-creation of systems that have desired structural integrity properties, including resilience, but also design integrity and dynamic unity.

Our goal is to surface key matters of architectural

judgment, drawing out myths and misconceptions, and sharing, positioning and connecting useful conceptions, strategies and techniques, and laws, principles, heuristics and other guidance.

Workshop ref: SA05

Ruth Malan

BDD BY EXAMPLE

In this workshop, Seb will provide a practical introduction to using examples to specify software. You will learn to break down complex business requirements with your stakeholders, using examples in their own language, giving you the tools you need to explore their ideas before you even write any software.

This workshop is for everybody involved in the process of developing software, so please bring product owners, testers and architects along. As well as describing what BDD is (and isn’t), we’ll spend a lot of time practicing collaborative analysis to make sure that our stories are appropriately sized, easy to read and unambiguous. We’ll develop a “ubiquitous language”, explore the workings of the Three-Amigos meeting, and really get to grips with the slippery interaction between features, stories, acceptance criteria and examples.

Before the day is over, we’ll also take time to discuss:

• How BDD relates to SBE, ATDD and TDD • Approaches to the cost/benefit trade-off of

test automation • Where BDD fits into your existing

development process • The benefits of “living documentation”

 We’ll use pens, cards and other bits of paper, so

you won’t need to know any tools in advance, or even remember your laptop!

To build further on these ideas, don’t miss Seb’s post-conference workshop: “Applied BDD with Cucumber, Cucumber-JVM and SpecFlow”.

Workshop ref: SA06

Seb Rose

DAY 1: ALL-DAY PRE-CONFERENCE WORKSHOPSS O F T W A R E A R C H I T E C T

so�ware-architect.co.uk | SOFTWARE ARCHITECT | 7

BETWEEN SESSIONS: ®8 8.30 Co«ee & registration | ® 11.00 Co«ee break | 13.00 Lunch break | ® 15.30 Co«ee break3

Page 100: MSDN September 2014

Wed

nesd

ay 1

5 O

ctob

er

11.309.30

WELCOME ADDRESS AND KEYNOTE PRESENTATIONS

THIS IS WATER A fish is swimming along, having some breakfast, when suddenly he’s snatched out of his world by his food; abruptly ejected into a bright world where it’s hard to breathe; landing on the bottom of a boat,

where strange alien creatures make strange sounds. Overhead, he sees an airplane flying at 500mph. Suddenly, one of the creatures picks him up, removes the hook, and, just as suddenly, he’s back home. Yet, when he regales his friends with this tale, no one can believe such a strange world can exist.

In this keynote, Neal will describe the water you swim in but cannot see anymore, such as relational databases and application servers. And he will jerk you out of this water (briefly) to describe a strange, fantastical world with things such as immutable database servers and phoenix machines.

You may have trouble getting your friends who didn’t attend to understand.

THE DEATH OF AGILEAt the very top of the Agile Manifesto is the statement: “Individuals and interactions over processes and tools”. In spite of that thought (and its prominence), the word “agile” has come more

and more to mean rigid adherence to specific processes and the tools that support those processes. Moreover, many of these processes are incomplete – Scrum, for example, uses only two of the 13 practices that make up XP – and process adherents rarely add in the missing pieces. The word “agile”, however, certainly applies to the process itself.

In this keynote, Allen will look at the state of the agile community as it moves away from the basic principles of agility, at how we got to that state, and at what we need to do to fix things (or get o  on the right foot if you’re just starting the journey).

Eoin Woods

SYSTEM SECURITY BEYOND THE LIBRARIES Security is now important to all of us, not just people who work at Facebook. But it is a complicated domain, with a lot of concepts to understand. In any technical ecosystem, there is a blizzard of security technology, as well as generic concepts such as keys, roles, certificates, trust, signing and so on. Yet, none of this is useful unless we know what problem we’re really trying to solve. In this session, Eoin will dive into the fundamentals of system security in order to decide how to secure our systems.

S O F T W A R E A R C H I T E C TDAY 2: TIMETABLE OF EVENTS

8 | SOFTWARE ARCHITECT | so�ware-architect.co.uk

Austin Bingham

OPEN DECISIONS IN ARCHITECTURAL EVOLUTION Evolving software architectures involves balancing many factors, and maintaining that balance can be challenging for any architect. By opening up the decision process for evolution, we can harness the insight of fellow developers, communicate plans and designs more e ectively, and produce a useful record of the work we do. In this session, Austin will look at a specific lightweight technique – “Open Design Proposals” – which has proven its e ectiveness in many projects.

Sander Hoogendoorn

SHAPING SERVICE ORIENTATION WITH SMART USE CASES Although many organisations apply service-oriented architecture at the core of their software development e orts, executing such projects is hard. There are many di erent stakeholders, even external to the organisation. And then there are many di erent types of deliverables. In this session, Sander will walk you through the di«culties that surround service-oriented projects, but will also demonstrate the use of a particularly useful modelling technique, called “smart use cases”.

Nathaniel Schutta

MIND THE GAP: ARCHITECTING UIS IN THE ERA OF DIVERSE DEVICESArchitecting and developing user interfaces used to be relatively easy: pick a server-side framework, define a standard monitor resolution, and spend your days dealing with browser quirks. But today, the landscape presents us with a plethora of screen sizes and resolutions, covering everything from a phone to a tablet to a TV. How does a team embrace this brave new world, knowing that the future will introduce even more volatility to the client space?

Jules May

IF CONSIDERED HARMFUL: HOW TO ERADICATE 95% OF ALL YOUR BUGS IN ONE SIMPLE STEP In 1968, CACM published a letter from Edgar Dijkstra, called “Go To statement considered harmful”. In it, he explained exactly why most bugs in programs were caused by Gotos, and he appealed for Goto to be expunged from programming languages. But Goto has a twin, which is responsible for nearly every bug that appears in our programs today. That twin is “If”. In this session, Jules will show why If and Goto have the same pathology.

Michael Kennedy

HIGH-PERFORMANCE NOSQL TECHNIQUES IN .NET You’re one of the brave ones who has jumped into the NoSQL pool and found it a refreshing change. That’s awesome. But there is so much more to being successful with NoSQL databases than simply getting started. In this session, Michael will explore some of the issues, techniques and best practices for being successful with NoSQL, in general, and MongoDB, in particular. This includes exploring correct document/entity design, indexes and deployment – to name just a few of the topics.

BOOK BOOK NOW

BOOK YOUR PLACE BOOK YOUR PLACE BY BY B1 AUGUST AND SAVE 1 AUGUST AND SAVE

UP TO £200UP TO £200

Neal Ford

Allen Holub

Take a closer look at the abstracts for all the sessions during the main conference on Wednesday, 15 October. For more detailed abstracts, please visit: software-architect.co.uk/agenda

DAY 2 Main conference | Wednesday

Page 101: MSDN September 2014

14.00 16.00

so�ware-architect.co.uk | SOFTWARE ARCHITECT | 9

DAY 2: TIMETABLE OF EVENTSS O F T W A R E A R C H I T E C T

BETWEEN SESSIONS: ®8 8.30 Co«ee & registration | ® 11.00 Co«ee break | 13.00 Lunch break | ® 15.30 Co«ee break3

Ed Courtenay

AN INTRODUCTION TO TYPESCRIPT JavaScript is the scripting glue that holds the web together – largely because of its flexibility. This flexibility also means that it can be di«cult to manage, especially in large-scale applications. In this session, Ed will demonstrate how TypeScript can help to tame new and existing client-side code. Using real-world examples, we will explore some of the problems with client-side JavaScript development as a motivating example, and introduce TypeScript as a way of solving some of these issues.

Howard Deiner

LEAN THINKING AND WHAT IT MEANS TO THE AGILE MINDSET Long before the agile revolution, industry had learned that e«cient production of goods required intense attention to quality, teamwork and continuous improvement. These themes of lean manufacturing were never part of the original formulation of the Agile Manifesto, and are rarely mentioned as part of the traditional agile/scrum recipe. In this session, Howard will teach the basics of lean, and demonstrate how they apply to agile development.

Neal Ford

EMERGENT DESIGN The hazard of Big Design Up Front in software is that you don’t yet know what you don’t know, and design decisions made too early are just speculations without facts. Emergent design techniques allow you to wait until the last responsible moment to make design decisions. In this session, Neal will cover four areas: emergent design enablers, battling things that make emergent design hard, finding idiomatic patterns, and how to leverage the patterns you find.

Sasha Goldshtein

MODERN BACKENDS FOR MOBILE APPS In this session, Sasha will explore cloud backend providers that take away the burden of managing servers and infrastructure for your mobile apps. Backend concerns for mobile apps include data storage, e«cient queries, push notifications and user authentication. We will explore the system architecture and concrete design for mobile apps that rely on Azure Mobile Services, Facebook Parse and cloud storage providers as a ready-made backend.

Seb Rose

MUTATION TESTING – BETTER CODE BY MAKING BUGS Do you know how good your tests are? Mutation testing can tell you. Unlike test coverage metrics, mutation testing lets us say something concrete about the quality of your test suite. Mutation testing has been around for years, but it’s only recently that performance tools (such as PITest for Java) have become available. In this session, Seb will look at the motivation and technology behind mutation testing and see some examples in action.

Gary Short

FROM ZERO TO HADOOP In this session, Gary will show you how to get started with Hadoop on a Microsoft platform. We’ll cover installation and exploration of the environment, before going on to learn how to write map reduce functions in C#, Pig and Hive.

Ido Flatow

BUILDING SCALABLE, DURABLE AND SECURED WEB APPLICATIONS WITH THE MICROSOFT AZURE PLATFORM We always hear tips about the patterns and practices of building web applications with Microsoft Azure. It’s time we see how it is done! In this session, Ido will construct a secured, durable, scalable, low-latency web application with Microsoft Azure – including hosting, storage, database, cache and Active Directory.

Brian A. Randell

BUILDING A DEVOPS CULTURE At the end of the day, development and operations departments exist to delight customers and help the business achieve its goals. The promise of DevOps is to create a closed-loop process, where traditional silos are replaced with collaborative teams that can respond to issues – both technological and business – with agility. In this session, Brian will show how an emphasis on people with better process and some tools can help you achieve a culture of DevOps within your organisation.

Nuno Filipe Godinho

IOT & M2M: HOW ARE THEY CHANGING THE WORLD WE LIVE IN? Internet of Things (IoT) is here and every day a new sensor or device starts to generate more data. With that, more and more Machine-to-Machine (M2M) communications occur, which means our solutions have new issues to face. In this session, Nuno will look at how these new “buzz words” are changing the world we live in, from fitbit to Google Glass and smart watches. How can we prepare for this? How can we get some business opportunities from it?

Dino Esposito

THE SKETCHY THING AND THE COMEBACK OF FLOWCHARTS AND TOP-DOWN DESIGN Always neglected in favour of domain analysis and modelling, the presentation layer of most applications hardly receives due attention. Meanwhile, a new generation of users is emerging that is much less forgiving, while also dictating UI constraints to architects and developers. In this session, Dino discusses a design approach that starts from requirements and builds the system from top to bottom.

Allen Holub

TDD, BDD & ATDD: TEST-, BEHAVIOUR- AND ACCEPTANCE-TEST-DRIVEN DEVELOPMENT TDD (and its specialisations: BDD and ATDD) is a dynamic design process particularly suited for agile environments. That is, (T/B/AT)DD is really a design, not a testing strategy. But it’s a design strategy that produces a set of very useful tests as a by-product. By building acceptance tests around tentative interfaces, then incrementally refining those interfaces using tests, you both design and code simultaneously in a way that yields an optimal design.

Jules May

BIG DATA AND PRIVACY We have been talking about Big Data for several years now, but Care.data and Edward Snowden have brought home to the non-technical public just what Big Data really implies – both the benefits and the risks. In doing so, it has opened up a whole new debate that is going to concern not just Big Data processors, but anyone who handles any kind of personal data. Our notion of privacy is about to change, and new regulation is not far behind. If you handle data, even anonymous data, things are about to get interesting.

Page 102: MSDN September 2014

Thur

sday

16

Oct

ober

11.309.30

BOOK BOOK NOW

BOOK YOUR PLACE BOOK YOUR PLACE BY BY B1 AUGUST AND SAVE 1 AUGUST AND SAVE

UP TO £200UP TO £200

DAY 3: TIMETABLE OF EVENTSS O F T W A R E A R C H I T E C T

10 | SOFTWARE ARCHITECT | so�ware-architect.co.uk

Shay Friedman

ANGULARJS: THE ONE FRAMEWORK TO RULE THEM ALL In the last couple of years we’ve seen the rise of client-side JavaScript frameworks. From almost nothing, we now have at least a dozen to choose from. One of the new kids in the block, AngularJS, comes straight from the Google o«ces and tries to stand out from the crowd with a complete set of tools and utilities. In this session, Shay will go through the di erent features of AngularJS and see what makes it one of the most popular JavaScript frameworks out there.

Robert Smallshire

CONDUCTING A SOFTWARE ARCHITECTURE REVIEW A project struggling to deliver the right balance of qualities; due diligence in advance of an acquisition; an independent assessment of software you have commissioned – these are all good motivations for a software architecture review – a candid examination of how a software design resolves the forces acting upon it. But how to conduct an architecture review? In this session, Robert will define goals for a review, explain who needs to be involved, when and why, and discuss key topics you should cover.

Simon Brown & Eoin Woods

MODELS, SKETCHES AND EVERYTHING IN BETWEEN Just the mention of the word “modelling” brings back horrible memories of analysis paralysis for many software developers. And, in their haste to adopt agile approaches, we’ve seen countless software teams who have thrown out the modelling baby with the process bathwater. In extreme cases, this has led to the creation of software systems that really are the stereotypical “big ball of mud”. In this session, Simon and Eoin will discuss models, sketches and everything in between.

Jules May

MOBILISING WEBSITES The major challenge facing today’s web site designers is adapting content to a range of distinct clients. Mobile and tablet versions are in the news just now, but there’s also integration with on-device apps, interfaces for disabled users, rights management and white-labelling. In this session, Jules will describe how he built an “impedance-matching” function at the server, downstream of the application, performing technical negotiation with the client, and delivering multiple user experiences from a single application.

Ed Courtenay

WHAT ARE AUTO-MOCKING CONTAINERS & WHY SHOULD YOU USE THEM? Explore how to use auto-mocking containers to improve and streamline your unit tests, and also how to exercise your IoC container in a testable fashion. In this session, Ed will cover lessons learned from a large development project that can help you avoid the same pitfalls in your own code. Starting from a simple project, the fragility of existing unit tests will be demonstrated, and we will see how developers can be discouraged from making comprehensive tests.

János Fehér

CREATING ADAPTIVE ARCHITECTURE WITH ZEROMQ In this session, János will demonstrate how architects and lead engineers can design a flexible but lightweight distributed architecture with ZeroMQ. At Intern Avenue, with this pattern, his team were able to glue together di erent frameworks and programming languages. When they separated components, the architecture was flexible enough to scale without changing the code from inter-process communication, to Unix socket-based to a clustered solution.

Nuno Filipe Godinho

ARCHITECTURE BEST PRACTICES ON WINDOWS AZURE When new technologies and paradigms appear, it is essential to learn them quickly and well. But this can be very hard, since some things are only learned with experience. In this session, Nuno will look at some architecture best practices that will help us make our solutions better across several levels, including performance, cost, integration, security and so on. By doing this, you’ll gain the knowledge needed to quickly start using the technology and paradigms that can improve your business.

Sander Hoogendoorn

INDIVIDUALS AND INTERACTIONS OVER PROCE$$E$ AND FOOLS The first statement in the Agile Manifesto clearly favours individuals, teams, interaction and collaboration over processes and tools. But there are two sides to every story. When it comes to tools, the Agile Manifesto is often misinterpreted in that it is not allowed to use tooling in agile projects. In this session, Sander will shine his critical light on the sense and nonsense of tools in the agile field, from post-its and brown-paper to wikis, agile dashboards and Scrumdamentalism.

Brian A. Randell

VISUAL STUDIO ONLINE: AN UPDATE EVERY THREE WEEKS If you’re looking for a no-hassle way to manage your development team’s assets using centralised version control or Git; if you want to track your work on projects big or small; if you want to have elastic build servers on demand; and even monitor your apps for availability; then Brian’s insights into Visual Studio Online might be for you. Whether you build Windows apps, OS/X apps, mobile apps on iOS or Android – and even Linux – you’ll have something to see.

Sasha Goldshtein

C# EVERYWHERE: CROSS-PLATFORM APPS WITH XAMARIN Are you a C# developer? Do you need to develop an iOS, Android, Windows Phone app? You can write your app in C# and share up to 90% of the code using Xamarin’s tools. In this session, Sasha will develop a cross-platform C# app that uses Xamarin to run on iOS, Android and Windows Phone. We’ll talk about developing views for each platform, sharing business logic and accessing HTTP services. We will also discuss options for introducing a cross-platform MVVM design into your app.

Dino Esposito

DDD MISCONCEPTIONS For too long, domain-driven design (DDD) has been sold as the ideal solution for very complex problems that only a few teams are actually facing. While technically correct, this statement sparked a number of misconceptions. In this session, Dino will clear the ground around DDD, emphasising the theoretical pillars of the approach: ubiquitous language and bounded context. From there, he’ll move ahead to creating a context map and then finally touch on the most commonly used supporting architectures for DDD.

Gary Short

BEST PRACTICE ARCHITECTURE IN HETEROGENEOUS BIG DATA STORESIn this session, Gary will cover best practice architectures for heterogeneous Big Data stores, covering SQL, NoSQL and distributed systems, and how best to make them interoperable.

DAY 3 Main conference | Thursday

Take a closer look at the abstracts for all the sessions during the main conference on Thursday, 16 October. For more detailed abstracts, please visit: software-architect.co.uk/agenda

Page 103: MSDN September 2014

14.00 16.00

DAY 3: TIMETABLE OF EVENTSS O F T W A R E A R C H I T E C T

so�ware-architect.co.uk | SOFTWARE ARCHITECT | 11

BETWEEN SESSIONS: ®8 8.30 Co«ee & registration | ® 11.00 Co«ee break | 13.00 Lunch break | ® 15.30 Co«ee break3

Brian A. Randell

APPLICATION ANALYTICS – ADD THE RIGHT FEATURES TO YOUR APP You’ve shipped your first app. Now what? Your backlog is a mile long with wishes from users, as well as your great ideas. But what should you implement? In this session, Brian will first introduce the what and the how of application analytics. He’ll then dig into options you can use, both free and paid, to instrument your cross-platform solutions, giving you the right information from your users, so that you can build the next best release of your app.

Seb Rose

LIES, DAMN LIES AND ESTIMATES Are estimates an essential part of project planning and delivery, or a waste of everybody’s time? As is so often the case, the answer is neither and both. In this session, Seb will demonstrate that there is more than one kind of estimate, and examine how they are typically used in an agile context. In doing so, we will look at what some of the great minds have said on the subject, from Disraeli to Steve McConnell. Ultimately, Seb may not change your mind, but he intends to widen your perspective.

Neal Ford

CONTINUOUS DELIVERY FOR ARCHITECTS Continuous delivery is a process for automating the production readiness of your application every time a change occurs – to code, infrastructure or configuration. In this session, Neal takes a look at the intersection of the architect role and the engineering practices in continuous delivery. In the continuous delivery world, rather than hone skills at predicting the future via Big Design Up Front, the emphasis lies with techniques for understanding and changing code with less cost during the process.

Sasha Goldshtein

SWIFT: APPLE’S NEW PROGRAMMING LANGUAGE FOR IOS AND OS X At WWDC 2014, Apple announced Swift, a new programming language for iOS and OS X. In this session, Sasha will review Swift’s fundamental concepts, including built-in types and collections, optionals, closures, protocols, extensions, generics and custom operators. We will see how Swift improves on Objective-C in terms of type safety, readability and developer productivity, and demonstrate Swift’s capabilities by building a simple iOS application from the ground up.

Allen Holub

DESIGN PATTERNS IN THE REAL WORLD Design patterns do not exist in splendid isolation. In the real world, patterns overlap one another and interact in complex ways. In this session, Allen takes a unique approach to teaching patterns by analysing a real computer program in terms of the patterns used to implement it. We’ll look at how the design patterns are actually used in practice, and see how the strengths and weaknesses of the patterns play o  one another.

Nuno Filipe Godinho

BIG DATA IN THE ENTERPRISE Big Data is a popular topic at this point. However, when we talk about large enterprises, we see that a lot of them are still struggling; trying to understand what data makes sense. How can it be integrated with the current IT infrastructure? How to solve the data ingestion problem? In this session, Nuno will be looking at techniques based on real-world experiences that can be used by enterprises to solve these issues in a way that will allow them to take control of Big Data scenarios without losing control of their data.

Allen Holub

WEB APPLICATION ARCHITECTURE: THE WHOLE STACK In this session, Allen will provide an integrated look at the architecture of an entire “vertical slice” of the web-application stack, from the UI at the top to the database at the bottom, and all of the interior plumbing (messaging, caching, etc) in the middle. We’ll discuss various trade-o s and alternatives (several UI architectures are available, for example), as well as specific technologies that you can use to implement various components.

Howard Deiner

AGILE/LEAN STARTUP IT PORTFOLIO MANAGEMENT – NO LONGER OXYMORPHIC! Centralised development resources are common in many of the late adopter organisations that struggle with agile transformations. In this session, Howard focuses on the mechanics of a portfolio management technique intended to guide the organisation into the use of lean startup thinking (with which to challenge product managers), paired with the right type of fiscal rigour (to make CFOs happy).

Ralf Westphal

LET SOFTWARE DESIGN COME TO LIFE USING SOFTWARE CELLS Layered and N-tier architecture has reached its limits. Today´s technologies for distributed software need a more flexible meta-model for coarse-grained software design. That´s what software cells provide. They let you view software as an evolving whole, consisting of autonomous units on multiple levels of detail. Through vertical and horizontal cell division they allow you to think of software as a nested self-similar structure, with which to tackle any size of requirements.

Nathaniel Schutta

BUILDING A MOBILE COMPETENCY CENTRE By now, the importance of having a mobile solution is obvious to just about every seat in the organisation. But how do we develop expertise? How do we work through the inevitable politics and organisational issues? What about the technical questions about hybrid vs. web vs. native? In this session, Nathaniel will explore these obstacles and present an approach to achieving mobile competency within your organisation.

Gil Fink

QUICK TOUR TO FRONT-END TESTING USING JASMINEUnit testing is an inseparable part of the development process, no matter which methodology you follow. But how will you test your JavaScript code? The answer is using JavaScript unit testing framework. Jasmine is a behaviour-driven development (BDD) framework for testing JavaScript code. In this session, Gil will introduce Jasmine and you will learn the building blocks of writing your unit tests using the framework.

Michael Kennedy

APPLIED NOSQL WITH MONGODB AND PYTHON NoSQL is a hot topic in the tech industry today. But what exactly is NoSQL and should I use it to build my next application? In this session, Michael will dig into why NoSQL databases are sweeping the industry and discuss the trade-o s between the various types (keyvalue stores vs. document databases, for example). We will explore the most broadly applicable variant of NoSQL, document databases, through hands-on demos with the most popular of the document databases, MongoDB.

Page 104: MSDN September 2014

BOOK BOOK NOW

BOOK YOUR PLACE BOOK YOUR PLACE BY BY B1 AUGUST AND SAVE 1 AUGUST AND SAVE

UP TO £200UP TO £200

Frid

ay 1

7 O

ctob

er

CONTINUOUS DELIVERY

Getting software released to users is often a painful, risky and time-consuming process. In this workshop, Neal will set out the principles and technical practices that enable rapid, incremental delivery of high-quality, valuable new functionality to users. Through automation of the build, deployment and testing process, and improved collaboration between developers, testers and operations, delivery teams can get changes released in a matter of hours – even minutes – no matter what the size of a project or the complexity of its code base.

We’ll begin by describing the technical di erences between related topics such as continuous integration, continuous deployment and continuous delivery, and describe the new technical artefact that continuous delivery introduces, the deployment pipeline. Neal will discuss the various stages, how triggering works, and how to pragmatically determine what “production ready” means

We’ll then cover the role of testing and the testing quadrant, including the audience and engineering practices around di erent types of tests. This is followed by version control usage and o ering alternatives to feature branching, such as toggle and branch by abstraction. Neal will then go on to cover operation, DevOps and programmatic control of infrastructure, using tools such as Puppet and Chef. He will also discuss how to incorporate databases and DBAs into the continuous integration and continuous delivery process.

Continuous delivery is a process for automating the production readiness of your application every time a change occurs to code, infrastructure or configuration. It turns out that some architectures and practices yield code that works better in this environment. This workshop takes a deep dive into the intersection of the architect role and the engineering practices in continuous delivery.

Workshop ref: SA07

Neal Ford

END-TO-END SPA DEVELOPMENT

Single Page Applications (SPAs) are web applications that are built using a single page, which acts as a shell to all the other web pages, with a rich JavaScript front-end. As opposed to traditional web applications, most of the SPA development is done on the front-end. The server, which once acted as a rendering engine, provides only a service layer to the SPA. This transition helps to create a more fluid user experience (UX), and turns out web applications to desktop-like smart clients.

Known web applications, such as Gmail and Google Docs, are implemented as SPAs, demonstrating that SPAs are the way to write your future web applications and not just a transient trend.

In this workshop, Gil and Ido will demonstrate the concepts of building an end-to-end SPA using an ASP.NET Web API back-end and Backbone.js in the front-end. We will start by learning crucial concepts, such as object-oriented JavaScript and modular JavaScript (patterns and Require.js), that are relevant to SPA development understanding. After setting the background needed for SPA, we will drill down into Backbone.js and Underscore.js which are the libraries we will use in the workshop for MVW and template engine. Later on, you will learn how to create back ends using ASP.NET Web API. And, at the end of the day, you will have a thorough understanding of SPA building blocks and how to create your own SPA.

Workshop ref: SA08

Gil Fink & Ido Flatow

LIGHTWEIGHT AGILE SOFTWARE ARCHITECTURE FOR TEAMS

What makes software architecture agile? It’s not SOLID principles or TDD, but progressing incrementally. Increments thus need to become tangible parts of an architecture; tangible for customers as well as for developers. Also – since agility is about people – designing software must become easy to do for the whole team, from requirements down to single functions. Without the ability to think as a team about software on a conceptual level there will be no collective architecture ownership.

In this workshop, Ralf will demonstrate how to approach any requirements in a systematic way and transform them into a series of thinly sliced designs. Those designs can then be jointly implemented in a distributed fashion by a team for fastest feedback. Think feature team instead of feature developer.

Topics covered in this workshop:

• Context-driven software design• Slicing requirements for incremental delivery• Finding entry points for functional design• Two principles for evolvable functional

hierarchies• Three basic categories of responsibilities of code• Class follows function – how to wrap functionality

into containers of various granularity for evolvability and production e«ciency

• Rapid delivery through division of labour – components and Services to the rescue

Workshop ref: SA09

Ralf Westphal

S O F T W A R E A R C H I T E C TDAY 4: ALL-DAY POST-CONFERENCE WORKSHOPS

12 | SOFTWARE ARCHITECT | so�ware-architect.co.uk

DAY 4 Post-conference all-day workshops | Friday

The following workshops run for a full day, from 09:30 to 17:30 with a short break in the morning and afternoon, and a lunch break at 13:00. You either require a one-day workshop pass to attend OR you can book a 3-day Pass or Universal Pass and attend the main conference sessions as well.

SA has been delightful; challenging my understanding from 20° to 180°. All of the sessions were information packed. No sleepers!CHIEF SOFTWARE ARCHITECT

Page 105: MSDN September 2014

A DAY OF DESIGN PATTERNS AND TESTING

Re-use solutions, not just code. Design patterns help you identify problems that occur, repeatedly, in your code and solve those problems in a standardised way. The principles that design patterns introduce are also those that make your code testable. The combination of test-driven development and design patterns allows you to make sure that your code is functionally correct and has a robust design.

Design patterns also give you useful tools to help test potentially complex code. In this workshop, Andy and Richard will in no way cover all OO design patterns, but will immerse you in the world of loose coupling and TDD, and set you in good stead to continue your learning, resulting in you building testable object-oriented solutions.

Workshop ref: SA10

Andy Clymer & Richard Blewett

BUILDING DATA-DRIVEN MOBILE APPS USING AMAZON WEB SERVICES

Paul Ardeleanu

APPLIED BDD WITH CUCUMBER, CUCUMBER-JVM AND SPECFLOW

It’s all very well reading books, but nothing beats actually getting practical experience. In this workshop, working in your choice of Java, C# or Ruby, we will drive out the implementation of a simple utility by specifying its behaviour in Cucumber. The tyrannical Product Owner will regularly change his mind, so we’ll need to keep our code well factored and easy to modify.

This session is designed for developers and testers. By the end of the day, you will be comfortable working with Cucumber in your chosen development environment. You’ll have seen, first hand, how you can use Cucumber to drive out valuable features for your customers and how that can help keep your stakeholders engaged in the software development process. It will also be clear how BDD interacts with TDD, and how you will utilise both approaches to deliver software that does the right thing and does the thing right.

You should bring a laptop with your chosen

development environment installed. And please try to pre-install your chosen Cucumber variant before you come (instructions available). But don’t worry, we can install on the day, if necessary.

By the end of the session, you will have a good understanding of how Cucumber/Cucumber-JVM/SpecFlow work, and their place in the BDD toolkit.

If this subject interests you, but you would prefer a gentler introduction, then don’t miss Seb’s earlier workshop on Tuesday: “BDD by example”.

Workshop ref: SA12

Seb Rose

DAY 4: ALL-DAY POST-CONFERENCE WORKSHOPSS O F T W A R E A R C H I T E C T

so�ware-architect.co.uk | SOFTWARE ARCHITECT | 13

BETWEEN SESSIONS: ®8 8.30 Co«ee & registration | ® 11.00 Co«ee break | 13.00 Lunch break | ® 15.30 Co«ee break3

In the age of mobile apps, up-to-date content is an absolute must and developers are without doubt required to leverage the power of the new always-on paradigm. If you’re a mobile developer and would like to learn how to create and consume web services then this workshop is for you.

In this workshop, Paul will show you how to design and implement data-driven iOS apps using Amazon Web Services. Firstly, you will learn how to plan, build and deploy APIs using services such as EC2, RDS and S3, as well as understanding other Amazon services that can make your data available worldwide without performance penalties.

We will then use the APIs provided to build a simple iOS app. Some of the iOS topics we will cover include:

• Using storyboards to build user interfaces fast • Data persistence using Core Data • Threading for API consumption and

interface updates • Storing user data securely • Testing in various network conditions • Debugging and optimisation

Workshop ref: SA11

SA has been delightful; challenging my understanding from 20° to 180°. All of the sessions were information packed. No sleepers!CHIEF SOFTWARE ARCHITECT

Page 106: MSDN September 2014

S O F T W A R E A R C H I T E C T

Paul Ardeleanu

Paul is an experienced iOS and web developer, trainer and mentor, specialising in complete software solutions, technical

leadership and amazing customer experiences. He started programming back when Fortran was cool and is now using programming languages that have not yet been invented.

Richard Blewitt

Richard has been working in the software industry for more than 20 years, starting with mainframes through the early years of client/

server to today’s service-oriented world. He has spent his professional life working on large distributed systems, including being the middle-tier architect on the UK national police systems.

Simon Brown

Simon works as an independent consultant, helping teams to build better software. His client list spans more

than 20 countries, including organisations ranging from small technology start-ups through to global household names. He is an award-winning speaker and the author of “Software Architecture for Developers”.

Ed Courtenay

Ed is an experienced software developer and technical evangelist who has been programming professionally for more

than 25 years. He currently works for a major manufacturer and retailer in the UK, leading the development team responsible for their ecommerce web site.

Howard Deiner

Howard is a software consultant and educator who specialises in agile process and practices. He has a varied background, spanning

well over 30 years, with extensive experience in commercial software, aerospace and financial services. He has played many roles, such as developer, analyst, team lead, architect and project manager.

Austin Bingham

Austin is a founding director of Sixty North, a software consulting, training and application development company. He has

previously worked at National Instruments, developing LabVIEW; at Applied Research Labs (University of Texas, Austin), developing sonar systems for the US Navy; and at a number of telecommunications companies.

Andy Clymer

Andy is a co-founder of Rock Solid Knowledge. Prior to that, he cut his teeth working in various start-ups, programming on

a host of platforms, finally working for a start-up bought by Cisco in 1997. He now spends his time working on RSK’s Kiosk-based solutions on Windows Embedded with .NET.

János Feher

Since 1996, János has been involved in a wide variety of projects, including technical support for NATO operations, development of a high-

performance computing grid, national TV and radio websites, and web applications for university and adult learning. János is currently the Head of Development for Intern Avenue.

Gil Fink

Gil is a web-development expert and ASP.Net/IIS Microsoft MVP. He works as a senior consultant and architect, and is currently

consulting for various companies, where he helps develop web and RIA-based solutions. He conducts lectures and workshops for individuals and enterprises who want to specialise in infrastructure and web development.

Dino Esposito

Dino is a trainer and software consultant based in Rome. A member of the IDesign team, he specialises in Microsoft

.NET technologies, and spends his time teaching and consulting across Europe and the USA. He has hands-on experience in architecting and building distributed systems for banking and insurance companies.

Neal Ford

Neal is director, software architect and meme wrangler at ThoughtWorks, a global IT consultancy focusing on end-to-end

software development and delivery. He is also the designer and developer of applications, magazine articles and video/DVD presentations. And author/editor of eight books, including the most recent “Presentation Patterns”.

Ido Flatow

Ido is a senior architect and trainer at SELA Group, a Microsoft ASP.NET/IIS MVP, and an expert on Microsoft Azure and web technologies

such as WCF, ASP.NET and IIS. He is co-author of Microsoft’s o«cial courses for WCF 4 (10263A) and the manager of the Israeli Web Developers User Group.

MEET YOUR SPEAKERS

14 | SOFTWARE ARCHITECT | so�ware-architect.co.uk

BOOK NOW

BOOK YOUR PLACE BY 1 AUGUST AND SAVE

UP TO £200

The Software Architect 2014 speakers are acknowledged experts in their field.

Recognised internationally, the 2014 speaker faculty comprises professional consultants, trainers, industry veterans, thought-leaders and published authors. Find out more about their experience and expertise here.

For comprehensive speaker biographies, please visit: software-architect.co.uk/speakers

2014 speakers

Page 107: MSDN September 2014

Allen Holub

Allen is an internationally recognised consultant, trainer, speaker and author. He specialises in lean/agile processes and culture,

agile-focused architecture and cloud-based web-application development. Allen has worn every hat from grunt programmer to CTO, and has written a dozen books and hundreds of magazine articles for various technical publications.

Ruth Malan

Having worked in the software architecture field since the mid-90s, Ruth has arguably played a pioneering role, helping

to define architectures and the process by which they are created and evolved, as well as helping to shape the role of the software, systems and enterprise architect.

Nuni Filipe Godinho

Nuno is Director of Cloud Services, Europe at Aditi Technologies, and has more than 16 years’ experience in IT and more

than eight years in cloud computing. He regularly helps customers create a cloud strategy but also designs, plans, manages, develops and maintains products and solutions in the cloud.

Sander Hoogendoorn

In his role of principal technology o«cer at Capgemini, Sander is concerned with the innovation of software

development. He is also responsible for Capgemini’s agile software development platform, and is recognised as an agile thought leader, as well as being a certified global software engineer (level 4) at Capgemini.

Jules May

Jules is a software architect with a particular interest in languages (both for programming and for discourse), and is

presently active in web and mobile convergence. He has been writing, teaching and speaking for 25 years now, and conducts frequent lectures and workshops to a range of audiences. He is the originator of “Problem Space Analysis”.

Nathaniel Schutta

Nathaniel is a software architect focused on mobile and making usable applications. A proponent of polyglot programming,

Nate has written two books on Ajax and speaks regularly at various worldwide conferences, No Flu  Just Stu  symposia, universities, and Java user groups.

Shay Friedman

Shay is a Visual C#/IronRuby MVP and the author of “IronRuby Unleashed”. With more than 10 years of experience

in the software industry, Friedman now works for CodeValue, a company he co-founded, where he creates products for developers, consults and conducts courses about web development and dynamic languages.

Seb Rose

Seb wrote his first commercial software in the early 80s on an Apple II. He went on to graduate from the University of

Edinburgh with a First-Class Joint Honours in Computer Science and Electronics. Over the past six years, he has focused on helping teams adopt and refine their agile practices.

Ralf Westphal

Ralf is a freelance consultant, project coach and trainer on software architectural topics and software team organisation.

He is the co-founder of the German “Clean Code Developer” initiative, which aims to increase software quality, and currently counts more than 3,700 members.

Sasha Goldshtein

Sasha is the CTO of SELA Group, a Microsoft C# MVP and Azure MRS, and an international consultant and trainer.

He is the author of “Introducing Windows 7 for Developers” (Microsoft Press, 2009) and “Pro .NET Performance” (Apress, 2012), a prolific blogger, and author of numerous training courses.

Michael Kennedy

As a full-time instructor for DevelopMentor, Michael specialises in core .NET, web, agile development, and test-

driven development (TDD) technologies. He has been building commercial applications with .NET since its initial public beta in 2001. Prior to working with .NET, he spent years working with C++ on Windows and SGI platforms.

Brian A. Randell

Brian is a senior consultant with MCW Technologies, LLC. For more than 20 years, he has been building

software solutions and educating his fellow developers. He spends his time teaching Microsoft technologies to developers, working with new and emerging technologies, and consulting worldwide.

Gary Short

Gary is a freelance data science practitioner and trainer, based in Dundee, UK. He has a deep understanding of the full

Hadoop and HDInsight environment, as well as an interest in Social Network Analysis, (UCINet and Pajek) and computational linguistics (NLTK).

Eoin Woods

Eoin is a lead architect in the Operations Technology group at UBS. Prior to UBS, he has worked in the software engineering field

for more than 20 years, for a number of companies, including Bull, Sybase, InterTrust and BGI. His main technical interests are software architecture, distributed systems, computer security and data management.

Robert Smallshire

Robert is a founding director of Sixty North, a software product and consulting business in Norway. He has worked in

senior architecture and technical management roles for several software companies, providing tools in the energy sector for dealing with the masses of information flowing from today’s digital oil fields.

MEET YOUR SPEAKERS

S O F T W A R E A R C H I T E C T

so�ware-architect.co.uk | SOFTWARE ARCHITECT | 15

Page 108: MSDN September 2014

16 | SOFTWARE ARCHITECT | www.so�ware-architect.co.uk

S O F T W A R E A R C H I T E C T

PRICING OPTIONS

SPONSORSHIP, EXHIBITION & MEDIA PARTNERSHIP OPPORTUNITIES

Universal Pass [All 4 days]

Main Conference [Wednesday & Thursday]

One Workshop Day [Tuesday or Friday]

Three-day Pass [Main Conference plus one Workshop day]

To register, please visit software-architect.co.uk/book For any registration enquiries, please contact the bookings team: T: +44 (0)20 7407 9964 E: [email protected] All prices include refreshments, bu et lunch and session notes but exclude travel and accommodation. If you require accommodation, you can secure discounted rates at recommended hotels via the Software Architect website: software-architect.co.uk/about

Please note that the online submission of a completed registration form constitutes a �rm booking, subject to the following terms and conditions. Any cancellations received after Friday, 7 July 2014, will incur a 30% administration fee. Cancellations must be made in writing at least 60 days before the conference, or the full fee will be charged. We are happy to accept substitutions if they are submitted in writing before the conference begins. The organisers reserve the right to make changes to the programme and speakers without notice, if this is unavoidable. If delegates are unable to attend for any reason that is beyond the control of the organisers, such as transport problems, personal illness, bereavement, inclement weather, terrorism or act of God, it will not be possible to make any refunds of conference or workshop fees.

Software Architect offers you the opportunity to position your company as one of the leading players in the European software development market. With access to a senior-level audience of key influencers and decision-makers, from a wide range of industries, you have the perfect platform to generate awareness, showcase new products and services, and demonstrate your experience and expertise.

To discuss sponsorship & exhibition opportunities please contact: Chris Handsley+44 (0)20 7830 3634chris.handsley@ publicis-blueprint.co.uk

Who will you meet at Software Architect?

£1,095+VAT

£795+VAT

£445+VAT

£1,395+VAT

Bookings made by Friday

1 August Save up to £250

£1,195+VAT

£895+VAT

£495+VAT

£1,495+VAT

Bookings made by Friday 19 September

Save up to £100

£1,295+VAT

£995+VAT

£545+VAT

£1,595+VAT

Bookings made after Friday

19 September

BOOK BOOK NOW

BOOK YOUR PLACE BOOK YOUR PLACE BY BY B1 AUGUST AND SAVE 1 AUGUST AND SAVE

UP TO £200UP TO £200

40%

14%

5% 3%

30%

3%

6%

Prices and sponsorship

PRICES AND SPONSORSHIP

TEAM LEADERMANAGER

DEVELOPERENGINEERPROGRAMMER

DIRECTORDEPARTMENT HEAD

ARCHITECT

CONSULTANT

OTHER

C-LEVEL