Professional Documents
Culture Documents
magazine
Exploring the
.NET Framework 4.5.1........32
magazine
Exploring the
.NET Framework 4.5.1........32
DIRECTX FACTOR
A 2D Portal into a 3D World
Charles Petzold, page 76
Terabytes of Text
KENT SHARKEY Site Manager
support “Office,” PDF, HTML, XML, ZIP, JOSHUA GOULD Art Director
.
Irene Fincher Audience Development Manager
APIs for NET, Java, C++, SQL, etc. ADVERTISING SALES: 818-674-3416/dlabianca@1105media.com
Dan LaBianca Vice President, Group Publisher
InfoWorld
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 offices. Annual subscription rates payable in US funds are: U.S. $35.00, International
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,
dtSearch products: 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,
Media Kits: Direct your Media Kit requests to Matt Morollo, VP Publishing, 508-532-1418 (phone),
Reprints: For single article reprints (in minimum quantities of 250-500), e-prints, plaques and posters contact:
Document filters also available for separate PARS International, Phone: 212-221-9595, E-mail: 1105reprints@parsintl.com, www.magreprints.com/
QuickQuote.asp
licensing 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: jlong@meritdirect.com; Web: www.meritdirect.com/1105
Conference Calling
When I first got into the technology and IT journalism racket as an environments. The annual Microsoft TechEd North America
editor at PCWorld magazine way back in 1992, computer conferences conference, considered a large IT/computing gathering, draws an
were king. Huge, big-tent confabs like Comdex in Las Vegas and estimated 10,000 or so attendees. Build attendance, meanwhile, is
PC Expo in New York drew tens—if not hundreds—of thousands strictly gated. Last year, registration for the Build 2013 conference
of attendees. Flights were booked solid for days. Cab lines in Vegas sold out within hours.
snaked around hotel entrances and often forced people to trudge Or consider the Live! 360 DEV conference, which takes place
the astonishingly long blocks between venues along the Strip. in Las Vegas next month (March 10-14). I’ve been active with the
The editorial planning for these events was robust. We’d hold Visual Studio Live! conference going back to my days as editor
multiple full-staff meetings in the weeks ahead of these shows, in chief of Visual Studio Magazine, and now that the event is part
assigning beats and lining up coverage responsibilities for the team of the expanded Live! 360 conference program, I continue to
of editors sent to cover keynotes and announcements. It was an era consult with the team to this day. The Live! 360 organizers place
of conference gigantism. Like the dinosaurs that roamed the earth an extremely high premium on fostering interaction between pre-
more than 68 million years ago, these industry-wide events were senters and attendees, encouraging people to approach speakers
huge, powerful ... and extraordinarily vulnerable. throughout the show. Live! 360 DEV expects to draw 700-plus
I began thinking about this when Microsoft announced that it attendees. It’s the absolute antithesis of the Comdex approach and,
would be holding another Build developer conference this year, frankly, it’s pretty cool.
returning to the Moscone Center in San Francisco from April 2-4. In an era of accessible streaming media and limited travel
Build, of course, has its roots in the old Microsoft Professional budgets, it really doesn’t make sense to drop 100,000 people into a
Developers Conference (PDC) series, which itself launched the room and call it a conference. Smaller events promise better focus,
same year I arrived at PCWorld. No developer conference would greater interaction and, ultimately, better value to the developers
ever approach the size and scale of a general computing event like and attendees traveling to the show.
Comdex, but those early PDCs could pack them in. The inaugural By the time you read this, Build 2014 registration will have long since
1992 event, which launched the Win32 API and introduced first sold out. If you didn’t hit the Web site early on Jan. 14, you’re almost
mention of Windows 95 by its code name “Chicago,” was attended certainly out of luck. Enjoy the streaming Web video and congratulate
by about 5,000 people. Later events would draw 8,000 or more. yourself for saving several hundred dollars in frustrating air travel.
There is certainly value in big-tent, destination events—see the For those who did sneak in, I expect you can look forward to
ongoing success of giant shows such as the Computer Electronics an outstanding event. Take advantage of the small footprint. Seek
Show (CES) or CeBIT in Germany—but the IT/computing industry out presenters, ask smart questions and argue with your fellow
in North America has seen nothing like Comdex or PC Expo attendees. There’s a lot to get out of these shows, and often the
since they both waned in the early 2000s. The great lizards of the smaller events afford the biggest opportunities to learn and grow.
past have been supplanted by smaller, more nimble mammals bet- Take advantage of it.
ter designed to endure a global cold snap and adjust to changing
Visit us at msdn.microsoft.com/magazine. Questions, comments or suggestions for MSDN Magazine? Send them to the editor: mmeditor@microsoft.com.
4 msdn magazine
Untitled-3 1 3/1/13 11:00 AM
CUTTING EDGE DINO ESPOSITO
6 msdn magazine
Untitled-2 1 4/30/13 10:48 AM
Note that this is the same code you’d use to add a Web API con- xml=true expression is added to the query string used to invoke
troller to an ASP.NET MVC application. You also have to specify Web API. For this to happen, you need to have the following code
routes. Here’s some code you want to run at application startup: in the constructor of your custom XML media type formatter:
RouteTable.Routes.MapHttpRoute( MediaTypeMappings.Add(new QueryStringMapping("xml", "true", "text/xml"));
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}", In a similar way, you can have callers express their preferences by
defaults: new { id = System.Web.Http.RouteParameter.Optional }); adding an extension to the URL or by adding a custom HTTP header:
Unless otherwise annotated with the NonAction attribute, any MediaTypeMappings.Add(new UriPathExtensionMapping("xml", "text/xml"));
MediaTypeMappings.Add(new RequestHeaderMapping("xml", "true",
public methods on the class that match the default naming and StringComparison.InvariantCultureIgnoreCase, false,"text/xml"));
routing conventions are public HTTP-callable endpoints. They For URL path extension, it means the following URL will map
can be called from any client without the need for generated proxy to the XML formatter:
classes, web.config references or special code. http://server/api/news.xml
Routing conventions in Web API dictate the URL starts with /api Note that for URL path extensions to work you need to have an
followed by the controller name. Note that there’s no action name ad hoc route such as:
clearly expressed. The action is determined by the type of request, config.Routes.MapHttpRoute(
whether GET, PUT, POST or DELETE. A method name that begins name: "Url extension",
routeTemplate: "api/{controller}/{action}.{ext}/{id}",
with Get, Put, Post or Delete is conventionally mapped to the corre- defaults: new { id = RouteParameter.Optional }
sponding action. For example, a method GetTasks on a TaskController );
will be invoked for any GET request to a URL such as /api/task. For custom HTTP headers, the constructor of the Request-
Regardless of the apparent similarity of behavior and class HeaderMapping class accepts the name of the header, its expected
names with ASP.NET MVC, Web API lives in a completely value and a couple of extra parameters. One optional parameter
separate set of assemblies and uses a completely different set of indicates the desired string comparison mode, and the other is a
types—System.Net.Http is the primary assembly. Boolean that indicates if the comparison is on the entire string. If
the negotiator can’t find a match on the formatter using the media
Inside Web API Content Negotiation type mapping information, it looks at standard HTTP headers such
“Content negotiation” is often used to describe the process of as Accept and Content-Type. If no match is found, it again goes
inspecting the structure of an incoming HTTP request to figure through the list of registered formatters and checks whether the
out the formats in which the client wishes to receive responses. return type of the request can be serialized by one of the formatters.
Technically, though, content negotiation is the process in which To add a custom formatter, insert something like the follow-
client and server determine the best possible representation format ing code in the startup of the application (for example, in the
to use in their interactions. Inspecting the request typically means Application_Start method):
looking into a couple of HTTP headers such as Accept and config.Formatters.Add(xmlIndex, new NewsXmlFormatter());
Content-Type. Content-Type, in particular, is used on the
server for processing POST and PUT requests and on the client Customizing the Negotiation Process
for choosing the formatter for HTTP responses. Content-Type is Most of the time, media type mappings let you easily fulfill any
not used for GET requests. special requirements for serialization. However, you can always
The internal machinery of content negotiation, however, is replace the default content negotiator by writing a derived class
much more sophisticated. The aforementioned scenario is the most and overriding the MatchRequestMediaType method:
typical—because of default conventions and implementations— protected override MediaTypeFormatterMatch MatchRequestMediaType(
HttpRequestMessage request, MediaTypeFormatter formatter)
but it isn’t the only one possible. {
The component that governs the negotiation process in Web ...
}
API is the class called DefaultContentNegotiator. It implements a
public interface (IContentNegotiator), so you can replace it entirely You can create a completely custom content negotiator with a new
if needed. Internally, the default negotiator applies several distinct class that implements the IContentNegotiator interface. Once you
criteria in order to figure out the ideal format for the response. have a handmade negotiator, you register it with the Web API runtime:
GlobalConfiguration.Configuration.Services.Replace(
The negotiator works with a list of registered media type typeof(IContentNegotiator),
formatters—the components that actually turn objects into a specific new YourOwnNegotiator());
format. The negotiator goes through the list of formatters and stops at The preceding code usually goes in global.asax or in one of those
the first match. A formatter has a couple of ways to let the negotiator handy config handlers that Visual Studio creates for you in the
know it can serialize the response for the current request. ASP.NET MVC Web API project template.
The first check occurs on the content of the MediaTypeMappings
collection, which is empty by default in all predefined media type Controlling Content Formatting from the Client
formatters. A media type mapping indicates a condition that, if The most common scenario for content negotiation in Web API
verified, entitles the formatter to serialize the response for the is when the Accept header is used. This approach makes content
ongoing request. There are a few predefined media type mappings. formatting completely transparent to your Web API code. The caller
One looks at a particular parameter in the query string. For exam- sets the Accept header appropriately (for example, to text/xml) and
ple, you can enable XML serialization by simply requiring that an the Web API infrastructure handles it accordingly. The following
8 msdn magazine Cutting Edge
code shows how to set the Accept header in a jQuery call to a Web
API endpoint to get back some XML: MSDN
Magazine
$.ajax({
url: "/api/news/all",
type: "GET",
headers: { Accept: "text/xml; charset=utf-8" }
});
Online
In C# code, you set the Accept header like this:
var client = new HttpClient();
client.Headers.Add("Accept", "text/xml; charset=utf-8");
Any HTTP API in any programming environment lets you set
HTTP headers. And if you foresee that you can have callers where
this might be an issue, a best practice is to also add a media type
mapping so the URL contains all the required information about
content formatting.
Bear in mind that the response strictly depends on the structure
of the HTTP request. Try requesting a Web API URL from the
address bar of Internet Explorer 10 and Chrome. Don’t be surprised
to see you get JSON in one case and XML in the other. The default
Accept headers might be different in various browsers. In general,
if the API will be publicly used by third parties, you should have a
URL-based mechanism to select the output format.
may be at play.
UI elements from getting cropped off the bottom of the display. If
your display has fewer than 900 lines of vertical resolution, then
you won’t have any options and the 100 percent scaling factor will
be all there is. As the vertical resolution of your display increases, GetDC function with a nullptr instead of a window handle. This
you’re presented with more options until you reach 1,440 lines of special value indicates you want the device context for the desk-
top as a whole rather than a particular window:
auto dc = GetDC(nullptr);
Naturally, you must remember to free this
handle when you’re done:
ReleaseDC(nullptr, dc);
The first parameter is the handle to the win-
dow to which the device context refers. Again,
a nullptr value represents the desktop. Now,
given the device context, you can use the Get-
DeviceCaps function to retrieve the system DPI
scaling factor for the x and y axes as follows:
auto x = GetDeviceCaps(dc, LOGPIXELSX);
auto y = GetDeviceCaps(dc, LOGPIXELSY);
Having a different value for the x and y axes
dates back to the dark ages when printers rou-
tinely offered different scaling factors horizontally
and vertically. I’ve never come across a display
that offers up non-square pixels, but I hear they
do exist in some industries for which special
graphics cards have been developed. LOG-
Figure 3 Windows 8.1 PC Setting Affecting Dynamic PIXELSX and LOGPIXELSY represent the
and Per-Monitor Scaling for the Desktop number of pixels per logical inch along the
msdnmagazine.com February 2014 13
Figure 4 System Scaling Factors the application knows what it’s doing. If an application is system
DPI-aware, the desktop window manager will scale the window
DPI Percentage
based on the assumption that it was rendered to the system DPI
96 100
scaling factor returned by the GetDeviceCaps function I mentioned
120 125
earlier. And if an application is DPI-unaware, the desktop window
144 150 manager assumes the window was rendered to the traditional 96
192 200 DPI and scales it accordingly.
Before I consider how to actually write a well-behaving, per-
Figure 5 Scaling Options Relative to Vertical Resolution monitor, DPI-aware application, I’ll discuss what it takes to make
Resolution Scaling Options such a claim. Windows Vista introduced the SetProcessDPIAware
… – 900 100% function to mark the calling process as DPI-aware. This function
900 – 1079 100% – 125%
took no arguments and simply turned on DPI awareness, so to
speak. This was before per-monitor awareness, so this was a sim-
1080 – 1439 100% – 125% – 150%
ple binary state. Either you’re DPI-aware or you’re not. Windows
1440 – ... 100% – 125% – 150% – 200%
8.1 introduced a new function called SetProcessDpiAwareness that
provides more control over this level of awareness:
width and height of the desktop. Again, this is a logical inch and VERIFY_(S_OK, SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE));
isn’t meant to reflect reality. Also, given these are the system DPI
Experience the DevExpress Difference today and download your free 30-day trial and
let’s build great apps, together.
99
Q Included Domains: .com, .net, .org, .biz, .info
$0.
Q Unlimited Power: webspace, traffic, mail accounts, SQL databases
Q Linux or Windows operating system
per month*
POWERFUL APPS
Q Over 140 popular apps (Drupal™, WordPress,
Joomla!™, Typo3, Magento® and many more...)
Q App Expert Support to answer your questions
POWERFUL TOOLS
Q Premium software, including
Adobe® Dreamweaver® CS5.5,
and NetObjects Fusion® 2013
Q 1&1 Mobile Website Builder
SUCCESSFUL MARKETING
Q 1&1 Search Engine Optimization
Q Listing in business directories
Q 1&1 E-Mail Marketing Manager
Q Facebook® Credits
STATE-OF-THE-ART TECHNOLOGY
Q Maximum Availability (Geo-redundancy)
Q 300 Gbit/s network connection
Q 2 GB RAM guaranteed
GI<:@J<CP
o “http
on( p://www.dyn
namicp
pdf.co
om”))); pageE
eElem
ments..Add(
Ad lab
bel); pag
page
pageElements
nts.A
Add(link);
k) } p
private
e void AddPath(Group pageElements, float x, float y) { // Adds a path to the pageEleme
ents ce
eTe.Dynamic
amic
icP
PD
PDF.Page
geElem
lements.Pat
lem P h
20,
0 Rgb
gb
bColor.Blue, RgbC
RgbCoolor.R
Red
d, 2, LineSty
eS lee.Solid
d, true); path
h.Su
.Sub
bPaths.A
.Ad
dd(new
wLLineS
ineSubPa
ubPath(x + 215, y + 40)); path.SubPaths.Add(new CurveToS
ToSubP
Path
h(x + 108, y + 80, x + 160,, y + 80
0)); path.Sub
SubPaths
SubP hs.Add(new
.A
Ad (ne CurveS
ec
ect
ctangl
angle(pageEleme
ents, “P
“Path
h Pa
Page Element:””, x, y);
) pageE
Eleme
Ele entss.Ad
Add(pa
d(path)
th); } priva
ate
e vo
void AddRectangle(Group pageElements, float x, float y) or
ordere
de dList = orde
o redL
edList.GetOverFlowL
o List((x + 5, y + 20); A
AddC
dCapti
a onAndRect
ap
225, 11
22 10); page.Ele
ements.A
ts.Add(o
dd(ord
r edList); x = 0; y +
rder
rd +==1
118
8; // Crea
ate
e an unorrdered
e lis
ist Un
Unord
deredList unorderedList = new Unor
o deredList(x + 5, y + 20, 400, 90
0, Font.H
t.Helvetica, 10); uno
orderredList
st.It
.Item
ms.A
s Add(“
dd
d(“Frui
Fr ts
Fru s”); unorder
e ies(); pieSeries.Da
er ataLab
abel = da; plotArea.Se
eries
ess.Add(pieS
.A
Ad Series
es
s); pieSeries.Eleme
lementss.Add
Add(27,
7, “Website A”); pieSeries.Elements.Add
.Ad (19, “Website
e B”)); pieSerries
es.Element
men s.Add(21, “W
Webssite C”); pieS
Serie
eri
rie
es.Elemen
eme ts[0
s[0].Color = a
ess.Elem
ments[2].Color = auttogradient3;”unor
o derredSubL
List2 = uno
orderedList.Items[
ms 1].SubL
ubLissts.A
AddUnorderedSubList(); unorderedSubL
u ist2.Items.Add(“
dd(“Pottato”); u
unorde
eredSubList2.Item
ms.A
.Add(
d(“Bea
ea
ans”);; Unordere
ans eredSub
Su List subU
GIF>I8DD<;
ed
dSubList(); subUno
d UnorderedSubList.Items.A
s.A
Ad
dd(““Lime”); subU
Unord
dere
edSubList.Item
tems.Ad
s.Add(“O
d(“Orang
range”);
e” Unorder
d edSubList su
s bUnorder
d edSu
e bList2 = un
nord
dere
edSubLis
Li t.Items[
ms 1].SubLists.
s.AddU
AddU
d norrdered
ed
dSubL
bList(
st ); su
ubUn
bUnorderedS
e ub
ana”); Unordered
eredSubList subUnord
o ered
edSubL
Su ist3
st3 = unorderredSubL
SubList2.Ite
t ms[0
0].Su
.SubLis
Lists.A
s.AddUn
d orderedS
SubList(); subUno
U rderedSu
dSubList3.Items.A
Add((“Sw
weet Pota
o to”)); UnorderedS
redSubL
ubLi
L st subU
Unord
rdeeredS
dS
dSubList4
st = un
st4 unorderedSu
Su
ubList4
4.Ite
.Items.A
m dd(“String Bean”
n”);; ssubUn
bUnorde
ere
edSub
bList4..Item
ms.Ad
dd(“Lima Bean
Bean”); subU
subUn
norderedSubList4.Items.Add(“Kidney Bean”
e ); x += 279; pag
page.E
Elemen
nts.Add
d(unorderedList
st);
);; unord
no ered
red
dLis
st = unord
n ered
red
dLis
st..Get
G Over
v Flo
e.Eleme
e. ents, “Unordered List Page
en ge E
Elem
ment
n Overfl
verflow:””, x, y,, 225
5, 110); page.Elem
ements
ents.Add
Add(un
(unorderedList); } private void AddTextF
t ield(Group pageE
eElem
lemen
nts, floa
at x, flo
oatt y) { TextF
Field
d txt = new
ew TextF
extField
eld(“txtfna
fna
ame”,
me x + 20, y +
attedTe
extArea(formattedHtml, x + 5
5, y + 20,
2 215,
20 15 60, FontF
Familyy.He
elvetica, 9, false)
se ; // Set
Setss the
the indent property formattedTextArea.Style.Paragraph.Inde
In nt = 18; AddCapt
Cap ionAndRe
ndRectan
a ggle(
eppage
eElem
E ents, “F
Formatted
orma
m tted
tedTe
ted TextArea
rea P
at dTe
atte extArea Overflow Text:”,
Te
e x + 279, y);
y ; pageE
p geElements.A
Add(form
formattedTextA
Area);
a) // Creat
ea e an overflow formatted text area for the overflow text Fo
Form
mattedT
tedTextA
xt reaM
Max
axLe
Length
ngth = 9;
9 tx
xt1.B
1.Borde
d rCo
de rColorr = RgbColo
Colo
lo
or.B
Bla
ack; txt
txt1.Ba
1 Ba
M ximu
Ma um Length
R bCo
Rg olor.AliceBlue
, y + 40
able”].S
.Font
.F
Selec
Sele
Se
Blue
0, 150,, 20
=FIJG<<;
gth”;; pageE
geE
Eleme
20);; c
20)
ements.
e; txt2.T
nts.Add(
cb.Bor
lected = true; cb.Ed
Add(txt
o derC
d
txt1); TextF
2. oolTip = “M
ex ield
olTip = “Editable
ontSize = 12; cb1.Items.Add(“Item 1”); cb1.Items.A
erter.Co
Add(“Item
e Combo
em 2”);
Co
xtf2name
Add(ttxt2); AddCap
Black; cb.Ba
ackg
groun
name”, x + 330, y + 30, 150, 40); txt2.DefaultValue = “This is a Tex
Caption
t AndR
ndColor = RgbC
AndRec
RgbColor
Box””; pageEl
pageE eme
2 cb1.Items.Add((“Item
onvert(“http://www.google.com”, “Output.pdf”));Convverte
er.Co
onvert(GetDoc
D Path
ctangle(pageElements, “TextField Form Page Element:”,, x,
o .Ali
AliceB
ments.Add(cb); ComboBox cb1 = new ComboBox(“cmb1nam
xtF
tField
x y, 504
ceBlue; cb.Font = Font.Helvetica; cb.FontSize = 12; cb.Items
ame”, x + 303,
em 3”); cb1.Items.Add(“Item 4”); cb1.Items.Add(“Non-Editable”);
Path(“Do
d whiich
4, 85
em .A
0 y + 40,
03
”); cb1
(“D cumentA.rtf”), “Output.pdf”);System.Diagnostics.Process.
( em
(“It
1.Items[“N
s.Startt(“
t(“Outpu
h goe
es to
m 1”);
40 150, 20
Non-E
t the nex
85);; } prrivate voi
Add(“
oid
1 ; cb.IItems
0); cb1.B
cb1.B
xt liline
d AddCom
te .Add(“It
b1 orde
orderCol
on-Editable”].Select
utput.pdf”);
utput ”); AsyncCo
ec
ne if tthe textt excee
C boFi
bo eld(Group
“Item
rColo
em 2”);
c ed = tru
Conver
2”); cb.I
or = Rgb
true;
e; cb1
nverrter aCon
cb.Items
g Colo
cb1.E
aConvert
verter
xceeds
p pageEl
pageEleme
ds wid
emen
width”;
e ts
en
ems.Add(“Item
orr.Bl
r.B
B ack;
em 3”)
ack cb1.Bac
Editable
e = new
e = ffalse;
e AsyncC
ncCon
”; txt2.
xt2 Mu
ts, float x, fl
MultiLin
3 ); cb.IItems
se cb1.ToolT
nverter(); aC
Linee=
;peXd`ZG;=Ç:fdgi\_\ej`m\G;=Jfclk`fej]fi%E<K;\m\cfg\ij
Z\K\ Jf]knXi\Ëj ;peXd`ZG;= gif[lZkj gifm`[\ i\Xc$k`d\ G;= ^\e\iXk`fe# dXe`glcXk`fe# Zfem\ij`fe#
gi`ek`e^#m`\n`e^#Xe[dlZ_dfi\%Gifm`[`e^k_\Y\jkf]Yfk_nfic[j#k_\fYa\Zkdf[\cjXi\\oki\d\cp
Õ\o`Yc\ Ylk jk`cc jlggcp k_\ i`Z_ ]\Xkli\j pfl e\\[ Xj X [\m\cfg\i% I\c`XYc\ Xe[ \]ÔZ`\ek# k_\ _`^_$
g\i]fidXeZ\ jf]knXi\ `j \Xjp kf c\Xie Xe[ lj\% @] pfl [f \eZflek\i X hl\jk`fe n`k_ Xep f] fli
NNN%;PE8D@:G;=%:FD
Zfdgfe\ekj#j`dgcpZfekXZkZ\K\Jf]knXi\Ëji\X[`cpXmX`cXYc\#`e[ljkip$c\X[`e^jlggfikk\Xd%
KIPFLIG;=JFCLK@FEJ=I<<KF;8P
K
nnn%;peXd`ZG;=%Zfd&\mXcfiZXcc/''%-*(%,''-s"(+('%..)%/-)'
n
£Web Dev Live! – NEW EVENT! Web Dev Live! will dive deep to
explore all that is HTML5, JavaScript and ASP.NET.
£Modern Apps Live! – Launch your mobile, cross-device & cloud development
training here.
£SharePoint Live! – Set your course for collaboration with these sessions
designed strictly for devs.
£SQL Server Live! – Your Mission? Conquering coding against SQL Server.
£This means you have Àve events with over a hundred sessions to choose from –
mix and match sessions to create your own, custom event line-up - it’s like no
other dev conference available today.
TURN THE PAGE FOR MORE EVENT DETAILS
£
Presented in
is the singular topic focus; sessions build on each other as the conference
Partnership with progresses, leaving you with a holistic understanding of modern
applications.
And INTRODUCING...
Web Dev Live!
The producers of Live! 360 DEV bring you a new, dynamic, content-rich
event — Web Dev Live! We're seeing an evolution where server-side web
technologies continue to improve, and at the same time JavaScript and
HTML 5 are becomi
omi
becoming viable smart client development technologies that
operate on
n th
their own. This is a great time to jump into the
JavaScrip
ip programming world, or to update your
JavaScript
knowle
e
knowledge of web development based on the latest
tools a
and capabilities.
SharePoint Live!
This March, SharePoint Live! will be for
developers only, where expert speakers will
guide an exploration of patterns and
practices, highlighting the capabilities of
various development tools. Select sessions
will focus on methodologies for development
that will supplement your overall Live! 360
DEV experience.
REGISTER BY FEBRUARY 12
AND SAVE $300
Use promo code DEVFEB4
magazine
I’ve had some exposure to functional programming over the past In this article, I’ll focus on one aspect of F# and functional pro-
few years. Some of this was implicit: Coding with lambdas in LINQ gramming that I’ve come to understand since hearing that comment
is functional programming. Some has been explicit: Using Entity about not needing foreach loops. Functional languages are really
Framework and the LINQ to SQL CompiledQuery type forced me good at working with sets of data. In a procedural language, when
to use .NET func logic. That was always a little tricky because I did it you work with sets, you have to explicitly iterate through them to
so infrequently. I’ve also been exposed to functional programming perform logic. A functional language, in contrast, comprehends sets
through the infectious enthusiasm of Rachel Reese, a Microsoft on a different level, so you just need to ask it to perform a function
MVP, who not only participates in my local user group (VTdotNET) on a set, rather than loop through the set and perform a function
but also runs the VTFun group here in Vermont, which focuses on each item. And that function can be defined with lots of logic,
on many aspects and languages of functional programming. The including math, if necessary.
first time I went to a VTFun meeting, it was filled with mathema- LINQ provides shortcuts for this, even a ForEach method into
ticians and rocket scientists. I’m not kidding. One of the regulars which you can pass a function. But in the background, your lan-
is a condensed matter theorist at University of Vermont. Swoon! I guage (perhaps C# or Visual Basic) simply translates this into a loop.
was a little overwhelmed by the high-level discussions, but it was A functional language such as F# has the ability to perform the
fun to actually feel like the dummy in the room. Most of what was set function at a lower level, and it’s much quicker thanks to its easy
said went right over my head—except for a single statement that parallel processing. Add to this other key benefits, such as a rich
caught my attention: “Functional languages don’t need no stinkin’ math-processing ability and an incredibly detailed typing system
foreach loops.” Whoa! I wanted to know what that meant. Why
don’t they need foreach loops? Figure 1 CylinderMeasurement Class
What I’ve usually heard is that functional programming is great public class CylinderMeasurement
for mathematical operations. Not being a math geek, I interpreted {
public CylinderMeasurement(double widthA, double widthB, double height)
that to mean “for demos that use the Fibonacci sequence to test {
out asynchronous behavior” and didn’t pay much more attention. WidthA = widthA;
WidthB = widthB;
That’s the problem with hearing just a short elevator pitch about Height = height;
functional programming. }
public int Id { get; private set; }
But I finally started hearing a more accurate characterization— public double Height { get; private set; }
that functional programming is great for data science. That certainly public double WidthB { get; private set; }
public double WidthA { get; private set; }
appeals to a data geek. F#, the functional language of the Microsoft public int LoadPounds { get; private set; }
.NET Framework, brings all kinds of data science capabilities to public double Psi { get; set; }
public CylinderType CylinderType { get; set; }
.NET developers. It has entire libraries dedicated to charting, time public void UpdateLoadPoundsAndTypeEnum(int load, CylinderType cylType) {
manipulation and set operations. It has APIs with logic dedicated LoadPounds = load; CylinderType = cylType;
}
to 2D, 3D and 4D arrays. It comprehends units of measure and is private double? Ratio {
able to constrain and validate based on specified units. get {
if (Height > 0 && WidthA + WidthB > 0) {
F# also enables interesting coding scenarios in Visual Studio. return Math.Round(Height / ((WidthA + WidthB) / 2), 2);
Rather than building up your logic in code files and then debug- }
return null;
ging, you can write and execute code line by line in an interactive }
window and then move the successful code into a class file. You can }
public double ToleranceFactor {
get a great feel for F# as a language with Tomas Petricek’s article, get {
“Understanding the World with F#” (bit.ly/1cx3cGx). By adding F# if (Ratio > 1.94 || Ratio < 1) {
return 1;
into the .NET toolset, Visual Studio becomes a powerful tool for }
building applications that perform data science logic. return .979;
}
}
Code download available at msdn.microsoft.com/magazine/msdnmag0214. }
24 msdn magazine
that even understands units of measure, and you’ve got a powerful Figure 2 Calculator Class to Calculate PSI
tool for performing calculations on large sets of data. public static class CylinderCalculator
There’s much more to F# and other functional languages that’s {
private static CylinderMeasurement _currentCyl;
still far beyond my reach. But what I want to do in this column
is focus on a way to quickly benefit from one particular aspect public static void UpdateCylinders(IEnumerable<CylinderMeasurement> cyls) {
foreach (var cyl in cyls)
of functional languages without making a huge investment: {
moving logic from the database into my application. This is the way _currentCyl = cyl;
cyl.Psi = GetPsi();
I like to learn: find a few things I can understand and use them to }
take some baby steps into a new platform, language, framework }
Many years ago, I wrote a Visual Basic 5 app that had to collect, return 0;
maintain, and report a lot of scientific data and perform a lot of }
}
calculations. Some of those calculations were so complex I sent
them to an Excel API.
In 1997, leveraging the Excel API to evaluate the formula from within
code and see no point in choosing this route over C#. Upon closer
examination, however, you may appreciate the terseness of the time C# would beat F# by a small margin. I can’t account for the
language, the ability to define the formulas more elegantly and, in oddity, but it’s possible there’s more I need to understand to per-
the end, the simple way I can apply the calculatePsi function Reese form truer profiling.
defined to the array of cylinders I passed to the method.
Keeping an Eye Out for Logic That Begs
for a Functional Language
I could get the client-side So while I have to work at my F# skills, my new understanding is
functionality and a performance going to apply nicely to apps I already have in production as well
as future apps. In my production apps, I can look at business logic
boost at the same time. I’ve relegated to the database and consider if an app would benefit
from an F# replacement. With new apps, I now have a keener
eye for spotting functionality I can code more efficiently with F#,
The terseness is thanks to the fact that F# is better designed to performing data manipulation, leveraging strongly typed units of
perform math functions than C# is, so defining those functions measurement and gaining performance. And there’s always the fun
is more efficient. But besides the geek appeal of the language, I of learning a new language and finding just the right scenarios for
was interested in performance. When I increased the number of which it was built! Q
cylinders per set in my tests, initially I did not see a performance
improvement over C#. Reese explained that the test environment JULIE LERMAN is a Microsoft MVP, .NET mentor and consultant who lives in the
is more expensive when using F#. So I then tested the performance hills of Vermont. You can find her presenting on data access and other Microsoft
in a console app using the Stopwatch to report the time passed. .NET topics at user groups and conferences around the world. She blogs at
The app built up a list of 50,000 cylinders, started the Stopwatch, thedatafarm.com/blog and is the author of “Programming Entity Framework”
passed the cylinders to either the C# or F# calculator to update the (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
PSI value for each cylinder, then stopped the Stopwatch when the her Pluralsight courses at juliel.me/PS-Videos.
calculations were complete.
In most of the cases, the C# process took about three times THANKS to the following technical expert for reviewing this article:
longer than the F# process, although about 20 percent of the Rachel Reese (Firefly Logic)
Remove data storage performance bottlenecks and scale your applications to extreme transaction processing
(XTP). Cache data in memory and reduce expensive database trips. NCache scales linearly by letting you add
inexpensive cache servers at runtime. JvCache is 100% Java implementation of NCache.
device when communicating with the cloud back end. Finally, Windows
we’ll present a brief introduction to Service Bus support for the Azure
Linux Virtual Admin Mobile
Machine Python Web Role Services
BUILD A FREE DEV/TEST SANDBOX IN THE CLOUD
MSDN subscribers can quickly spin up a dev/test environment on
Windows Azure at no cost. Get up to $150 in credits each month!
aka.ms/msdnmag
Figure 1 Arduino Sprinkler System Reference Architecture
28 msdn magazine
lot of money if there are many chatty devices. Furthermore, more Figure 2 Four Patterns for Device-Cloud Service Communication
data means more CPU use, which means more energy, a precious
Pattern Summary Example
resource on a mobile device. Most battery-powered devices equipped
Telemetry A client device sends A device publishes messages about
with a Wi-Fi transmitter and a SIM card need to enter a low-power data (one way) to a the temperature to Topics. The
“sleep” mode during periods when they aren’t transmitting or cloud service. cloud service subscribes to some or
receiving data. The IEEE 802.11 standard defines this power-save all of these temperature messages.
polling feature. The data gets buffered when the device is sleeping. Inquiry A client device sends A device inquires about upcoming
Once it awakens, the buffered data is delivered. Chatty networks a query to the cloud weather conditions by posting
fill buffers and prematurely awaken sleeping devices. service and receives a weather inquiry to a topic.
a response. The cloud service subscribes to
HTTP request/reply approaches can be ridiculously wasteful,
inquiries and posts a message
given the size of the payload relative to the overall HTTP request- response to a topic of its own to
response infrastructure. Suppose a device simply needs to report which the device subscribes.
a number to the cloud, such as temperature, pressure or GPS Command A cloud service issues The cloud service publishes a
coordinate. That binary data is probably only a few bytes in size, a command to a temperature message/command
but the HTTP POST is generally at least 500 to 1,000 bytes, with client device and to a topic to which a device
the request header alone ranging from 200 to 2,000 bytes. Sure, the client device subscribes. The device then turns
returns a success or water on or off and sends a reply
some developers use tricks, like stuffing everything into the HTTP failure response. back to the cloud service by
header to avoid the overhead of the body part of the HTTP request. posting a response to a topic.
But that isn’t sufficient, and the size of the HTTP request only gets Notification A cloud service issues The cloud service sends a time-
bigger when you have to transmit security credentials. a one-way out-of- reset message to a device by
Here’s some simple math to convince you. Imagine your device band notification to publishing the message to a topic
has to send temperature data every 5 seconds and the payload for a client device that’s to which that device subscribes.
important for the
the temperature data is a generous 20 bytes. In a 24-hour period,
device’s operation.
the temperature data by itself would transmit from the device to
the cloud about 350,000 bytes. If you add in the HTTP request/
response envelope, you raise each transmission by 800 bytes, a • Implement transactional behavior and atomicity
factor of 41, sending more than 14MB to the cloud instead of just • Support ordered delivery of messages and provide a
the 350KB of temperature data. This can get prohibitively expen- time-to-live for each message
sive if you’re supporting thousands of devices. • Extend to publish-subscribe scenarios easily using
Perhaps the biggest misconception is that VPNs are inherently Topics and Subscriptions
safe. The reality is that VPN networks can be risky, especially To get a more concrete idea of how a device connects to and
when devices connected to a VPN are outside the manufacturer’s communicates with the cloud back end, take a look at Figure 1,
or operator’s immediate physical control. Once a single device is which depicts how a special-purpose device might fit into a bigger
breached, all devices connected to the same VPN are vulnerable. architecture. We’ll use the canonical example of OpenSprinkler, an
Once an untrusted user gets access to a connected device, he or she open source, Internet-based sprinkler/irrigation valve controller
can use the device to explore and attack your internal resources. that’s capable of checking the weather before deciding to turn on
Despite these shortcomings, VPNs are often the only option the water. It’s built using Arduino parts. Note in Figure 1 that the
offered by many carriers. Arduino controls the sprinkler system using a home network as
the Internet connection and communicates with a cloud back end.
The Windows Azure Service Bus Approach
Windows Azure Service Bus offers some great solutions to these Solving Connectivity Problems
challenges. Leveraging the Service Bus is more secure, because the Windows Azure Service Bus does a great job of solving the address-
device is only an endpoint on the Internet where it can place mes- ability and network connectivity challenges. The Arduino device
sages into a queue. The device can’t reach other protected network would probably sit behind some NAT layer, making it difficult to
resources inside cloud services. In addition, using the Service Bus reach from a cloud service. Fortunately, the Service Bus dramati-
for device connectivity costs less in terms of power, because the cally simplifies connectivity by acting as a relay service and serving
device can sleep more often, waking up periodically to pull any as a proxy for a cloud back end. Moreover, it can provide Queues,
waiting messages from the queue. Topics and Subscriptions, which enables it to act as an event hub
The Service Bus provides even more value because it can: for messages sent between the cloud and the device. The decoupled
• Decouple device communication and interaction from nature of a queue acting as a relay lets the device asynchronously
your cloud service send and receive messages to and from the cloud, even if only occa-
• Enable load leveling and load balancing among several sionally connected. For security, the device can be authenticated with
instances of your back-end service SharedAccessSignature, SharedSecret, SAML or SimpleWebToken.
• Identify duplicate messages Notice in Figure 1 that one or more worker roles may be reading
• Gather messages into logical groups (called Sessions) from the Service Bus message queue. Worker roles can make
msdnmagazine.com February 2014 29
decisions and issue commands back to the device. Other worker All four patterns leverage Service Bus Topics and Subscriptions.
roles might be getting weather information from other systems, Depending on the direction of the communication (device to cloud
such as the National Weather Service. Worker roles may also be service or cloud service to device), the device can either subscribe
saving all the unprocessed incoming events into a NoSQL data- to topics or publish to topics. Topics are simply a mechanism to
base, such as MongoDB. send messages, while subscriptions are used to consume mes-
Figure 1 also shows mobile users interacting with Web roles sages. You can create filter rules for subscriptions to allow more
to schedule watering. Mobile users can receive push notifications fine-grained control over which messages are retrieved. Worker
from Windows Azure Mobile Services (WAMS), which supports roles in the cloud service can be used to publish messages to
all the major notification networks, such as Windows Notification topics or to consume messages from subscriptions.
Services (WNS), Microsoft Push Notification Service (MPNS), Due to space constraints, we can’t illustrate all of the patterns
Apple Push Notification Service (APNS) and Google Cloud here in this article, so we’ll delve into just one. Figure 3 shows a
Messaging for Android (GCM). WAMS makes it easy to support reference implementation of the Command pattern. It demon-
Windows, iOS and Android. strates that devices from Buildings 1 and 2 can subscribe to messages
You can even envisage a machine-learning part of the archi- (Commands) and post responses back to topics. Note that worker
tecture. Windows Azure can support Linux VMs and it’s quite roles in the cloud service can publish messages to a Temperature
simple to configure PyMongo (a Python driver for MongoDB) and Shade Command Topic and that specific devices can separately
to read the event stream produced by various devices and use subscribe to Temperature or Shade Control messages. Service Bus
machine-learning techniques in PyML to find patterns or make Topics and Subscriptions can be used in a wide variety of combi-
predictions about the event stream data. Based on certain predic- nations to partition the message flow appropriately.
tions or patterns, the cloud service can choose to send commands
to the device, such as turning on or shutting off the water. AMQP and Interconnectivity
A messaging system that’s the primary endpoint for sending and The Windows Azure Service Bus team recently announced support
receiving data is extensible, because devices can continue to send for the Advanced Message Queuing Protocol (AMQP) 1.0, an open
a single message stream while new Subscriptions can be added to standard with a binary application layer for message-oriented
a Service Bus Topic for each new system that will consume that middleware. Its main value is that it’s highly interoperable and that
message stream. These systems can be for real-time analytics and it uses a binary format on the wire to minimize payload size.
machine-learning as well as other scenarios described earlier. AMQP supports reliable message transfer, queuing, routing,
pub/sub and more. Because it’s a wire-level protocol targeting
Communicating with the Cloud data streaming across the network, any compliant tool can inter-
There are four patterns that can be used on the client to communi- act with the data regardless of the implementation language. This
cate with the cloud service. These are outlined in Figure 2. enables cross-platform, hybrid applications using an open, stan-
dard protocol. The library lets you mix and match
languages, frameworks, and OSes, supporting
Building 1 Building 2 .NET, Java, Python and PHP. You’ll find more
Device 1 Device 2 Device 3 Device 4 information on the Windows Azure Samples page
at aka.ms/G3izk8. Designed to be light and inter-
operable, AMQP is a good fit for many of today’s
devices needing connectivity to a cloud back end.
Service Bus However, AMQP is too much software for
today’s Arduino, which lacks the necessary memory,
Temperature Control Shade Control Temperature and Shade Response Topic storage and processing power. Running AMQP
Subscription Subscription
requires support for Transport Layer Security (TLS),
Temperature Response Shade Response a cryptographic protocol that provides com-
Temperature and Shade Command Topic Subscription Subscription
munication security over TCP. TLS uses X.509
certificates (asymmetric cryptography) to validate the
identity of communicating parties across the wire.
Worker Role Worker Role Worker Role Worker Role In addition, the Apache Qpid Proton client-based
for Temperature for Shade for Temperature for Shade messaging library is often used to integrate with the
Control Control Response Response AMQP to simplify communications across routers,
bridges and proxies. All of this raises the question:
How do you support low-end devices connecting
to cloud back ends while enjoying the benefits of
Windows Azure
the Service Bus messaging infrastructure?
One option is to pay more money and get a
Figure 3 Architecture for the Command Pattern Raspberry PI. If you don’t want to do that, you’ll
Wrapping Up
In this month’s column we presented four
patterns that can be used to build a reli-
able message exchange between a device
and cloud services. We introduced AMQP,
the open source message-queuing protocol
that helps to increase interoperability and
minimize bandwidth and is completely sup-
ported by the Windows Azure Service Bus.
Finally, we began discussing how to support
low-end devices connecting to cloud back
ends while using the Service Bus messaging
infrastructure, which we’ll continue in our
next article.
We’d like to thank Clemens Vasters and
Abhishek Lal for helping us understand the
brave new world of connected devices. Clearly,
the world of special-purpose devices con-
nected to cloud services is growing rapidly.
Traditional approaches to communicating
with a cloud service need to be reevaluated.
Security, bandwidth, network reliability, and
interoperability are just some of the chal-
lenges that architects and developers face
with special-purpose devices in the M2M
world. Using the Windows Azure Service Bus
makes those challenges far less daunting. Q
The Microsoft .NET Framework 4.5.1 release, along the new .NET just-in-time (JIT) compiler, which shipped as a
with Visual Studio 2013, introduces innovative features to increase Community Technology Preview (CTP) release around the same
developer productivity and application performance. Additionally, time as the .NET Framework 4.5.1.
it provides new features for improving the UX of consuming .NET
NuGet packages, which is important because NuGet is a primary More Productive Development
delivery vehicle for .NET Framework libraries. I’ll start with new debugging features delivered with the .NET
The previous product, the .NET Framework 4.5, was a big Framework 4.5.1 to improve developer productivity.
release with many new features. It has been installed on more than Async Debugging Improvements After setting up a solid and
200 million machines. The .NET Framework 4.5.1 was released easy-to-use base for the asynchronous programming model in
about 14 months later in October 2013, and despite the short the previous Framework releases, we wanted to smooth out some
time frame, it comes packed with many features requested by remaining aspects for the overall developer experience with the
customers. In this article, I’ll review the new features in the .NET .NET Framework 4.5.1. Two questions are essential for debugging
Framework 4.5.1, and for more details, you can refer to .NET asynchronous code: “How did I get into this async method?” and
Framework 4.5.1 RTM (bit.ly/1bBlEPN) and .NET Framework 4.5.1 “What is the state of all the tasks in my application?” Visual Studio
Preview (bit.ly/10Vr2ft) posts on the .NET Framework Blog. 2013 introduces enhancements to the Call Stack and Tasks windows
The .NET Framework 4.5.1 is only a part of what the .NET team to help you find answers to these questions in a much more intui-
(of which I’m a member) has been working on over the past year. tive way. These improvements are supported for desktop, Web and
We also shipped several libraries on NuGet to fill platform gaps Windows Store apps on Windows 8.1 and are available for C++
and to enable new scenarios. I’ll provide an overview of our .NET and JavaScript as well.
NuGet libraries and also highlight one of our deep investments, It’s common to have nested async method calls within an
app or library, which rely on the await keyword to manage the flow of
This article discusses: execution. Previously, Visual Studio didn’t show the chain of
async calls when stopped at a breakpoint within a Task. Visual
• New debugging features
Studio 2013 provides a logical and sequential view of methods in
• Application performance enhancements
a nested chain of calls for both asynchronous and synchronous
• Easier use of NuGet libraries methods. This makes it easier to understand how the program
• The new RyuJIT compiler reached a location inside an asynchronous call.
Technologies discussed: Figure 1 shows an asynchronous code sample. Figure 2 and Figure
Microsoft .NET Framework 4.5.1, Visual Studio 2013
3 demonstrate the difference between the call stack views of Visual
Studio 2012 and Visual Studio 2013 for that code. More details of this
32 msdn magazine
LAS VEGAS 2O14
March 10 - 14 | Planet Hollywood Hotel & Casino
vslive.com/lasvegas
MAY THE
CODE BE
WITH YOU
£
Intense Take-Home Training for
Developers, Software Architects WANT TO
and Designers
LEARN
Topics include: ³Windows Phone MORE?
³ Visual Studio/ ³Cross-Platform SCAN THIS
.NET Mobile QR CODE
TO JOIN OUR
Development MAILING LIST
³ Windows 8.1/
WinRT ³ ASP.NET
³WPF/Silverlight ³ HTML5
REGISTER BY
FEBRUARY 12
AND SAVE $300!
Visual Studio Live! Las Vegas vslive.com/lasvegas
is part of Live! 360 DEV, which
CONNECT WITH VISUAL STUDIO LIVE!
means you’ll have access to twitter.com/vslive – @VSLive
four (4) other co-located
facebook.com – Search ”VSLive”
events at no additional cost:
linkedin.com – Join the
Five (5) events means over a “Visual Studio Live” group!
hundred sessions to choose
AND INTRODUCING Web Dev Live!
from – mix and match sessions
to create your own, custom
event line-up – it’s like no other
dev conference available today!
magazine
BEST
BESTSELLER
SELLER ComponentOne Studio Enterprise 2013 v3 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
• Visual Studio 2013 and Bootstrap support
• New advanced theming tools for WinForms and ASP.NET
• 40+ UI widgets built with HTML5, jQuery, CSS3, and SVG
• New Windows Store Sparkline, DropDown, & Excel controls
dŚŽƵƐĂŶĚƐĂƌĞƵƐŝŶŐůĞdžƐLJƐdĞĂŵΠƚŽĐƌĞĂƚĞǁŽƌŬŇŽǁƐŽůƵƟŽŶƐĂŶĚǁĞďĂƉƉƐͲǁŝƚŚŽƵƚĐŽĚŝŶŐ͊
&ŽƌƚƵŶĞ ϱϬϬ ĐŽŵƉĂŶŝĞƐ͕ ƐƚĂƚĞ͕ ůŽĐĂů͕ K͕ ĂŶĚ ŽƚŚĞƌ ĨĞĚĞƌĂů ĂŐĞŶĐŝĞƐ ƵƐĞ dĞĂŵ ƚŽ ŵĂŶĂŐĞ ƚŚĞŝƌ ƚĂƐŬƐ͘
ĂƐŝůLJƚĂŝůŽƌdĞĂŵƚŽŵĞĞƚLJŽƵƌĞdžĂĐƚƌĞƋƵŝƌĞŵĞŶƚƐͲĞǀĞŶŝĨƚŚĞLJĐŚĂŶŐĞĚĂŝůLJ͕ǁĞĞŬůLJ͕ŽƌĞǀĞŶĞǀĞƌLJŵŝŶƵƚĞ͘
magazine
Register by March 5
This May, developers, software architects,
engineers, and designers will blast off in the
and Save $300!
Use promo code VSLFEB2
windy city for four days of unbiased and
cutting-edge education on the Microsoft
Platform. Live long and code with .NET gurus,
launch ideas with industry experts and rub CONNECT WITH VISUAL STUDIO LIVE!
elbows with Microsoft stars in pre-conference
workshops, 60+ sessions and fun networking twitter.com/vslive – @VSLive
events – all designed to make you better at your
job. Plus, explore hot topics like Web API, facebook.com – Search “VSLive”
jQuery, MongoDB, SQL Server Data Tools
and more! linkedin.com – Join the
“Visual Studio Live” group!
Tracks Include:
³ Visual Studio/.NET
³ ASP.NET
³ SharePoint/OfÀce
vslive.com/chicago
In exploring how to build more efficient Windows Store apps, (bit.ly/SgI0AA). If you haven’t read the previous article, you can find
I first looked at error handling. In this second article, I’ll examine sev- it at msdn.microsoft.com/magazine/dn519922.
eral techniques for improving a Windows Store app’s performance,
focusing on memory usage and HTML UI responsiveness. I’ll intro- Setting up the Example
duce the new predictable object lifecycle model in the Windows Throughout this article, I draw on specific examples you can test
Library for JavaScript on Windows 8.1 (WinJS 2.0). Then, I’ll in your own code. You can follow along or download the complete
examine Web Workers and the new Scheduler API in WinJS 2.0, code to peruse at your leisure.
both of which complete background tasks without locking the UI. I’m using different test cases than in the previous article, so you’ll want
As in the previous article, I’ll present both diagnostic tools for find- to add some new buttons to the global NavBar if you’re following along.
ing the problems and solutions for addressing the issues uncovered. (You can just start a brand-new Navigation app project if you prefer—
I’ll assume you’re fairly familiar with building Windows Store that works, too.) The new NavBarCommands are shown in Figure 1.
apps using JavaScript. If you’re relatively new to the platform, I For these test cases, I use the more realistic scenario of an app
suggest beginning with the basic “Hello World” example (bit.ly/ that surfaces content from the Web. This app fetches data from the
vVbVHC) or, for more of a challenge, the “Hilo” sample for JavaScript United States Library of Congress Print & Photographs Online
Catalog Web service (1.usa.gov/1d8nEio). I’ve written a module that
wraps calls to the Web service in promise objects and defines classes
This article discusses:
for storing the received data. Figure 2 shows the module, in a file
• Setting up a sample app that surfaces content from the Web titled searchLOC.js (/js/searchLOC.js).
• Disposing of objects and checking for memory leaks Remember to link to the searchLOC.js file from default.html at
• Implementing the dispose pattern in WinJS the root of your project before you try to call into it.
• Using the Scheduler and Web Worker APIs
Disposing of Objects
Technologies discussed:
In JavaScript, an object remains in memory as long as it can be
Windows 8.1, Windows Library for JavaScript 2.0, Visual Studio 2013 reached through a lexical environment or chain of references.
Code download available at: Once all references to the object have been removed, the Gar-
msdn.microsoft.com/magazine/msdnmag0214
bage Collector de-allocates memory from the object. As long as a
reference to the object remains, the object stays in memory. A
42 msdn magazine
Figure 1 Additional NavBarCommands in Default.html the document (through a call to removeChild or innerHTML). The
<div data-win-control="WinJS.UI.NavBar">
corresponding JavaScript object remains in memory, even though
<div data-win-control="WinJS.UI.NavBarContainer"> the corresponding HTML has vanished:
<!-- Other NavBarCommand elements. --> var newSpan = document.createElement("span");
document.getElementById("someDiv").appendChild(newSpan);
<div id="dispose"
data-win-control="WinJS.UI.NavBarCommand" document.getElementById("someDiv").innerHTML = "";
data-win-options="{
location: '/pages/dispose/dispose.html', WinJS.log && WinJS.log(newSpan === "undefined");
icon: 'delete', // The previous statement outputs false to the JavaScript console.
label: 'Dispose pattern in JS' // The variable "newSpan" still remains even though the corresponding
}"> // DOM object is gone.
</div> For a normal Web page, the life of an object extends only for as
<div id="scheduler"
data-win-control="WinJS.UI.NavBarCommand" long as the browser displays the page. Windows Store apps can’t
data-win-options="{ ignore these sorts of memory leaks. Apps commonly use a single
location: '/pages/scheduler/scheduler.html',
icon: 'clock', HTML page as a content host, where that page persists throughout
label: 'Scheduler' the app session (which could last for days, or even months). If an
}">
</div> app changes state (the user navigates from one page to another, for
<div id="worker" example, or a ListView control is scrolled so that some items fall out
data-win-control="WinJS.UI.NavBarCommand"
data-win-options="{ of visibility) without cleaning up memory allocated to unneeded
location: '/pages/worker/worker.html', JavaScript objects, that memory can become unavailable to the app.
icon: 'repair',
label: 'Web worker'
}"> Checking for Memory Leaks
</div>
</div> Luckily, Visual Studio 2013 has new features that can help developers
</div> track down memory leaks—in particular the Performance and
Diagnostics window. For this test case and the next, I’ll demon-
memory leak occurs if a reference to an object (and therefore the strate a couple of the tools that it surfaces.
object itself) remains beyond when it’s needed. For this test case, I’ll add a custom control to my solution that
One common cause of memory leaks in JavaScript applications purposely allows memory leaks. This control, named SearchLOC-
are “zombie” objects, which typically occur when a JavaScript object Control (/js/SearchLOCControl.js), creates a search text box and
references a DOM object and that DOM object is removed from then displays results after a response to a query has been received.
Figure 2 Accessing the Print & Photographs Online Catalog Web Service
(function () {
"use strict";
return httpClient.getStringAsync(new Windows.Foundation.Uri(queryurl)).
var baseUrl = "http://loc.gov/pictures/" then(function (response) {
var httpClient = new Windows.Web.Http.HttpClient();
collection.pictures = JSON.parse(response).
function searchPictures(query) { results.map(function (picture) {
var url = baseUrl + "search/?q=" + query + "&fo=json"; return new SearchResult(picture);
var queryURL = encodeURI(url); });
Figure 3 shows the code for SearchLOCControl.js. Again, remem- control and creates a memory leak by setting the innerHTML of
ber to link to this new JavaScript file from default.html. the control’s host <div> to an empty string, as shown in Figure 5.
Note that I use jQuery to build my custom control, which I add Now I can test the control’s memory usage. The Performance
to my solution using the NuGet Package Manager. Once you’ve and Diagnostics window provides several tools for measuring the
downloaded the NuGet package to your solution, you’ll need to performance of a Windows Store app, including CPU sampling, app
manually add a reference to the jQuery library in default.html. energy consumption, UI responsiveness and JavaScript function
The SearchLOCControl relies on some styling I’ve added to timing. (You can read more about these tools on the Visual Studio
default.css (/css/default.css), which is shown in Figure 4. team’s blog at bit.ly/1bESdOH.) If it’s not already visible, you’ll need to
Now I add a new page control named dispose.html (/pages/ open the Performance and Diagnostics pane, either through the
dispose/dispose.html) to the solution and add the following Debug menu (Visual Studio Express 2013 for Windows) or through
HTML markup inside the <section> tag of dispose to create the the Analyze menu (Visual Studio Professional 2013 and Visual
custom control: Studio Ultimate 2013).
<button id="dispose">Dispose</button><br/><br/> For this test, I use the JavaScript memory monitoring tool. Here
<div id="searchControl" data-win-control="SearchLOCControl.Control"></div>
are the steps for performing the test:
Finally, I add code to the PageControl.ready event handler in the
1. In the Performance and Diagnostics window, select
dispose.js file (/pages/dispose/dispose.js) that naively destroys the
JavaScript Memory and then click Start. The project
then runs in debugging mode. If prompted by a User
Figure 4 Styling Added to Default.css
Account Control dialog box, click Yes.
.searchList {
height: 700px !important; Figure 5 Code in Dispose.js to ”Destroy” the Custom Control
width: auto !important;
} (function () {
"use strict";
.searchResultsItem {
display: -ms-inline-grid; WinJS.UI.Pages.define("/pages/dispose/dispose.html", {
-ms-grid-columns: 200px; ready: function (element, options) {
-ms-grid-rows: 150px 150px WinJS.UI.processAll();
}
$("#dispose").click(function () {
.searchResultsItem img { var searchControl = $("#searchControl")[0];
-ms-grid-row: 1; searchControl.innerHTML = "";
max-height: 150px; });
max-width: 150px; }
}
// Other page control code.
.searchResultsItem .details {
-ms-grid-row: 2; });
} })();
www.textcontrol.com/reporting
US: +1 855-533-TEXT
txtextcontrol EU: +49 421 427 067-10
Higher Performance:
64 bit support for Windows Server, Windows 7 and 8
Scale-Out Performance:
Scale elastically. New machines are introduced to a running
database and become effective immediately
Cloud-Ready:
Azure compatibility for running / deploying easily in the cloud
for (var i = 0; i < hubSections.length; i++) { $(contentElement).append("<img src='" + pictures[i].pictureThumb + "' />");
hubSection = hubSections.getItem(i); (i % 2) && $(contentElement).append("<br/>")
collection = collections.getItem(i); }
populateSection(hubSection, collection); }
} })();
});
Desktop and then click Stop in the diagnostics session tab. Figure Scheduler
14 displays the results. JavaScript is a single-threaded environment, meaning everything
I see the frame rate dropped to 3 FPS for roughly half a is on the UI thread. In WinJS 2.0, Microsoft introduced the WinJS.
second. I select the period of low frame rate to see more details Utilities.Scheduler to organize work performed on the UI thread
(see Figure 15). (see bit.ly/1bFbpfb for more information).
At this point in the timeline (Figure 15), the UI thread is The Scheduler creates a single queue of jobs to be run on the
absorbed in running scheduler.js. If you look closely at the UI thread in the app. Jobs are completed based on priority, where
timeline details, you see several user marks (orange “tick” higher priority jobs can preempt or postpone lower-priority jobs.
marks). These indicate specific calls to performance.mark in the Jobs are scheduled around actual user interaction on the UI thread,
code. In scheduler.js, the first call to performance.mark occurs where the Scheduler slices up the time between calls and completes
when scheduler.html loads. Populating each HubSection as many of the queued jobs as it can.
control with content invokes a subsequent call. From the results, As mentioned, the scheduler executes jobs based on their
more than half of the time spent evaluating scheduler.js occurred priority, as set using the WinJS.Utilities.Scheduler.Priority
between when I navigated to the
page (the first user mark) and
when the sixth HubSection was
populated with images (the last
user mark).
(Keep in mind results will vary
depending on your hardware. The
HTML UI responsiveness tests
shown in this article were run
on a Microsoft Surface Pro with
a third-generation Intel Core i5-
3317U processor, running at 1.7Ghz,
and Intel HD Graphics 400. )
To reduce lag, I might refactor
my code so the HubSection con-
trols are populated in a staggered
manner. Users see content in the
app soon after they navigate to
it. The content for the first one
to two hub sections should load
immediately after navigation
and the other HubSections can
load afterward. Figure 14 HTML UI Responsiveness for Scheduler.html
Web Workers
Figure 15 Timeline Details Where the UI Thread Evaluates Scheduler.js The standard Web platform includes
the Web Worker API that lets an app
enumeration. The enumeration has seven values (in descending run background tasks off the UI thread. In short, Web Workers (or
order): max, high, aboveNormal, normal, belowNormal, idle and just Workers) allow for multi-threading in JavaScript applications.
min. Jobs of equal priority are run on a first-in, first-out basis. You pass simple messages (a string or simple JavaScript object) to the
Turning to the test case, I create a job on the Scheduler to populate Worker thread and the Worker returns messages back to the main
each HubSection when scheduler.html loads. For each HubSection, thread using the postMessage method.
I call Scheduler.schedule and pass in a function that populates the Workers run in a different script context from the rest of the app, so
HubSection. The first two jobs are run at normal priority and all the they can’t access the UI. You can’t create new HTML elements using
others are run when the UI thread is idle. In the third parameter for createElement or leverage features of third-party libraries that rely on
the schedule method, thisArg, I pass in some context for the job. the document object (for example, the jQuery function—$). However,
Figure 16 Updated Scheduler.js Using Scheduler API
(function () { priority,
"use strict"; { section: hubSection, collection: collection },
"adding hub section").
var dataRequest, jobOwnerToken; owner = jobOwnerToken;
var scheduler = WinJS.Utilities.Scheduler; }
});
WinJS.UI.Pages.define("/pages/scheduler/scheduler.html", { },
ready: function (element, options) {
performance.mark("navigated to scheduler"); unload: function () {
dataRequest && dataRequest.cancel();
dataRequest = Data.featuredCollections. jobOwnerToken && jobOwnerToken.cancelAll();
then(function (collections) { }
performance.mark("got collection");
// Other PageControl members ...
var hub = element.querySelector("#featuredHub"); });
if (!hub) { return; }
function populateSection(section, collection) {
var hubSections = hub.winControl.sections, performance.mark("creating a hub section");
hubSection, collection, priority; section.data.header = collection.data.title;
jobOwnerToken = scheduler.createOwnerToken(); var contentElement = section.data.contentElement;
contentElement.innerHTML = "";
for (var i = 0; i < hubSections.length; i++) {
hubSection = hubSections.getItem(i); var pictures = collection.data.pictures;
collection = collections.getItem(i); for (var i = 0; i < 6; i++) {
priority == (i < 2) ? scheduler.Priority.normal : $(contentElement).append("<img src='" + pictures[i].pictureThumb + "' />");
scheduler.Priority.idle; (i % 2) && $(contentElement).append("<br/>")
}
scheduler.schedule(function () { }
populateSection(this.section, this.collection) })();
},
keynote speakers
Scott Ambler Steve Denning
ALM Thought Leader and Co-creator of DAD Framework Award-winning Author
Disciplined Agile Delivery: The Foundation for Scaling Agile Transforming Management through Agile
plenary speakers
Mike Brittain James Whittaker Dave West
Director of Engineering, Etsy Distinguished Technical Evangelist, Microsoft Chief Product Officer, Tasktop
sponsors
diamond platinum
Aspect-Oriented
Programming with the
RealProxy Class
Bruno Sonnino
A well-architected application has separate layers so The good news is that something like that does exist: aspect-oriented
different concerns don’t interact more than needed. Imagine you’re programming (AOP). It separates general code from aspects that cross
designing a loosely coupled and maintainable application, but in the boundaries of an object or a layer. For example, the application log
the middle of the development, you see some requirements that isn’t tied to any application layer. It applies to the whole program and
might not fit well in the architecture, such as: should be present everywhere. That’s called a crosscutting concern.
• The application must have an authentication system, used AOP is, according to Wikipedia, “a programming paradigm
before any query or update. that aims to increase modularity by allowing the separation of
• The data must be validated before it’s written to the database. crosscutting concerns.” It deals with functionality that occurs in
• The application must have auditing and logging for multiple parts of the system and separates it from the core of the
sensible operations. application, thus improving separation of concerns while avoiding
• The application must maintain a debugging log to check duplication of code and coupling.
if operations are OK.
• Some operations must have their performance measured Figure 1 The Repository<T> Class
to see if they’re in the desired range. public class Repository<T> : IRepository<T>
Any of these requirements need a lot of work and, more than that, {
public void Add(T entity)
code duplication. You have to add the same code in many parts of {
the system, which goes against the “don’t repeat yourself ” (DRY) Console.WriteLine("Adding {0}", entity);
}
principle and makes maintenance more difficult. Any requirement
change causes a massive change in the program. When I have to public void Delete(T entity)
{
add something like that in my applications, I think, “Why can’t the Console.WriteLine("Deleting {0}", entity);
compiler add this repeated code in multiple places for me?” or, “I }
wish I had some option to ‘Add logging to this method.’” public void Update(T entity)
{
Console.WriteLine("Updating {0}", entity);
This article discusses: }
60 msdn magazine
Figure 2 The Main Program, with No Logging Figure 4 The Logger Repository
static void Main(string[] args) public class LoggerRepository<T> : IRepository<T>
{ {
Console.WriteLine("***\r\n Begin program - no logging\r\n"); private readonly IRepository<T> _decorated;
IRepository<Customer> customerRepository =
new Repository<Customer>(); public LoggerRepository(IRepository<T> decorated)
var customer = new Customer {
{ _decorated = decorated;
Id = 1, }
Name = "Customer 1",
Address = "Address 1" private void Log(string msg, object arg = null)
}; {
customerRepository.Add(customer); Console.ForegroundColor = ConsoleColor.Red;
customerRepository.Update(customer); Console.WriteLine(msg, arg);
customerRepository.Delete(customer); Console.ResetColor();
Console.WriteLine("\r\nEnd program - no logging\r\n***"); }
Console.ReadLine();
} public void Add(T entity)
{
Log("In decorator - Before Adding {0}", entity);
In this article, I’ll explain the basics of AOP and then detail how _decorated.Add(entity);
Log("In decorator - After Adding {0}", entity);
to make it easier by using a dynamic proxy via the Microsoft .NET }
Framework class RealProxy. public void Delete(T entity)
{
Implementing AOP Log("In decorator - Before Deleting {0}", entity);
_decorated.Delete(entity);
The biggest advantage of AOP is that you only have to worry about Log("In decorator - After Deleting {0}", entity);
the aspect in one place, programming it once and applying it in all }
the places where needed. There are many uses for AOP, such as: public void Update(T entity)
• Implementing logging in your application. {
Log("In decorator - Before Updating {0}", entity);
• Using authentication before an operation (such as allowing _decorated.Update(entity);
some operations only for authenticated users). Log("In decorator - After Updating {0}", entity);
}
• Implementing validation or notification for property
setters (calling the PropertyChanged event when a public IEnumerable<T> GetAll()
{
property has been changed for classes that implement Log("In decorator - Before Getting Entities");
the INotifyPropertyChanged interface). var result = _decorated.GetAll();
Log("In decorator - After Getting Entities");
• Changing the behavior of some methods. return result;
As you can see, AOP has many uses, but you must wield it with }
care. It will keep some code out of your sight, but it’s still there, run- public T GetById(int id)
ning in every call where the aspect is present. It can have bugs and {
Log("In decorator - Before Getting Entity {0}", id);
severely impact the performance of the application. A subtle bug in var result = _decorated.GetById(id);
the aspect might cost you many debugging hours. If your aspect isn’t Log("In decorator - After Getting Entity {0}", id);
return result;
used in many places, sometimes it’s better to add it directly to the code. }
AOP implementations use some common techniques: }
if (Thread.CurrentPrincipal.IsInRole("ADMIN"))
{
You simply create the new class, passing an instance of the old try
class as a parameter for its constructor. When you execute the {
Log("User authenticated - You can execute '{0}' ",
program, you can see it has the logging, as shown in Figure 6. methodCall.MethodName);
You might be thinking: “OK, the idea is good, but it’s a lot of work: I var result = methodInfo.Invoke(_decorated, methodCall.InArgs);
have to implement all the classes and add the aspect to all the methods. return new ReturnMessage(result, null, 0,
That will be difficult to maintain. Is there another way to do it?” With methodCall.LogicalCallContext, methodCall);
}
the .NET Framework, you can use reflection to get all methods and catch (Exception e)
execute them. The base class library (BCL) even has the RealProxy {
Log(string.Format(
class (bit.ly/18MfxWo) that does the implementation for you. "User authenticated - Exception {0} executing '{1}'", e),
methodCall.MethodName);
The RealProxy class gives you basic functionality for proxies. It’s }
Log("User not authenticated - You can't execute '{0}' ",
an abstract class that must be inherited by overriding its Invoke methodCall.MethodName);
method and adding new functionality. This class is in the name- return new ReturnMessage(null, null, 0,
methodCall.LogicalCallContext, methodCall);
space System.Runtime.Remoting.Proxies. To create a dynamic }
proxy, you use code similar to Figure 7. }
Filtering Functions
Until now, there was no filtering in the functions; the aspect is
applied to every class method that’s called. Often this isn’t the
desired behavior. For example, you might not want to log the
retrieval methods (GetAll and GetById). One way to accomplish
this is to filter the aspect by name, as in Figure 14.
The program checks if the method starts with “Get.” If it does, the
program doesn’t apply the aspect. This works, but the filtering code is
repeated three times. Besides that, the filter is inside the proxy, which
will make you change the class every time you want to change the
proxy. You can improve this by creating an IsValidMethod predicate:
private static bool IsValidMethod(MethodInfo methodInfo)
{
return !methodInfo.Name.StartsWith("Get");
Figure 13 Output of the Program Using Two Proxies }
Now you need to make the change in only one place, but you still OnAfterExecute and OnErrorExecuting. These methods verify whether
need to change the class every time you want to change the filter. the event handler is defined and, if it is, they check if the called
One solution to this would be to expose the filter as a class property, method passes the filter. If so, they call the event handler that applies
so you can assign the responsibility of creating a filter to the caller. the aspect. The factory class now becomes something like Figure 18.
You can create a Filter property of type Predicate<MethodInfo> Now you have a flexible proxy class, and you can choose the
and use it to filter the data, as shown in Figure 15. aspects to apply before executing, after executing or when there’s
The Filter property is initialized with Filter = m => true. That an error, and only for selected methods. With that, you can apply
means there’s no filter active. When assigning the Filter property, many aspects in your code with no repetition, in a simple way.
the program verifies if the value is null and, if so, it resets the
filter. In the Invoke method execution, the program checks the Not a Replacement
filter result and, if true, it applies the aspect. Now the proxy cre- With AOP you can add code to all layers of your application in a
ation in the factory class looks like this: centralized way, with no need to repeat code. I showed how to cre-
public class RepositoryFactory ate a generic dynamic proxy based on the Decorator design pattern
{
public static IRepository<T> Create<T>() that applies aspects to your classes using events and a predicate to
{ filter the functions you want.
var repository = new Repository<T>();
var dynamicProxy = new DynamicProxy<IRepository<T>>(repository) As you can see, the RealProxy class is a flexible class and gives
{ you full control of the code, with no external dependencies. How-
Filter = m => !m.Name.StartsWith("Get")
};
return dynamicProxy.GetTransparentProxy() as IRepository<T>;
}
}
}
The responsibility of creating the filter has been transferred to
the factory. When you run the program, you should get something
like Figure 16.
Notice in Figure 16 that the last two methods, GetAll and
GetById (represented by “Getting entities” and “Getting entity 1”)
don’t have logging around them. You can enhance the class even
further by exposing the aspects as events. That way, you don’t have
to change the class every time you want to change the aspect. This
is shown in Figure 17.
In Figure 17, three events, BeforeExecute, AfterExecute and
ErrorExecuting, are called by the methods OnBeforeExecute, Figure 16 Output with a Filtered Proxy
msdnmagazine.com February 2014 65
Figure 17 A Flexible Proxy
class DynamicProxy<T> : RealProxy if (AfterExecute != null)
{ {
private readonly T _decorated; var methodInfo = methodCall.MethodBase as MethodInfo;
private Predicate<MethodInfo> _filter; if (_filter(methodInfo))
AfterExecute(this, methodCall);
public event EventHandler<IMethodCallMessage> BeforeExecute; }
public event EventHandler<IMethodCallMessage> AfterExecute; }
public event EventHandler<IMethodCallMessage> ErrorExecuting;
public DynamicProxy(T decorated) private void OnErrorExecuting(IMethodCallMessage methodCall)
: base(typeof(T)) {
{ if (ErrorExecuting != null)
_decorated = decorated; {
Filter = m => true; var methodInfo = methodCall.MethodBase as MethodInfo;
} if (_filter(methodInfo))
ErrorExecuting(this, methodCall);
public Predicate<MethodInfo> Filter }
{ }
get { return _filter; }
set public override IMessage Invoke(IMessage msg)
{ {
if (value == null) var methodCall = msg as IMethodCallMessage;
_filter = m => true; var methodInfo = methodCall.MethodBase as MethodInfo;
else
_filter = value; OnBeforeExecute(methodCall);
} try
} {
var result = methodInfo.Invoke(_decorated, methodCall.InArgs);
private void OnBeforeExecute(IMethodCallMessage methodCall) OnAfterExecute(methodCall);
{
if (BeforeExecute != null) return new ReturnMessage(
{ result, null, 0, methodCall.LogicalCallContext, methodCall);
var methodInfo = methodCall.MethodBase as MethodInfo; }
if (_filter(methodInfo)) catch (Exception e)
BeforeExecute(this, methodCall); {
} OnErrorExecuting(methodCall);
} return new ReturnMessage(e, methodCall);
}
private void OnAfterExecute(IMethodCallMessage methodCall) }
{ }
ever, note that RealProxy isn’t a replacement for other AOP tools, On the other hand, with RealProxy, you’ll have full control of
such as PostSharp. PostSharp uses a completely different method. your source code, with no external dependencies, and you can
It will add intermediate language (IL) code in a post-compilation extend and customize it as much as you want. For example, if
step and won’t use reflection, so it should have better performance you want to apply an aspect only on methods that have the Log
than RealProxy. You’ll also have to do more work to implement an attribute, you could do something like this:
aspect with RealProxy than with PostSharp. With PostSharp, you public override IMessage Invoke(IMessage msg)
{
need only create the aspect class and add an attribute to the class var methodCall = msg as IMethodCallMessage;
(or the method) where you want the aspect added, and that’s all. var methodInfo = methodCall.MethodBase as MethodInfo;
if (!methodInfo.CustomAttributes
.Any(a => a.AttributeType == typeof (LogAttribute)))
Figure 18 A Repository Factory {
that Sets the Aspect Events and Filter var result = methodInfo.Invoke(_decorated, methodCall.InArgs);
return new ReturnMessage(result, null, 0,
methodCall.LogicalCallContext, methodCall);
public class RepositoryFactory
}
{
...
private static void Log(string msg, object arg = null)
{ Besides that, the technique used by RealProxy (intercept code
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(msg, arg);
and allow the program to replace it) is powerful. For example, if you
Console.ResetColor(); want to create a mocking framework, for creating generic mocks
}
public static IRepository<T> Create<T>()
and stubs for testing, you can use the RealProxy class to intercept
{ all calls and replace them with your own behavior, but that’s a sub-
var repository = new Repository<T>();
var dynamicProxy = new DynamicProxy<IRepository<T>>(repository);
ject for another article! Q
dynamicProxy.BeforeExecute += (s, e) => Log(
"Before executing '{0}'", e.MethodName);
dynamicProxy.AfterExecute += (s, e) => Log( BRUNO SONNINO is a Microsoft Most Valuable Professional (MVP) located in Brazil.
"After executing '{0}'", e.MethodName); He’s a developer, consultant, and author, having written five Delphi books, pub-
dynamicProxy.ErrorExecuting += (s, e) => Log( lished in Portuguese by Pearson Education Brazil, and many articles for Brazilian
"Error executing '{0}'", e.MethodName);
and U.S. magazines and Web sites.
dynamicProxy.Filter = m => !m.Name.StartsWith("Get");
return dynamicProxy.GetTransparentProxy() as IRepository<T>;
}
}
THANKS to the following Microsoft Research technical experts for reviewing
this article: James McCaffrey, Carlos Suarez and Johan Verwey
magazine
WITH
00110010010100101010010101011010010101010110101001010010100101010010010101010101101010001001010101010010000100110011011100010101010
1101010010000100001100101000100100011010100101011010000101101011010101110010000101000110011010101010011100110101000110101010001101110
0010101000100101010011101011011001010101011010100101001000000110101010001001010010101011100100010101101010000100111000010111001001000
01100101010100100101010101100101010001101010001010010101001101010101001010100010010101000100100010101100110110000101010001101110010
YOU!
PRODUCED BY
1/9/14 12:17 PM
LAS VEGAS 2O14
March 10 - 14 | Planet Hollywood Resort & Casino
COMPREHENSIVE
TRAINING
DEVELOPER
FOR THE
WORLD.
Visual Studio Live! Las Vegas is part of
Live! 360 DEV, which means you’ll have
Visual Studio Live! is your guide access to four (4) other co-located events
to the .NET Development universe, at no additional cost:
featuring code-¾lled days,
networking nights and independent
education. Whether you are a .NET
developer, software architect or a
designer, Visual Studio Live!’s
multi-track events include focused,
cutting-edge education on the .NET
platform that you’ll be ready to
implement as soon as you get back
to the of¾ce. AND INTRODUCING Web Dev Live!
Register by February 12
and Save $300!
Use promo code VSLFEB4
vslive.com/lasvegas
LT19 What’s New in Team Foundation LT20 Controlling Hardware Using LT21 WCF & Web API: Can We All LT22 Great User Experiences with
2:30 PM 3:45 PM
Server 2013 - Benjamin Day Windows 8.1 - Brian Peek Just Get Along?!? - Miguel Castro CSS 3 - Robert Boedigheimer
LTH01 What’s New in .NET 4.5.1 LTH02 Interaction Design Principles LTH04 Knocking it Out of the Park
8:00 AM 9:15 AM LTH03 To Be Announced
- Jason Bock and Patterns - Billy Hollis with Knockout.JS - Miguel Castro
LTH15 Visual Studio Online—It’s More LTH16 Creating Games for Windows 8 LTH18 Create an API For Your Application
11:00 AM 12:15 PM LTH17 To Be Announced
Than You Know - Brian Randell with Unity - Brian Lagunas With Service Stack - Jesse Liberty
LTH22 App Insights - App Performance LTH23 Building Composite XAML LTH24 Asynchronous Debugging LTH25 Busy Developer’s Guide to
1:30 PM 2:45 PM
Monitoring - Brian Randell Applications with Prism - Brian Lagunas in .NET - Jason Bock Node.js - Ted Neward
START TIME END TIME POST-CONFERENCE WORKSHOPS: FRIDAY, MARCH 14, 2014 (SEPARATE ENTRY FEE REQUIRED)
7:30 AM 8:00 AM Post-Conference Workshop Registration - Coffee and Morning Pastries
LWF01 Workshop: Deep Dive into Visual Studio 2013, TFS, LWF02 Workshop: Build and Submit a Game to the Windows LWF03 Workshop: Busy Developer’s
8:00 AM 5:00 PM
and Visual Studio Online - Brian Randell App Store - David Giard Guide to AngularJS - Ted Neward
SHAREPOINT LIVE! & SQL SERVER LIVE! TRACKS MODERN APPS LIVE! TRACK
Mobile Web JavaScript Developing Apps and SQL Server for the
Solutions for SharePoint Developer Modern Apps Live!
LT05 One ASP.NET - Game Changers for LT06 - Introduction to In-Memory OLTP using LT07 Introduction to Modern Apps
2013 - Jesse Liberty Hekaton in SQL Server 2014 - Kevin Goff Development - Rockford Lhotka
LT13 SQL Server 2012/2014 Columnstore Indexes LT14 Modern Apps Architecture
LT12 What's New in MVC 5 - Miguel Castro
- Kevin Goff - Rockford Lhotka
LT23 Build Real Time Websites with LT24 SQL Server in Windows Azure Virtual LT25 ALM with Visual Studio Online
SignalR - Rachel Appel Machines - Eric D. Boyd and Git - Brian Randell
LT30 What’s New in Web API 2 LT31 T-SQL for Application Developers LT32 Managing a Distributed
- Miguel Castro - Attendees Choose - Kevin Goff Project Team - Kevin Ford
LW05 Going Native with KendoUI Mobile LW06 How SharePoint Apps are LW07 Application Servers and
r - Keith Burnell Going to Save Us! - Bill Ayers Windows Azure - Kevin Ford
CONNECT WITH
LW12 Building Cross-Platform Phone Apps LW13 Developing Using the SharePoint 2013 LW14 Modern App Design
& Sites with jQuery Mobile - Nick Landry REST Services - Matthew DiFranco - Billy Hollis VISUAL STUDIO LIVE!
twitter.com/vslive – @VSLive
LW20 Introduction to Of¾ce 365 LW21 User Expperience Nuts
LW19 Tips for Building Multi-Touch Enabled
SharePoint Online Development and Bolts - Billy Hollis & Anthony
Web Sites - Ben Hoelting
- Matthew DiFranco Handley
facebook.com – Search “VSLive”
LW26 Build Once Deploy Everywhere LW27 Set Your Code Free! SharePoint Apps for LW28 Data Access and SQL Server
with Icenium from Telerik - Ben Hoelting the Mobile World - Bill Ayers - Steve Hughes & Dave Stienessen
Intercepting
Asynchronous Methods
Using Unity Interception
Fernando Simonazzi and Grigori Melnik
Unity (not to be confused with the Unity3D game engine) is a aspect-oriented programming (AOP). The runtime interception
general-purpose, extensible, dependency injection container with feature in Unity allows you to effectively intercept method calls to
interception support for use in any type of Microsoft .NET Framework- objects and perform pre- and post-processing of these calls.
based application. Unity is designed and maintained by the Interception in the Unity container has two main components:
Microsoft patterns & practices team (microsoft.com/practices). It can interceptors and interception behaviors. Interceptors determine the
be easily added to your application via NuGet, and you’ll find the mechanism used to intercept the calls to methods in the intercepted
main hub of learning resources related to Unity at msdn.com/unity. object, while the interception behaviors determine the actions that
This article focuses on Unity interception. Interception is a tech- are performed on the intercepted method calls. An intercepted
nique that’s useful when you want to modify the behavior of individual object is supplied with a pipeline of interception behaviors. When a
objects without affecting the behavior of other objects from the same method call is intercepted, each behavior in the pipeline is allowed
class, very much as you’d do when using the Decorator pattern (the to inspect and even modify the parameters of the method call, and
Wikipedia definition of the Decorator pattern can be found here: eventually the original method implementation is invoked. Upon
bit.ly/1gZZUQu). Interception provides a flexible approach for adding return, each behavior can inspect or replace the values returned
new behaviors to an object at run time. These behaviors typically or exceptions thrown by the original implementation or the pre-
address some crosscutting concerns, such as logging or data vali- vious behavior in the pipeline. Finally, the original caller gets the
dation. Interception is often used as the underlying mechanism for resulting return value, if any, or the resulting exception. Figure 1
depicts the interception mechanism.
There are two types of interception techniques: instance inter-
This article discusses:
ception and type interception. With instance interception, Unity
• The runtime interception feature in Unity dynamically creates a proxy object that’s inserted between the
• Intercepting TAP asynchronous methods client and the target object. The proxy object is then responsible
• Dealing with generics for passing the calls made by the client to the target object through
• An alternative to using await the behaviors. You can use Unity instance interception to intercept
objects created both by the Unity container and outside of the con-
Technologies discussed:
tainer, and you can use it to intercept both virtual and non-virtual
C# 5.0, Unity 3 methods. However, you can’t cast the dynamically created proxy
Code download available at: type to the type of the target object. With type interception, Unity
msdn.microsoft.com/magazine/msdnmag0214
dynamically creates a new type that derives from the type of
the target object and that includes the behaviors that handle the
72 msdn magazine
Fortunately, having an actual object representing the out-
Client Invoke Message
GetNextHandlerDelegate come of the operation makes interception of this asynchro-
Invoke
nous pattern relatively simple. Other asynchronous patterns
Return
Value Object are quite a bit more difficult to intercept: In the Asynchronous
Programming Model (bit.ly/ICl8aH) two methods represent
Proxy Object or Target Object or a single asynchronous operation, while in the Event-based
Behavior Behavior Behavior Original Class
Derived Class Asynchronous Pattern (bit.ly/19VdUWu) asynchronous opera-
Method
tions are represented by a method to initiate the operation
Return and an associated event to signal its completion.
Behaviors Pipeline Value
In order to accomplish the interception of the
asynchronous TAP operation, you can replace the Task
Figure 1 Unity Interception Mechanism returned by the method with a new Task that performs
the necessary post-processing after the original Task
crosscutting concerns. The Unity container instantiates objects completes. Callers of the intercepted method will receive the new
of the derived type at run time. Instance interception can only Task matching the method’s signature, and will observe the result
intercept public instance methods. Type interception can intercept of the intercepted method’s implementation, plus whatever extra
both public and protected virtual methods. Keep in mind that, processing the interception behavior performs.
due to platform constraints, Unity interception does not support
vstest.executionengine.x86.exe Warning: 0 : FERNANDO SIMONAZZI is a software developer and architect with more than 15 years
Async operation DoStuffAsync threw:
of professional experience. He has been a contributor to Microsoft patterns &
System.InvalidOperationException: invalid
at AsyncInterception.Tests.AsyncBehaviorTests2.TestObject.< practices projects, including several releases of the Enterprise Library, Unity,
DoStuffAsync>d__38.MoveNext() in d:\dev\interceptiontask\ CQRS Journey and Prism. Simonazzi is also an associate at Clarius Consulting.
AsyncInterception\AsyncInterception.Tests\
AsyncBehaviorTests2.cs:line 501
--- End of stack trace from previous location where exception was thrown --- DR. GRIGORI MELNIK is a principal program manager on the Microsoft patterns
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) & practices team. These days he drives the Microsoft Enterprise Library, Unity,
at System.Runtime.CompilerServices.TaskAwaiter. CQRS Journey and NUI patterns projects. Prior to that, he was a researcher
HandleNonSuccessAndDebuggerNotification(Task task)
and software engineer long enough ago to remember the joy of programming in
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at AsyncInterception.LoggingAsynchronousOperationInterceptionBehavior.< Fortran. Dr. Melnik blogs at blogs.msdn.com/agile.
CreateWrapperTask>d__3.MoveNext() in d:\dev\interceptiontask\
AsyncInterception\AsyncInterception\
LoggingAsynchronousOperationInterceptionBehavior.cs:line 63
THANKS to the following technical expert for reviewing this article:
Stephen Toub (Microsoft)
msdnmagazine.com February 2014 75
DIRECTX FACTOR CHARLES PETZOLD
positive Y axis, your thumb points to positive Z. With a left-hand for (size_t polygonIndex = 0; polygonIndex < m_srcPolygons.size(); polygonIndex++)
{
coordinate system, it’s the same except using the left hand. const Polygon& srcPolygon = m_srcPolygons.at(polygonIndex);
My goal here is to obtain a 2D path geometry of a short text string, Polygon& dstPolygon = m_dstPolygons.at(polygonIndex);
and then twist it around the origin into a 3D ring so the beginning for (size_t pointIndex = 0; pointIndex < srcPolygon.Points.size(); pointIndex++)
meets the end, similar to the illustration shown in Figure 1. Because {
const D2D1_POINT_2F pt = srcPolygon.Points.at(pointIndex);
I’ll be converting 2D coordinates to 3D coordinates and then back float radians = 2 * 3.14159f * (pt.x - m_geometryBounds.left) / geometryWidth;
to 2D, I’ve chosen to use a 3D coordinate system with Y coordinates float x = radius * sin(radians);
float z = radius * cos(radians);
increasing going down, just like in 2D. The positive Z axis comes out float y = height * ((pt.y - m_geometryBounds.top) / geometryHeight - 0.5f);
of the screen, but it’s really a left-hand coordinate system. dstPolygon.Points.at(pointIndex) = Point2F(x, y);
}
To make this whole job as easy as possible, I’ve used a font file }
stored as a program resource, and created an IDWriteFontFile
// Create path geometry from Polygon collection
object for obtaining the IDWriteFontFace object. Alternatively, DX::ThrowIfFailed(
you could obtain an IDWriteFontFace through a more roundabout Polygon::CreateGeometry(m_deviceResources->GetD2DFactory(),
m_dstPolygons,
method from the system font collection. &m_pathGeometry)
The ID2D1PathGeometry object generated from the Get- );
}
GlyphRunOutline method is then passed through the Simplify method
msdnmagazine.com February 2014 77
Getting Some Perspective
Three-dimensional graphics programming
is not just about coordinate points. Visual
cues are necessary for the viewer to interpret
an image on a 2D screen as representing an
object in 3D space. In the real world, you
rarely view objects from a constant vantage
point. You’d get a better view of the 3D text
Figure 4 The CircularText Display Figure 5 The Tilted CircularText Display in Figure 4 if you could tilt it somewhat so
it looks more like the ring in Figure 1.
CreateWindowSizeDependentResources that converts the source To get some perspective on the three-dimensional text, the
polygons to the destination polygons based on the size of the screen. coordinates need to be rotated in space. As you know, Direct2D
In the inner loop, you’ll see x, y and z values calculated. This is supports a matrix transform structure named D2D1_MATRIX
a 3D coordinate but it’s not even saved. Instead, it’s immediately _3x2_F that you can use to define 2D transforms, which you can
collapsed back into 2D by simply ignoring the z value. To calcu- apply to your 2D graphics output by first calling the SetTransform
late those 3D coordinates, the code first converts a horizontal method of ID2D1RenderTarget.
position on the original path geometry to an angle in radians from Most commonly, you would use a class named Matrix3x2F from
0 to 2π. The sin and cos functions calculate a position on a unit the D2D1 namespace for this purpose. This class derives from
circle on the XZ plane. The y value is a more direct conversion from D2D1_MATRIX_3x2F_F and provides methods for defining var-
the vertical coordinates of the original path geometry. ious types of standards for translation, scaling, rotation and skew.
The CreateWindowSizeDependentResources method concludes The Matrix3x2F class also defines a method named Transform-
by obtaining a new ID2D1PathGeometry object from the desti- Point that allows you to apply the transform “manually” to individual
nation Polygon collection. The Render method then sets a matrix D2D1_POINT_2F objects. This is useful for manipulating points
transform to put the origin in the center of the screen, and both fills before they’re rendered.
and outlines this path geometry, with the result shown in Figure 4. You may think I need a 3D rotation matrix to tilt the displayed
Is the program working? It’s hard to tell! Look closely and you text. I’ll certainly be exploring 3D matrix transforms in future
can see some wide characters in the center and narrower characters columns, but for now I can make do with 2D rotation. Imagine
at the left and right. But the big problem is that I started out with a yourself situated somewhere on the negative X axis of Figure 1,
path geometry with no intersecting lines, and now the geometry looking toward the origin. The positive Z and Y axes are situated
is displayed back over itself, with the result that overlapping areas just like the X and Y axes in a conventional 2D coordinate system,
are not filled. This effect is characteristic of geometries, and it hap- so it seems plausible that by applying a 2D rotation matrix to the
pens whether the path geometry created by the Polygon structure Z and Y values, I can rotate all the coordinates around the three-
has a fill mode of alternate or winding. dimensional X axis.
for (size_t pointIndex = 0; pointIndex < srcPolygon.Points.size(); pointIndex++) // Update FPS display text
{ uint32 fps = timer.GetFramesPerSecond();
const D2D1_POINT_2F pt = srcPolygon.Points.at(pointIndex);
float radians = 2 * 3.14159f * (pt.x - m_geometryBounds.left) / geometryWidth; m_text = (fps > 0) ? std::to_wstring(fps) + L" FPS" : L" - FPS";
}
To start my fifth year in this space, I want to tell you about a student of drive and competence. Think of Jose building his raft and
who came to Boston for one of my classes. He lives in Miami and I shoving off into the Florida Straits, and the courage that must
doubt it violates his privacy to tell you that his name is Jose. Over have required. The Miami Herald in December reported that one
drinks at the Harvard Faculty Club (see msdn.microsoft.com/magazine/ person died and two others went missing attempting the very same
dn532211), I asked him how he’d come to the United States. “From feat Jose managed so many years ago.
Cuba. On a raft. And now here I am at Harvard having drinks with Immigrants appreciate what we have here, things that we natives
the software legend.” take for granted. They don’t sweat small stuff, such as shopkeepers
I was (uncharacteristically, you must admit) speechless. But saying “Happy Holidays” instead of “Merry Christmas.” Most of
another student of mine, who left Cuba as an infant on a plane to them fled bad governments, usually of a collectivist or totalitarian
Spain, summed up Jose’s journey well: “That took cojones.” bent. They especially admire the U.S. Constitution’s limits on gov-
America has always been a refuge for immigrants. It holds an ernment. They’re quick to smell a rat and sound the alarm when
allure and offers a welcome like nowhere else, especially in techno- they see it being violated.
logical fields. Think of all the scientists and engineers we’ve welcomed
from abroad, and how they’ve enriched our country and the world:
Bell. Fermi. Einstein. Tesla. Von Neumann. Immigrants bring us an energy,
Andy Grove, another immigrant, writes: “By the time I was 20, I
had lived through a Hungarian Fascist dictatorship, German mil- a zest, that we can’t easily
itary occupation, the Nazi ‘Final Solution,’ the siege of Budapest
by the Soviet Red Army, a period of chaotic democracy in the duplicate in-house.
years immediately after the war, a variety of repressive Communist
regimes, and a popular uprising that was put down at gunpoint.”
(Busy guy, no?) Grove escaped to the United States in 1957 and So I say let them in. Throw open the doors to the serious geeks.
co-founded Intel in 1968. Maybe we could hold programming contests every year and take
Sometimes our global welcome generates profound ironies. While the top 1,000 entries. Maybe the top 10 teams at the Microsoft
welcoming Grove, we also welcomed a prime representative of his Imagine Cup competition should be offered green cards. (See my
persecutors: rocket scientist Werner von Braun, member of the Nazi October 2011 column at msdn.microsoft.com/magazine/hh456410.) Maybe
party and the SS. His 1960 biographical movie carried the title, “I anyone who earned a Ph.D. in a STEM field could stay here after
Aim at the Stars.” Cynics suggested a subtitle: “… But Sometimes I school, and if they kept their noses clean for 5 years could make that
Hit London.” Or as Tom Lehrer sang: “Don’t say that he’s hypocritical status permanent. You can probably think of other criteria that
/ Say rather that he’s apolitical. / ‘Once the rockets are up, who cares would work. This idea is so obvious and sensible, though, that it
where they come down? / That’s not my department,’ says Werner has no chance whatsoever of becoming government policy.
von Braun.” (You can listen here: bit.ly/1lJpABs.) We overlooked von “My sons are born here, Americans for life,” said Jose. “They’ll
Braun’s past; he built us a moon rocket. Good trade? Bad trade? never have to do what I did.”
Immigrants drive our technological leadership today as well. May we forever continue to be a refuge for immigrants. They
Think of Sergey Brin from Russia, co-founder of Google. Or Jer- want our freedom and opportunity. We need their brains. And we
ry Yang from Taipei, co-founder of Yahoo (although based on need their cojones, too. Q
the performance of Yahoo lately, maybe we shouldn’t count him.)
And it’s not just the Nobel-caliber immigrants that enrich our lives. DAVID S. PLATT teaches programming .NET at Harvard University Extension
Just think of really smart geeks here in the Windows community: School and at companies all over the world. He’s the author of 11 programming
Juval Lowy. Anders Hejlsberg. I’m sure you know plenty yourself. books, including “Why Software Sucks” (Addison-Wesley Professional, 2006)
and “Introducing Microsoft .NET” (Microsoft Press, 2002). Microsoft named
Immigrants bring us an energy, a zest, that we can’t easily him a Software Legend in 2002. He wonders whether he should tape down two
duplicate in-house. Having the chutzpah to leave your known world of his daughter’s fingers so she learns how to count in octal. You can contact him
behind for something you hope is better requires enormous levels at rollthunder.com.
80 msdn magazine
Untitled-5 1 1/8/14 4:11 PM
Untitled-1 1 1/15/14 10:02 AM
17
TH
DEVWEEK
SU
FROM THE ORGANISERS OF SOFTWARE ARCHITECT
CC
ES
SF
U
L
YE
AR
!
31ST MARCH – 4TH APRIL 2014 | CENTRAL HALL, WESTMINSTER, LONDON
BOOK
NOW
BOOK YOUR PLACE BY
31 JANUARY AND SAVE
UP TO £200
w w w. d e v w e e k . c o m
WELCOME VENUE
CENTRAL HALL
WESTMINSTER
LONDON,
SW1H 9NH
These colour symbols appear under the descriptions of each presentation throughout the guide.
WELCOME
AT-A-GLANCE AGENDA
NOW Richard
Blewett
Neal
Ford
Iordanis
Giannakakis
Dejan
Sarka
Bob
Beauchemin
BOOK YOUR PLACE BY AN INTRODUCTION FUNCTIONAL DEVICE EXCEL 2013 AND NEW CARDINALITY
31 JANUARY AND SAVE TO THE REACTIVE THINKING ¡ FRAGMENTATION OFFICE 365 POWER BI ESTIMATING FOR
UP TO £200 FRAMEWORK ¡ VS. CLEAN CODE ¡¡¡ QUERY PLANS¡
¡
AT-A-GLANCE AGENDA
ALSO EACH DAY... ®8 8.30 Coffee & registration | ® 11.00 Coffee break | 13.00 Lunch break | ® 15.30 Coffee break
THE FOLLOWING
WORKSHOPS RUN
FOR A FULL DAY, PROBLEM
FROM 09.30 TO SPACE ANALYSIS:
WHAT’S NEW BUILDING A new analytical technique
17.30 WITH A IN SQL SERVER HOW TO DESIGN GRAPH to deliver robust, easily
SHORT BREAK 2014 FOR STUFF THAT DATABASE implementable and change-
IN THE MORNING DEVELOPERS MATTERS, FAST! APPLICATIONS tolerant architectures
AND AFTERNOON,
AND A LUNCH Ian
BREAK AT 13.00. Robinson
Bob Eewei Jim Jules
Beauchemin Chen Webber May
UNLESS WORKSHOP REF: M1 WORKSHOP REF: M2 WORKSHOP REF: M3 WORKSHOP REF: M4
OTHERWISE
NOTED IN THE SQL Server Too much How do
DESCRIPTION, 2014 is just time is you design
around wasted a large
THEY ARE the corner creating that system?
PRESENTATION- and, in this big design We know
BASED IN STYLE workshop, Beauchemin upfront, only to find that users Neo4j is a JVM-based Waterfall doesn’t work very
RATHER THAN will discuss in detail don’t like what you have built graph database. For highly well, but also that Agile scales
‘HANDS-ON’ LABS. the most important and once it has been released. connected, semi-structured poorly. Various proposals have
compelling new features. Today, we are in danger of not data, graph databases are been made (BDUF, domain-
This includes memory- only over-designing, but also thousands of times faster than driven design, prototyping)
optimised tables and designing solutions to the relational databases, making but none has yet achieved
Please refer to page 2 compiled storage procedures wrong problems. them ideal for managing much traction.
for guide to colour symbols. (aka Hekaton), a new In this workshop, Chen complex data across many The key to managing a
in-memory storage engine for will demonstrate how to domains, from finance to large system is – precisely
greater speed in processing. experiment with rapid social, telecoms to geospatial. – managing change. No
The more interesting and design techniques to In this workshop, specification ever survives
useful implementation detail ensure design solutions Robinson and Webber its own implementation: as a
is that this is all integrated for the right business will cover the core system takes shape, everyone
with native SQL Server – no problems are delivered to functionality of the Neo4j –developers, architects and
new DDL and DML to learn, the right target audiences graph database. With a stakeholders – change their
and integration between rapidly and continuously. mixture of architecture minds continually. In any
memory-optimisation and He will show how to create and hands-on coding non-trivial project, goalposts
“traditional” tables is built-in. design solutions fast, as a sessions, you’ll quickly are constantly in motion. A
He will also cover clustered team, and how to work with learn how to develop a robust architecture is one that
columnstore indexes and other a client to get products that Neo4j-backed application. can anticipate those changes,
columnstore enhancements, really matter out into market Each session comprises a set and a good design is one that
which don’t require extra early. Good design involves of practical exercises designed can accommodate them
copies of your data to use the elegantly solving problems to introduce and reinforce an cheaply and efficiently.
in-memory, column-based despite the constraints. More aspect of the Neo4j stack. Problem space analysis is
xVelocity engine, and new often than not, time is one of Attendees won’t need any a technique that simply and
cardinality estimating for those constraints. previous experience of graph clearly anticipates, documents
query plans, which have been In this workshop, you databases to participate. and defines the changes
vastly overhauled based on a will be forced to think and They will, however, need that can affect a project.
decade or more of real-world act quickly, exploring how some experience of Java, and It informs the architectural
experience with the most to quickly work as a team to a laptop with a Java IDE of design so that it can
difficult query patterns. address a real-world problem; their choice. Attendees will accommodate those changes,
While these three changes rapidly analysing customer, leave with a good grounding in and it delivers a change-
alone are enough to fill the industry and business trends, developing a graph database tolerant ubiquitous language
whole day’s workshop, there behaviours and needs to solution, a copy of O’Reilly’s to unify and coordinate the
are many more changes validate ideas; and learning Graph Databases book, and development effort.
coming in CTP2 and beyond. how to apply the latest design a heap of additional exercises In this workshop,
Depending on public thinking, Lean Startup, Lean to help them hone their May will introduce the
availability of the relevant UX and agile methodologies, to skills further. principles of problem
information, Beauchemin bring your prototype to life and ¡ space analysis, and will
will also discuss and ensure it is as useful as it can show how those principles
demonstrate these. possibly be. can be translated into
¡ ¡ architectures and thence
into working systems,
even while the goalposts
BOOK are moving. The technique
®8 8.30 Coffee & registration | ® 11.00 Coffee break | 13.00 Lunch break | ® 15.30 Coffee break
AGILE
SOFTWARE SHAREPOINT EXCEL 2013 –
ARHICTECTURE 2013 SELF-SERVICE
SKETCHES DEVELOPERS’ IOS CRASH NODE.JS FOR BI AND DATA
AND NOUML OVERVIEW COURSE DEVELOPERS QUALITY
WORKSHOP REF: M5 WORKSHOP REF: M6 WORKSHOP REF: M7 WORKSHOP REF: M8 WORKSHOP REF: M9
THE FOLLOWING
PAGES PROVIDE Sander Roy
THE FULL Hoogendoorn Osherove
ABSTRACTS
FOR ALL THE coaching; a lot of them without the
MAIN BREAKOUT necessary real-life experience but
SESSIONS proudly waving their agile certificates,
BETWEEN 1ST
AND 3RD APRIL. DEATH BY INTEGRITY-
proving they at least had two days
THE MAIN DOGMA VERSUS DRIVEN of training.
ASSEMBLING DEVELOPMENT
CONFERENCE AGILE
During this challenging talk,
WILL BEGIN ON appreciated international speaker
TUESDAY, 1ST
APRIL, WITH WELCOME ADDRESS & Sander Hoogendoorn, global agile
A WELCOME KEYNOTE PRESENTATIONS thought-leader at Capgemini, shows
ADDRESS AND what happens to organisations and
TWO KEYNOTE 9.30am: Death by dogma projects that are coached by well-
PRESENTATIONS
FOR ALL versus assembling agile meaning consultants with little
ATTENDEES. Almost all organisations, large and experience. Often this leads to very
small, are turning towards agile to dogmatic applications of the more
Please refer to page 2
for guide to colour symbols.
escape failing traditional software popular agile approaches, mostly
development projects. Due to the Scrum and Kanban. This dogmatic
strong increase in popularity of agile thinking currently blocks the use of
approaches and techniques, many more elaborate techniques, tools and
newcomers enter the field of agile technology in agile projects, even when
9.30
these would really improve the work. Due 10.15am: Integrity-driven development
to this lack of experience and the growing What does it mean to develop with integrity?
dogmatism in the agile beliefs, more and Is it just a wishy-washy subject or can we
more agile projects will fail. translate it into actual day-to-day practices?
But perhaps even more importantly, The way we promise things; the way
during this talk, Hoogendoorn will also show we act when we know we can’t promise
that there is no such thing as one-size-fits-all something; how we give out estimates.
agile. Different organisations and different Do we face reality or do we tell people
projects require different agile approaches. what they want to hear? Does code review
Sometimes lightweight agile, user stories, improve integrity?
simple planning and estimation are just fine. In this session, Osherove will explain why
But in many projects, the way of working used integrity can provide a welcome change to
should rather be built up from slightly more developers who feel helpless in their jobs,
enterprise-ready approaches. doing the wrong thing, and knowing what
During this talk, Hoogendoorn will the right thing would have been.
demonstrate how to assemble an agile He will use examples from day-to-day
approach that is specifically suited to your work life, where you can choose to use
project, with many examples from real-life integrity or avoid it, and what are the
agile implementations. possible consequences.
11.30
Malik Kelly Clark Beauchemin Blewett
I WANT TO DEVELOP WHAT DO YOU GET IF CREATING HADOOP MEMORY-OPTIMISED AN INTRODUCTION
FOR SHAREPOINT, YOU COMBINE XP AND MAP-REDUCE JOBS TABLES AND TO THE REACTIVE
BUT I DON’T KNOW KANPAN? GET READY IN C# COMPILED STORED FRAMEWORK
WHERE TO START FOR XANPAN! All data processing in Hadoop PROCEDURES The Reactive Framework is
If you find SharePoint is The world doesn’t need essentially boils down to a (AKA HEKATON) a library that is based around
interesting, but don’t know another software development map-reduce process. The SQL Server 2014 introduces the IObservable interface
where to start, then this method, there are plenty mapping consists of retrieving a new in-memory storage and LINQ. It introduces a
session is for you. Malik already! But each team needs the data and performing engine for greater speed in compelling programming
will walk you through the to learn to create its own. operations, such as filtering processing. In addition, rather model that allows you to build
fundamental building blocks So what do you get if you and sorting. The reduce than reproduce the page-based “event”-based code with
of how to move from zero cross Kanban with Extreme part of the process involves structures of the original declarative LINQ statements.
to hero. Specific topics will Programming? Xanpan! a summary operation, such storage engine, this engine In this session, Blewett
include core programming In this session, Kelly will as grouping and counting. operates on linked lists of will introduce the Reactive
skills, investing in the right describe what you get if you Hadoop map-reduce jobs hash buckets – all structures Framework and show how it
areas to optimise your learning mix these two elements, throw are often written in Java, are lock and latch-free. can greatly simplify your code.
curve, free resources and tools in a bit more Lean, season which can present a steep Multi-version storage and ¡
to help you get started, tips with Economics and stir. The learning curve to non-Java optimistic concurrency
and tricks to get you on your resulting Xanpan focuses on programmers. However, the are used to get the most
way, and plenty more besides. teams not projects, and allows Microsoft SDK for Hadoop out of the new engine. The
If you’re looking to get started, for planned and unplanned provides a convenient API most interesting and useful
but need some help on your work within iterations and wrapper around the Hadoop implementation detail is
journey then don’t miss levels flow. One team using Streaming framework. that this is all integrated with
this session! this approach claims to be able Using this API, you can native SQL Server – no new
¡ to deliver “to the day”. create custom map-reduce DDL and DML to learn, and
¡¡ jobs in C#. In this session, integration between memory-
Clark will explore how to optimised and “traditional”
do this, and provide several tables is built-in.
concrete examples for ¡
learning the process.
¡¡
14.00
Friedman Clymer Sarka Milner Ford
ASP.NET MVC TIPS, SIMPLIFYING COLUMNSTORE WHAT’S NEW IN FUNCTIONAL
TRICKS AND THREAD-SAFE CODE INDEXES AND BATCH BIZTALK SERVER 2013 THINKING
HIDDEN GEMS WITH CONCURRENT PROCESSING IN Learn about the new features Learning the syntax of a new
The ASP.NET MVC DATA STRUCTURES SQL SERVER 2012 in BizTalk Server 2013 language is easy, but learning
framework has been around When developing multi- AND 2014 including new adapters, to think under a different
for quite a while now, and it threaded applications that With large data warehouses Windows Azure support, paradigm is hard. In this
has been constantly gaining share state, we need to (DW), it is essential to improvements to runtime session, Ford will help you
popularity ever since it consider thread safety when have fast queries. Before and administrative features, transition from a Java-writing
appeared on the scene. sharing state across multiple columnstore indexes and as well as ESB Toolkit imperative programmer to
However, despite that fact, threads. These techniques batch processing it was integration and what that a functional programmer,
a lot of MVC developers are require the developer to nearly impossible to achieve really means. BizTalk using Java, Clojure and
not aware of various hidden understand the possible race reasonable performance Server 2013 is an evolution Scala as examples. He will
gems that can make their conditions and select the of DW queries on large of Microsoft’s popular take common topics from
development experience cheapest synchronisation tables without investing integration messaging product imperative and OOP languages
much easier and nicer. In this technique to satisfy thread huge amounts of money that embraces the cloud and and look at alternative ways
session, Friedman will go safety. But, while essential, in parallelism, such as the the latest technologies such of solving those problems
through some of those secrets, they can often become tedious Parallel Data Warehouse. as SFTP, REST and Service in functional languages.
helping to ease and quicken and make the simplest of With SQL Server 2012 Bus. In this session, Milner Expect your mind to be bent,
your everyday work with the algorithms seemingly overly and 2014, you can achieve will demonstrate how to use but you’ll leave with a much
ASP.NET MVC framework. complicated and hard to satisfactory performance even the new REST adapter to better understanding of both
¡ maintain. In this session, with a traditional single- consume a public service, the syntax and semantics of
Clymer will explore the box database server. In this connecting to a Service Bus functional languages.
use of built-in concurrent session, Sarka goes beyond Queue using the adapter to ¡
data structures shipped a simple introduction of the send messages and another to
with TPL that will simplify columnstore indexes and receive messages, provisioning
multi-threaded code while batch processing, to include a BizTalk 2013 server in
maximising concurrency an in-depth explanation and Windows Azure IaaS, and
and efficiency. examples on how to get the much more.
¡ most out of these new features. ¡
¡
16.00
Chen Lambert Webber Aschenbrenner Giannakakis
ANGULAR JS AIN’T PRACTICE A LITTLE GRAPH THE DANGEROUS DEVICE
JUST ANOTHER PROGRAMMING – FOR THE BUSY BEAUTY OF FRAGMENTATION
MVC FRAMEWORK WHAT’S THE POINT? DEVELOPER BOOKMARK LOOKUPS VS. CLEAN CODE
You’ve probably heard of Practice Programming is a In this session, Webber will SQL Server Bookmark Trying to implement
Backbone.js as a JavaScript simple concept that can help explore powerful analytic Lookups can be very powerful, the same functionality
MVC (Model-View- any developer stay at the top techniques for graph data, when used correctly. However, on different devices, OS
Controller) framework for of their game, learning better beginning with some of the there are a lot of side effects versions, manufacturers and
building web apps, but it’s ways to do things. It can be innate properties of (social) that you should be aware of so on can be more trouble
worth exploring other options as simple as the old favourite graphs from fields such as when your indexing strategy than you’d expect. In this
when you want to get more out “Fizz-Buzz” program, to anthropology and sociology. relies on them. In this session, session, Giannakakis will
of your framework. AngularJS writing games in downtime. By understanding the forces Aschenbrenner will dig into show you how you can
is highly opinionated, which In this session, Lambert will and tensions within the the various problems that get the job done without
makes it easier for beginners explore the idea of Practice graph structure and applying Bookmark Lookups can compromising code quality
to grasp core MVC concepts, Programming, and how it some graph theory, it is cause, how they occur and and readability. Specifically, he
while veteran web developers can help you and the people possible to predict how the how you can resolve them to will demonstrate how to use
will enjoy its integration with around you in a relaxed, graph will evolve over time. get better performance from dependency injection, model-
automated testing suites. And and probably irreverent, To test just how powerful your SQL Server. Specific view-presenter pattern and
for anyone who wants to write discussion. He will look at and accurate graph theory topics will include the tipping other techniques to achieve
less boilerplate code? You will the ideas behind Practice is, he’ll (retrospectively) point, parameter sniffing the task at hand.
love Angular JS’s two-way Programming, why too much predict World War 1 based on problems, bad statistics, auto/ ¡
data binding abilities. Attend practice can be a bad idea a social graph and a simple forced parameterisation and
this session and Angular (practice makes imperfect) algorithm. These powerful Bookmark Lookup deadlocks.
JS just might turn into your and why practicing “bad techniques can also be applied ¡
favourite MVC framework. programming” can actually to modelling domains in
BOOK
¡¡ be helpful too. There will also
be examples that you can
Neo4j (a graph database).
Don’t worry, there won’t be NOW
use for your own Practice much maths. BOOK YOUR PLACE BY
Programming (both for good ¡ 31 JANUARY AND SAVE
UP TO £200
and bad).
¡
9.30
Hoogendoorn Goldshtein Holub Sarka Osherove
HOW FRAMEWORKS WHAT’S NEW IN MESSAGING WITH EXCEL 2013 AND REFACTORING SKILLS
CAN KILL YOUR C++ 11? RABBITMQ OFFICE 365 POWER BI FOR TDD
PROJECTS AND With the introduction of Messaging is one of the Excel is the analytical tool in You have been trying to learn
PATTERNS TO AVOID version 11, C++ is enjoying a most effective ways to pass the Microsoft Office suite for TDD, and it’s going pretty well,
BEING KILLED renaissance. But the changes non-time-critical information analysing both relational and but your code looks horrible.
When it comes to writing code, are so substantial that it’s between servers. It’s ideal for unstructured big data. In this Your design skills are lacking,
a seemingly endless stream now almost an entirely new use with remote databases, session, Sarka explores some and trying to let TDD drive the
of new frameworks hits the language. The new C++ logging, monitoring and of Excel’s technologies: Power design without having design
streets every year to help you. style is based on lambda so forth. RabbitMQ is one Pivot, through which Excel skills can lead to a problematic,
Or even every month. And, functions, rvalue references, of the most flexible of the becomes a single-user analysis although testable, design of
yes, frameworks can help you automatic type inference, messaging systems. It’s robust, service in tabular mode; Power your code. This workshop will
write better code faster. But variadic templates, new open source, easy to use and View and Power Map, for specifically deal with design
also, once you apply one or standard library collections, supports pretty much all of the creating ad-hoc reports on the skills, and assumes that you
more frameworks to a project, smart pointers and many developer platforms. In this tabular model with minimal already know how to write
trouble begins. What if you other features. In this session, session, Holub will discuss effort; and Power Query, giving unit tests. In this session,
require features that aren’t Goldshtein will show how messaging in general and you a data search engine, Osherove, the author of “The
implemented? What if it these features fit into existing how best to apply it in your so you can query data from Art of Unit Testing”, walks
contains bugs or omissions? C++ programs and how application. He then goes on to within your business and from through important techniques
And what if a new version is modern C++ development discuss Rabbit’s architecture external data sources. Sarka for refactoring and design
released that is implemented is up to par in productivity and programming. will also discuss the Office 365 of code that will be either
differently? These problems and performance with any ¡ BI sites, which provide the test driven or refactored for
can bring your project a halt. other language. infrastructure for publishing testability as part of a test-
In this session, Hoogendoorn ¡ your reports, if you do not use driven legacy effort. He will
demonstrates pragmatic an internal infrastructure. give real examples in .NET
architectures and patterns ¡¡¡ and Java. And most of the
that will help your projects workshop will be hands-on
avoid framework issues and pairing and refactoring on real
to keep code independent of code. Osherove will cover the
framework choices. following topics: clean code
¡ [continued below]
11.30
Rodenski Davies Clark Beauchemin
and SOLID design principles;
Ido WHAT’S NEW IN USING HIVE NEW CARDINALITY design for testability;
Flatow
VISUAL STUDIO 2013 TO QUERY AND ESTIMATING FOR refactoring patterns on hard-
BATTLE OF THE Discover what’s new in Visual PROCESS BIG DATA QUERY PLANS to-test legacy code; writing
FRAMEWORKS: Studio 2013. In this session, Writing map-reduce jobs Having accurate row tests against refactored code;
ASP.NET VS. NODE.JS you can hear from Microsoft to process data is not a estimates is crucial to obtain when it does and does not
It seems that Node.js is the about new features around trivial experience. This is a the best query plans. In SQL make sense to refactor; and
coolest kid on the block. developer productivity, web time-consuming task, even Server 2014, the cardinality open-source projects and how
More and more companies, development, Windows 8.1 for a seasoned Java or C# estimating calculators have we would refactor them.
from start-ups to giants such app development, .NET 4.5.1 programmer. Hive is a useful been vastly overhauled
as Microsoft and Linkedin, and Team Foundation Server. tool for creating and running based on a decade or more of Full-day workshop
are using Node.js in their Davies will outline what’s new map-reduce jobs in Hadoop. real-world experience with the ¡
applications. But can this in 2013, and provide numerous HiveQL is a declarative most difficult query patterns.
framework compete demonstrations in each of language, modelled to provide Among the patterns that
with a veteran such as these areas. Knowledge of a similar experience to writing give improved estimates
ASP.NET? There are many earlier versions is assumed. SQL: you construct and run are ever-increasing
considerations for using either ¡¡ the statement, submitting it keys and columns with
but, in this session, Rodenski to a query engine; the query correlation. One of the most
and Flatow will just let the engine transforms the query interesting features is the
frameworks fight it out. into a series of map-reduce instrumentation of the
¡ jobs. By not having to worry cardinality calculators through
about the low-level coding extended events; you can see
you become more productive how the estimate is produced.
and can concentrate on data ¡
analysis. This session will
get you up to speed with
Hive, and includes several
practical examples.
¡
14.00
Dahan Goldshtein Kennedy Aschenbrenner Osherove
PROGRAMMING IN TASK AND DATA APPLIED NOSQL UNIQUEIDENTIFIERS REFACTORING SKILLS
THE FOURTH PARALLELISM: REAL- IN .NET AS CLUSTERED KEYS FOR TDD
DIMENSION WORLD EXAMPLES Perhaps you’ve heard about IN SQL SERVER Full-day workshop
There are certain types of Many developers have seen the next generation of Everybody is doing it; nobody ¡
requirements that necessitate the Task Parallel Library APIs databases roughly classified wants to talk about it in public
developers thinking in four for concurrent applications, as NoSQL databases? These – uniqueidentifiers that are
dimensions. Specifically, but have only played around databases are generally much used as clustered keys in SQL
dealing with the passage with toy examples. In this better than RDBMS at scaling, Server. They have a lot of pros
of time in various business session, Goldshtein will performance and ease-of- for devs, but DBAs just cry
processes. In this session, demonstrate how to extract development (for instance, in when they see them used in
Dahan will take you through concurrency and parallelism NoSQL the object-relational this manner. In this session,
some common scenarios from seemingly impossible impedance mismatch usually Aschenbrenner will cover the
that will show the kind of situations, how to gain disappears). Unfortunately, basics about uniqueidentifiers,
business problems that scalability from lock-free many talks on NoSQL are why they are good and bad, and
are created by traditional code, and how to analyse very academic and general. how you can find out if they
programming techniques, as real-world parallel Not this one. In this session, affect the performance of your
well as solutions from the field applications with profilers Kennedy will explore the database. If they are affecting
of Event-Stream Processing to see the precise benefits NoSQL landscape and look your database negatively,
(also known as Complex Event gained from parallelisation. at the various options out you will also learn some best
Processing). Although there ¡ there. Then he’ll demonstrate practices how you can resolve
is foundational support for how to leverage MongoDB (a those performance limitations
these patterns in most queuing popular NoSQL DB) to build without changing your
technology, we’ll see why more .NET applications using LINQ underlying application.
supportive debugging and as the data access language. ¡
visualisation tools are needed. From there he will build a
You, too, can be a Time Lord. .NET application using LINQ
¡ and MongoDB in a series of
interactive demos using Visual
Studio 2012 and C#.
¡
16.00
Chen Courtenay Sarka Milner Osherove
BETA.TELUS.COM: WHAT ARE AUTO- SQL SERVER DID YOU GET MY REFACTORING SKILLS
RESPONSIVE, MOCKING CONTAINERS, TRANSACTION MESSAGE? BROKERED FOR TDD
ITERATIVE, AND WHY SHOULD YOU ISOLATION LEVELS MESSAGING ON Full-day workshop
COLLABORATIVE USE THEM? SQL Server has a complete WINDOWS AND ¡
In early 2013, a skunkworks Explore how to use auto- set of transaction isolation BEYOND
team of designers, developers mocking containers to improve levels, providing any of the In this session, Milner will
and strategists came together and streamline your unit four pessimistic and two explain the importance of
to rethink the website of one tests, and to exercise your IoC optimistic locking levels. brokered messaging and
of Canada’s largest telcos. container in a testable fashion. In order to achieve a good the various tools you can
Beta.telus.com was the first Using Ninject and the Ninject compromise between data use to implement it. He will
project to come out of the Mocking Kernel package as integrity and performance discuss MSMQ, Service Bus
TELUS Digital Labs, and an example, this demo-led suitable for business needs, for Windows and Windows
there were many lessons session will take you through it is essential to choose the Azure, and RabbitMQ. You
learned along the way, such the problem space that auto- right one. A developer needs will learn about core brokered
as how to implement Lean mocking containers address, to thoroughly understand messaging concepts and
methodology in an Enterprise- covering lessons learned from the possible problems that how each of these tools
loving company, how to get a large-scale development. can be caused by selecting supports them. If you are
designers and developers Starting from a simple project, an inappropriate isolation building distributed systems
rapid prototyping together, Courtenay will demonstrate level. So in this session, and aren’t using a message
and more. What worked the fragility of existing unit Sarka will demonstrate how broker in some fashion, you
and what needed re-work tests and how developers can they all work, explaining the need to come to this session
in this large mobile-first, be discouraged from making infrastructure behind each to learn why you should.
responsive redesign? Get a comprehensive tests because one, and leave you with an Demonstrations will cover
behind the scenes look into they can be an inhibitor to understanding of which simple queued messaging with
BOOK
some of the processes, tools
and technologies used to get
refactoring processes. He will
then introduce the idea of
levels are best suited to which
problems.
all frameworks, scale out with
multiple receivers, integrating NOW
beta.telus.com off the ground auto-mocking containers by ¡ RabbitMQ with Service Bus BOOK YOUR PLACE BY
in only four months, with demonstrating the use of the using AMQP, and much, much 31 JANUARY AND SAVE
UP TO £200
updates almost every week. Ninject Mocking Kernel. more.
¡¡ ¡ ¡
9.30
Holub Taulty Sarka Beachemin Ford
KNOCKOUT: WINDOWS 8.1 APPS: THE ART (AND ARIMA) WORK WITH SPATIAL CONTINUOUS
AN INTRODUCTION WHAT’S NEW FOR OF FORECASTING DATA IN SQL SERVER DELIVERY
The Knockout framework is APP DEVELOPERS? Forecasting is not easy, Every phone, tablet and WORKSHOP
a standalone implementation Windows 8 was a dramatic especially if it is about the Twitter message contains Getting software released
of the MVVM (Model View shift: a new version of the future. Using the Time Series spatial data. In this session, to users is often a painful,
ViewModel) pattern, which is operating system with algorithm in SQL Server Beauchemin will demonstrate risky and time-consuming
one of the best user-interface new input mechanisms, Analysis Services is a quite how to import your spatial process. In this workshop,
architectures for web new devices, new apps on straightforward process. data into SQL Server and use Ford sets out the principles
applications. It implements a new platform, and a new However, many times you do it there. He will also include and technical practices that
“declarative bindings” and Store. Only a year later, not get valuable results. In a discussion/demo of using enable rapid, incremental
automatic UI refresh, which Windows 8.1 came along with this session, Sarka will talk SQL Server’s spatial library delivery of high-quality,
in practice, automatically thousands of refinements about Auto-Regressive Trees with other data platforms valuable new functionality to
updates the user interface as and enhancements to both (ART) and Auto-Regressive for analysis. users. Through automation
the underlying data model’s the operating system and Integrated Moving Averages ¡ of the build, deployment
state changes. When used with the app platform. In this (ARIMA) algorithms in depth, and testing process, and
a “server push” package, such session, Taulty will pick out explaining why you get what improved collaboration
as LightStreamer, you can some highlights and walk you you get, and how can you between developers, testers
modify a value on the server through code to show the main overcome typical forecasting and operations, delivery teams
and that modification will be areas that have changed for a problems. He will also show can get changes released in a
immediately visible on the .NET developer who’s already how you can measure the matter of hours – sometimes
web client (and vice versa). In building Windows 8 apps or quality of your forecasts, and even minutes – no matter
this session, Holub will look who’s coming to Windows 8.1 discuss the data preparation what the size of a project or
at Knockout’s architecture new for the first time. for forecasting. the complexity of its code base.
and how to leverage that ¡ ¡ To begin with, Ford will move
architecture to build highly from release, back through
interactive web-application testing, to development
user interfaces. There will be practices, analysing at
several JavaScript examples. each stage how to improve
¡ collaboration and increase
[continued below]
11.30
Randell Henney Kennedy Dahan
feedback so as to make the
MAKING THE MOST OF SEVEN INEFFECTIVE HIGH-PERFORMANCE LOOSELY-COUPLED delivery process as fast and
THE TFS SERVICE CODING HABITS OF NOSQL TECHNIQUES ORCHESTRATION efficient as possible. Later,
Do you have a distributed MANY PROGRAMMERS You’re one of the brave ones WITH MESSAGING Ford will introduce agile
team? Are you looking for Habits help you manage the who has jumped into the Event-driven architecture infrastructure, including the
someone to take care of your complexity of code. You apply NoSQL pool and found it a (EDA) is one of the most use of Puppet to automate the
team’s source code repository existing skills and knowledge refreshing change. That’s powerful, yet least utilised, management of testing and
and bug list so you don’t automatically to the detail, awesome. But there is so much architectural approaches to production environments.
have to? If so, take a look at while focusing on the bigger more to being successful with building distributed systems. He will discuss automating
Team Foundation Service. picture. But because you NoSQL databases than simply Ever since callbacks made data management, including
Located at tfs.visualstudio. acquire habits largely by getting started. In this session, their way into programming migrations. Development
com, it brings together imitation, and rarely question Kennedy will explore some of languages, developers have practices that enable
Microsoft Visual Studio, them, how do you know your the issues, techniques and best been arguing whether the incremental development
Team Foundation Server habits are effective? Many of practices for being successful benefits of looser-coupling and delivery will be covered at
and Windows Azure. In this the habits that programmers with NoSQL, in general (and outweigh the drawback length, including a discussion
session, Randell will show you have for naming, formatting, MongoDB, in particular). seeing the control flow in of why branching is inimical
how to get started with the commenting and unit testing This includes exploring one place. These arguments to continuous delivery.
service, load up code, track do not stand up as rational and correct document/entity continue as developers look to
your work and run builds. practical on closer inspection. design, indexes and leverage technologies such Full-day workshop
More importantly, he will help In this session, Henney deployment – to name just as RabbitMQ on-premise, ¡
you understand the pros and examines seven coding habits a few of the topics. If you’re or Azure Queues and
cons of moving to the cloud. that are not as effective as getting started with NoSQL, Amazon SQS in the cloud.
He’ll also discuss how Team programmers believe, and this session should help you In this session, Dahan
Foundation Service differs suggests alternatives. take things to the next level. will demonstrate which
from Team Foundation Server, ¡ ¡ development practices
and what that means to you can bring the global flow
and your team. visualisation of orchestration
¡¡ to your publish/subscribe
messaging architectures to
get the best of both worlds.
¡
14.00
Malik Courtenay Sarka Evans Ford
SHAREPOINT CSOM GROWING OPTIMISING SPECIFICATION CONINUOS DELIVERY
AND REST IN THE CONFIGURABLE TEMPORAL QUERIES BY EXAMPLE WORKSHOP
REAL WORLD SOFTWARE WITH (PART 1): Get practical, hands-on Full-day workshop
CSOM and REST: the single EXPRESSION<T> AN INTRODUCTION experience of Specification ¡
most important SharePoint Learn how to use expression Although temporal data is part by example (SBE), one of the
topic you need to be on top trees to enable configurable of many business applications, most important concepts
of. In this session, Malik will and testable business most RDBMS, including in agile and iterative
cover the architecture of rules, without sacrificing SQL Server, do not support development. SBE is a set
REST and CSOM, what tools performance. In this session, it out of the box. However, of process patterns that
to use when developing, how Courtenay will start by before solving the problem, help agile software teams
to discover the API, advanced demonstrating an example you need to understand it. deliver value more reliably, by
scenarios such as debugging project where business rules In this session, Sarka will using the power of concrete
and concurrency, best are controlled by configuration provide an introduction to examples as a means of
practices, and less-obvious using a composite strategy temporal problems, then go on collaborating on requirements
things that will bite you. pattern. The pattern will be to develop Interval CLR data and design, enabling a shared
Ouch! Don’t miss. refactored into a provider that type. He will then discuss what understanding between
¡¡ supplies an expression tree, kind of constraints pertain to business and technical people.
which will then be compiled. temporal data, and how we In this session, Evans will
Simple benchmarking will query temporal data. Please cover some of the key patterns
be used to demonstrate the note, this is the theoretical of SBE, through a set of
performance benefits of this introduction needed for hands-on exercises, to ensure
approach. Another demo the following Optimising you get beyond the theory and
will show creating a simple temporal queries (Part 2): into the practice, where deep
expression tree and compiling the optimisation session, learning takes place.
it to a standalone DLL, intended to provide the ¡
which will then be executed groundwork for those
by a test project. who do not yet have a
¡¡ deep understanding of
temporal problems.
¡
16.00
Clymer Smallshire Sarka Beauchemin Ford
PATTERNS IN DELIVER DOMAIN- OPTIMISING WHAT’S IN CONINUOS DELIVERY
PARALLEL DRIVEN DESIGNS – TEMPORAL QUERIES MICROSOFT’S WORKSHOP
PROGRAMMING DYNAMICALLY! (PART 2): HADOOP OFFERINGS? Full-day workshop
WITH TPL How will you model your THE OPTIMISATION In this session, Beauchemin ¡
The free lunch is over: ever-changing world? Having a SQL Server solution looks at Microsoft’s
applications no longer get Domain-driven design (DDD) for a problem does not mean implementation of Hadoop
a massive performance codifies perspectives on the job is done. Of course, in conjunction/comparison
boost whenever a new CPU reality into a domain model, the next immediate issue is with some of the more
arrives. In order to take which is realised as a software the performance. Temporal well-known offerings. See
advantage of the increased system around which valuable queries that involve intervals what Microsoft has added
power, applications need to services can be constructed. are typically very IO and CPU for .NET data programming
be designed to take advantage As business domains change, intensive. For example, a and management. This
of the multiple cores. This our requirements and models test for overlapping intervals session covers both the
means a shift in the algorithms must follow. Dynamic was solved with inefficient cloud implementation and
and techniques we employ. languages, such as Python queries for years. However, a “traditional” Hadoop running
In the same way that OO and Ruby, coupled with handful of solutions with fast under Windows.
has design patterns, parallel document databases, can queries were developed lately. ¡
programming also has its own produce flexible domain In this high-level technical
catalogue of patterns to solve models that can gracefully session, Sarka introduces
re-occurring problems. In this accommodate new five different methods to get
session, Clymer will introduce information that wasn’t efficient queries that search
a variety of parallel processing explicitly modelled by the for overlapping intervals, one
patterns and give examples original designers. Discover of the most complex temporal
of implementations using when and how dynamic problems. Of course, these
BOOK
Microsoft’s TPL from simple
fork/join, divide and conquer,
language solutions are most
appropriate for domain
solutions can be implemented
on other temporal problems NOW
geometric decomposition, models, and understand as well. BOOK YOUR PLACE BY
pipelines to the slightly the trade-offs. ¡ 31 JANUARY AND SAVE
UP TO £200
bizarre Monte Carlo. ¡
¡¡
THE FOLLOWING
WORKSHOPS RUN
FOR A FULL DAY, DELIVER
FROM 09.30 TO BUILDING DOMAIN- AGILE/
17.30 WITH A SCALABLE DRIVEN SHAREPOINT OO-DESIGN,
SHORT BREAK JAVASCRIPT DESIGNS – 2013 APP FROM START
IN THE MORNING APPS DYNAMICALLY! DEVELOPMENT TO FINISH
AND AFTERNOON,
AND A LUNCH Austin
BREAK AT 13.00. Bingham
Gil Rober t Sahil Allen
Fink Smallshire Malik Holub
UNLESS WORKSHOP REF: F1 WORKSHOP REF: F2 WORKSHOP REF: F3 WORKSHOP REF: F4
OTHERWISE
NOTED IN THE Building and Apps Many people
DESCRIPTION, maintaining enable any who think
large and developer they’re
THEY ARE scalable to deliver doing OO
PRESENTATION- JavaScript SharePoint aren’t. For
BASED IN STYLE web apps is not at all easy. How do you statically model functionality. They allow you example, the dynamic model
RATHER THAN So how you build such an ever-changing world? The to use things such as MVC, (that shows how run-time
‘HANDS-ON’ LABS. things without being driven approach of domain-driven TDD and everything else you objects interact) should drive
into madness? Using and design (DDD) describes the like with SharePoint. Apps the design process; the class
combining proven JavaScript codification of perspectives of are the single biggest change diagram is an artefact you
patterns will do the trick. reality into a domain model, between SharePoint 2010 build while doing dynamic
Please refer to page 2 In this one-day which is in turn realised as and 2013. Is it surprising, modelling. Fixating on the
for guide to colour symbols. workshop, Fink will a software system around then, to discover that the apps class diagram renders your
talk about the patterns which valuable services can platform is full of gaping holes program, at best unwieldy,
behind some of the largest be constructed. As business – missing functionality and at worst non-functional.
JavaScript apps, such as and physical domains evolve, pitfalls – things you need to Similarly, basic OO
Gmail and Twitter, and our requirements, models and watch out for? architectural goals (such
how to apply them in your implementations must follow In this session, Malik as eliminating getter/setter
own apps. He will start if they are to remain relevant. will cover all those topics functions) seem impossible to
from object patterns and Dynamic languages, such that you won’t read on do unless you understand how
then focus in on module as Python are a great match MSDN, but that you the design process actually
patterns, promises, timers for the dynamism of the real will discover in your works. It turns out that the
and more. world. It is perhaps surprising projects. No stone will process you use influences
¡ then, that for much of the be left unturned. both the quality and the basic
decade since its inception, Those who will get the structure of the design.
DDD has manifested its most out of this session are In this workshop,
results in rigid relational- those who are either .NET Holub will cover an agile
database schemas, object developers who don’t want version of the OO-design
relational mappers pushed to learn SharePoint – or are process, with an emphasis
beyond reasonable limits and clinging on to best practices on how to arrive at an
inflexible object models in as they are being forced optimal design.
statically typed languages such into delivering SharePoint He’ll provide a quick
as Java or C#. functionality – or seasoned overview of the process,
In this hands-on SharePoint developers who then spend much of the class
workshop, participants want to know the real deal working through one (or more
will work together to on apps. if we have time) real-world
implement a domain ¡ examples that show you the
model in Python using entire process, from front to
nothing more that plain back: requirements gathering
old Python objects. and problem-statement
Bingham and Smallshire definition, use-case analysis
will show how core DDD (story development), and the
concepts, such as entities, simultaneous construction of
immutable value objects, the dynamic and static models
aggregates and repositories, using UML.
can be implemented in Python. ¡
They will build declarative
tools from scratch to facilitate
model implementation, and
BOOK they’ll evaluate persistence
®8 8.30 Coffee & registration | ® 11.00 Coffee break | 13.00 Lunch break | ® 15.30 Coffee break
FROM ZERO BUILDING
TO APP HOW DO THE DOMAIN-
WITH NOSQL, COOL KIDS ANDROID DRIVEN
MONGODB EFFECTIVE CREATE CHATS FOR .NET APPS WITH
AND .NET USER STORIES TODAY? DEVELOPERS APACHE ISIS
WORKSHOP REF: F5 WORKSHOP REF: F6 WORKSHOP REF: F7 WORKSHOP REF: F8 WORKSHOP REF: F9
SPEAKERS
MEET YOUR
SPEAKERS Paul Klaus Bob Austin
DEVWEEK Ardeleanu Aschenbrenner Beauchemin Bingham
ATTRACTS A Paul is an Klaus provides Bob is a database- Austin is a
WORLD-CLASS experienced iOS and independent SQL centric application founding director
web tinker, trainer Server consulting practitioner and of Sixty North, a
SPEAKER FACULTY. and mentor, currently teaching services across Europe and architect, writer, software consulting, training
FIND OUT MORE iOS at SkillsMatter in London, the US. He has worked with instructor, course author and and application development
ABOUT THEIR UK. He started programming SQL Server 2005/2008/ Developer Skills Partner for company. He is also an
EXPERIENCE back when Fortran was cool 2012/2014 from the very SQL skills. Over the past few experienced presenter and
AND EXPERTISE and graduated with a PhD beginning, and in 2004/2005 years he’s been writing and teacher, having spoken at a
in Computational Physics was honoured with the MVP teaching his SQL Server number of conferences and
HERE. from UCLan. award from Microsoft. 2005-2012 courses worldwide. software groups.
SPEAKERS
Matt is an Mark is the founder Roy is the Brian is a partner Ian is Neo
independent of CommonsWare chief scientist at with MCW Technology’s
consultant and and a three-time Bouvet.no, and Technologies, Director of
trainer who, from the early entrepreneur. His experience one of the original ALT.NET an Endjin Associate and Customer Success, working
days of the Internet, was ranges from consulting on organisers. He consults and a Microsoft ALM MVP. with customers to design
building websites and open-source and collaborative trains teams worldwide on He spends his time teaching and develop graph database
databases. Currently, Matt development for the Fortune the gentle art of unit testing, Microsoft technologies to solutions. He is a co-author
builds applications and teaches 500 to application development test-driven development and developers, working with new of Graph Databases
other developers about the on just about anything smaller how to lead software teams, and emerging technologies, (O’Reilly) and REST in
latest Microsoft technologies. than a mainframe. including many videos. and consulting worldwide. Practice (O’Reilly).
UNIVERSAL PASS:
All 5 days £1495 +VAT £1595 +VAT £1695 +VAT £1795 +VAT
3-DAY PASS:
Main conference only
£795 +VAT
£895 +VAT £795 +VAT
£995 +VAT £895 +VAT
£1095 +VAT £995 +VAT
£1195 +VAT
+VAT +VAT
1-DAY WORKSHOP-ONLY PASS £445
£345 +VAT £445
£395 +VAT £495 +VAT
£445 +VAT £545 +VAT
£495 +VAT
London calling:
take in the view
from Central
Hall’s Skyline
Terrace
Please note that submission of a completed registration form constitutes a firm booking, subject to the following terms and conditions. Any cancellations received after 17th January 2014 will incur an
administration fee of 30%. Cancellations must be made in writing at least 60 days before the start of 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.