Tech.Ed Day 5 Roundup

Posted 07 December 2008, 21:19 | by | | Perma-link

TLA311: The Future of C#

The story for C# so far has been: Managed code (1.x), Generics (2.0) LINQ (3.0), however the trends in languages at the moment is towards:

  • Declarative: Less how you want to do something, but more what you want to do - this is supported by LINQ and PLINQ.
  • Dynamic: Not just dynamic languages, but objects whose type we don't know about at compile time.
  • Concurrency: No one's got this completely right for the last 30 years or so, mainly because it means many things to many people. As computers gain more cores, we need to work out how to make our sequential processes run in parallel.
  • Within Microsoft, there's a trend for VB.Net and C# to steal ideas: Going forward they are going to stop adding features separately to each language - many of the new things in C# 4.0 are already in VB, and the same goes for VB10.

So, what is coming in C# 4.0?

  • Dynamic Programming: The Dynamic Language Runtime, sits in the middle, offering Expression Trees, Dynamic Dispatch and Call Site caching, the languages sit on top of the DLR (IronPython, IronRuby, C#, VB.Net, etc), and under the DLR are binders to objects, etc.
    To access a dynamic object, you use the dynamic type, so member selection is deferred to runtime, when the actual types are substituted. Obviously, there's no IntelliSense for dynamic types.
    You will also be able to implement IDynamicObject, which will allow you to dynamically create properties on the object, which are stored in an internal dictionary - this gives you a kind of Duck Typing ("It looks like a duck, it acts like a duck, it sounds like a duck, let's just call it a duck").
    The ultimate proof of this was when Vishal Joshi copied some JavaScript from an aspx file into a cs file, and it all pretty much just worked.
  • Optional and Named Parameters: You can declare default values for parameters, and these will be used if no value is passed in. Positional arguments are processed first and then named arguments are processed. This is obviously of most benefit when it comes to COM interop. The ref modifier on interop calls is now optional, and the Primary Interop Assemblies are no longer needed - only the calls you actually use will be generated.
  • Co- and Contra-variance: See Eric Lippart's Fabulous Adventures In Coding series on the Future of C# for more on this, but my main notes were that the Out modifier will promise that you won't add to or modify the contents of the objects passed to you, and an In modifier states you only take input (e.g. Compare).

And what about after C# 4.0? There was a demonstration of the compiler being exposed as part of the API, allowing complete Meta-programming, dynamic languages that change at runtime, etc.

WUX402: ASP.Net AJAX Tips and Tricks

Something I probably should know about - the preventDefault method will disable the default url action on a link - quite handy.

AddHistoryPoint

This allows you to store Key-Value pairs, along with a title in a state bag, that then enables Back and Forward  navigation, along with Bookmarking support. Within the Script Manger you need to Enable History, set On Navigate, and set EnableSecureHistory to false. This can be done and accessed either server side or, when using sys.Application.AddHistoryPoint on the client side.

jQuery

This now ships with ASP.Net MVC and will be included in VS2010, Jeff King has lots of content on jQuery integration - some quite neat selectors are available:

$("#id") // basic select element by id.
$(":text") // select all elements of type=text.
$(".class_name") // basic select by css class name.
$("#grd tr:even") // find element id "#grd" then select every even row within it.

Script Combining

Although modern browsers are getting better, the HTTP spec recommends only two active connections from a client to the server - so consider combining your scripts together to reduce roundtrips - or you can look into using the ToolKitScriptManager to assist with that.

AJAX with ASP.Net MVC

Handy additions - Ajax.BeginForm - wrap this in a using statement, and you automatically get the closing form tag as well.

There is a client only AJAX toolkit, and helper methods to go with it.

PDC01-IS: Cloud Services: The Story Behind the PDC Keynote Demos

Interesting interactive session on the work being done for the RNLI that has already saved lives, and BlueHoo, who rather frivalously use Azure platform to make little grey and blue blobs (or Hoos) dance. Oh, and enable you to network via BlueTooth and a data service.

WUX02-IS: Top 10 Web Mistakes and How to Avoid Them

A packed session (in fact, a repeat of a previously packed session).

10: Lousy and Out of Date Content

For best results, remove out of date content - at the very least, ensure you have a date on the content, so users can see when it was posted, and ignore it if they wish.

9: Errors in Code

Make sure your mark-up is valid.

8: No Easy Navigation

Sitemaps, breadcrumb trails, search all help.

7: Inconsistent Site Design

On larger sites, ensure that the site layout and design is consistent - especially the overall navigation.

6: Bad User Workflow

An example here was twitter: On the first page, the focus is in the text area at the top - this is good, because you probably went there to post a tweet, however, once you're browsing later pages, this is less important - you're more likely scrolling around, reading tweets, etc - lose the focus on those pages.

5: Only Providing Rich Media

4: Obtrusive Ads

Try and come up with a way to make them less obtrusive, more relevant, targeted, etc.

3: Not Optimising for Search

URLs, HTML markup (see 9 above), etc.

2: Non-Designers Designing

Again, 7, inconsistent designs, poor colour choices, etc - there are plenty of free or affordable templates and colour schemes out there, use them.

1: Not Planning for the Future

Locking people out because they have a later build than your browser sniffer, failing to work on browsers like Chrome or IE8, etc.

Filed under: Conferences, Tech.Ed

Tech.Ed Day 4 Roundup

Posted 07 December 2008, 21:13 | by | | Perma-link

TLA322: Writing a 3D Game in 60 Minutes

A walkthrough using the Spacewar Starter Kit, and turning it into a Space Invaders clone - not very 3D, as it was all top down, but I did learn where I went wrong adding my background in my own game - blending is important.

MS Exam 070-562: Microsoft .Net Framework 3.5 ASP.Net Application Development

I passed this one too! Great news! I'm now a Microsoft Certified Technical Specialist: .Net Framework 3.5, ASP.Net Applications - what a mouthful. Apparently I'm very good at configuring and deploying web applications Wink, but a bit weak when it comes to targeting mobile devices - no real surprises there.

WIN305: Parallel Programming Techniques in F#

See my earlier comments, only this time, my brain really did melt. The good news is that Parallel classes are coming in System.Threading v4.0.

PDC307: Microsoft Visual Studio 10: Web Development Futures

First a quick re-cap of what we have in VS2008 SP1, and the out of band releases - -vsdoc.js based JavaScript ItelliSense support added through a hotfix, ASP.Net MVC already in beta, ASP.Net AJAX toolkits and jQuery support.

Then on to VS2010

The biggest change to "Design" is in CSS: It is now standards compliant, it has better support of selectors, and the renderer passes the Acid 1 test.

On the "Source" side, as mentioned previously, there's a large number of HTML snippets that have been added, and "Selection Expansion" was demonstrated (double clicking will expand your selection).

JavaScript IntelliSense is even more improved, a lot faster parsing of JS files to generate IntelliSense. Return types can be parsed from comments, and also it no longer falls over when you have bad scripts.

A whole new deployment story was announced, alongside the Web Config transforms mentioned before. By default transforms are created for each build configuration, Debug compilation is on by default, but off for release builds, and MSBuild will power your deployments.

In the Project properties, there's a new Publish tab, that will allow you to define how you publish the project - you can set up multiple profiles, with different servers, logins, deployment methods. The publish tools will finally allow you to "Skip extra files on the server" so it doesn't delete things it doesn't know about, you can automatically mark the project as an Application on the server, and there's a Publishing toolbar for "one click deployments" - an early offering of this can be found at DiscountASP's MS Deploy Lab.

Filed under: Conferences, Tech.Ed

Tech.Ed Day 3 Roundup

Posted 07 December 2008, 20:55 | by | | Perma-link

PDC201: A Lap Around Cloud Services

Windows Adger Azure - a British Microsoftie who can actually pronounce Azure.

So, it's an OS for the cloud, it provides:

  • Hardware abstraction across many servers.
  • Storage: Distributed, scalable and durable.
  • Monitoring and Maintenance: CPU, disk, memory, bandwidth, etc - basically anything that they might bill you for - and alerting via Live Alerts (SMS, Email, etc).
  • Currently it's all .Net, but they are looking into other options such as PHP, unmanaged code, etc.

When writing for the platform, beware that you're not running in complete Medium Trust - for example while you can open sockets, you can't connect to SQL Server

The two main roles on the platform:

  1. Web Role - sites and services.
  2. Worker Role - actually does work on things. Inbound requests come over HTTP(s).

The web role writes messages to the queue; the worker role watches the queue for jobs to work on.

Three main types of storage accessed via a REST based interface:

  1. Queues - but these are not MSMQ. They are deleted after about 2 weeks - so no using them for cheap storage. When a message is read, it is hidden from the queue while the worker role processes it, but will be restored later if you don't clean it up - this allows for some level of guarantee that the message will be processed, but you need to be aware that a message might have already been started.
  2. Tables - persistent storage for entities, but there's no relational features: joins, etc are not supported. Using a Partition Key allows MS to scale out your data easily, and using a partition key in your queries will limit the search scope nicely. You can also run parallel queries using the partition key.
  3. Blobs - A file system in the cloud.

The SDK provides all you need to develop services - a local environment that will host a cloud service on Vista or Windows Server 2008, complete with mock storage (basically contained in a SQL Express instance), and a managed API, including Logging, Storage, Config.

Currently the logging is all stored in the cloud, and is the only way to get any reporting about the internal state of your application out of it when it's deployed. Currently you have to download these logs to read them. When you are developing locally, logging is per instance - in the cloud it is per application.

The config has a number of settings that define the application - some of which can be changed while the application is running (e.g. Number of Servers).

Local storage is isolated so it's not shared between servers, it's not session based, and can be blown away at any time, so don't expect it to be there when you come back twenty minutes later.

Currently there's one data centre in the US, but they are looking at adding more in different countries - especially for compliance, but also for failover. When you deploy to multiple servers the deployment is fault aware, and so will ensure at least some of your servers are in separate racks, etc.

Last note on debugging these locally - sometimes the storage system can start up and report that it's ready before it really is ready - usually just restarting the debug session will resolve this - this is mostly a problem when you a worker role that starts up and attempts to read from a queue that hasn't spooled up properly yet.

MSDN Ramp Up - myrampup.com or www.msdn.com/rampup - this is a great free resource on Microsoft Learning, providing you with a whole bunch of revision material around a few of the MS exams - I spent an hour going over a few of the items on here in preparation for:

MS Exam 070-536: Microsoft .Net Framework - Application Development Foundation

I passed! Woo-hoo! The only thing I guess I didn't really like was the whole "now spend some time telling us what you thought about each question in the exam" - I didn't know whether I'd passed or failed at this point, let alone which questions I'd messed up, so didn't feel I could comment properly… Also, in the Prometric survey, I wasn't sure what I should put for the "How far did you travel to get to the test centre today?" question - "Less than five miles", because I'd wandered up to the top floor from the exhibition hall, or "More than 60 miles", because I was in Spain, not London?

Overall highlights: I can build services, and apparently know about threading and application domains, but need to work on serialization - oh and if they'd actually asked me any questions on mailing, I'd probably have done better in the "Interoperability, Reflection and Mailing" section than I did.

SOA304: Building RESTful Services using Windows Communication Foundation

REpresentational State Transfer provides us with a uniform interface to interact with services:

  • POST: Creates data
  • GET: Retrieve data
  • PUT: Updates data
  • DELETE: Deletes data
  • GET operations can be cached - there should be no side effects to a get.

PUT and DELETE are idempotent actions - it doesn't matter how many times you call them, the same thing will happen each time.

With WCF you can map methods to URIs and verbs, using the new attribute WebGet() - e.g. WebGet(UriTemplate = "/{id}") decorating the method GetOne(string id)

PUT, DELETE and POST need to use the WebInvoke(UriTemplate = "…", Method = "POST")

The REST toolkit for WCF is now available.

WUX405: Common ASP.Net Production Issues and How to Avoid Them

Go visit Tess's website for all the goodies.

The main topics covered where:

Performance issues:

  • Low CPU - you're waiting on an external resource or you have a lock.
  • High CPU - Busy server, infinite loops, etc.

Crashes:

  • Recycling server - By default this happens are 20 minutes of idle time or 1700 minutes (29 hours), when the web.confg changes, a directory is renamed, or about 15 aspx files have been changed - check your Antivirus activity
  • Exceptions - in timers or finalisers will bring down the process
  • Stack Overflow - This is the end of the line, you can't do anything further here.
  • Fatal Execution Engine Exception - the address details in the log are useful - basically your code has managed to get somewhere it shouldn't be able to go - either a bug in the CLR or a managed heap corruption - native code writing out of the buffer.
  • Out Of Memory - Again, the application can't recover as there's no more space to recover into - on a 32bit server you'll start hitting OOM when you have about 800MB in Private Bytes or 1.4GB in Virtual Bytes.

You can (and probably should) also log the Application Lifetime Events to get more information on app restarts.

Once again: Do not prematurely optimize - test, monitor, trace, etc to find out where your issues are.

Session State - be aware that this is retrieved on every page request even if you don't use it - so if you're storing a large object in the session, and you're using SQL Session State, you're now serialising and de-serialising this large object on every page request, even if you're not using it on that page.

On this topic, take care with what you are serialising - a 1MB dataset takes about 15-20MB during serialisation! So look at using a dataset surrogate - derive from dataset, override the Serialize methods, and store what you need.

Filed under: Conferences, Tech.Ed

Tech.Ed Day 2 Roundup

Posted 06 December 2008, 11:23 | by | | Perma-link

DAT203: Learning the Entity Framework

In light of the whole "LINQ to SQL is dead, long live LINQ to SQL" issues floating around at the moment, I'd taken a look at EF a few weeks ago, and found that it did address some of the limitations I'd started to come up against in LINQ to SQL - such as multiple references to the same table (E.g. an author field and an editor field, both referencing the Users table - in LINQ to SQL these came out with rather ambiguous, unhelpful names, but in EF I can edit the relationships and call them "Editor" and "Author" - handy).

One thing that had been confusing me was the concept of the Set - I'd not really worked out what the Set objects were for and what they should be named - clearly the default of EntityTypeSet wasn't ideal - however pluralising the set tended to make sense - the set "SalesPeople" contains entities of type "SalesPerson"; "Customers" contains "Customer"; etc.

The inheritance model in EF is also quite nice:

  1. One Table for multiple classes: use a discriminator column - e.g. ExpiryDate column with a value in the past creates an Expired Item.
  2. Table per Type: The table has all the fields required for a lookup.
  3. Table per Class: This would probably end up with duplicated data - e.g. Address data.

The architecture of EF is layered, and you can access it from any layer that you like, from the entities right down to direct database access.

In version 2 stored procedures will be properly supported.

Other nice features in Version 2:

Model First: You can model your objects in the design surface, and generate the database from the model.

Lazy Loading: It's been added, and you can toggle it on and off as required.

Unit Testing: There's been a lot of work with the community to ensure that this is all testable.

MBL201: Windows Mobile Smackdown!

How many mobiles can one person have synced with OneNote? Clearly quite a few. Anyway, this was mostly a selection of cool demos of things you can do with an HTC Diamond Touch Pro (because it has an accelerometer) and other phones (that don't), and so my notes were mostly a list of URLs:

  • MyMobiler - Remote Control your mobile from the desktop
  • TinyTwitter - If I could keep my Facebook status up to date, I guess this would be useful to me
  • DashWire - An online dashboard for all your mobile use
  • GRemote - this is one of the HTC Diamond ones - control the mouse on your desktop using the accelerometer in your phone.
  • SlingBox Mobile - if you've got a slingbox, you can access the content on it over the web on your phone…
  • Imagination - These people are doing some very interesting things with "Augmented Reality" and the like - see their Invisible Train for example.
  • Fake Call - get out of meetings nice and easily - schedule a call in the middle of it, and away you go.

TLA326: Web 2.0 Goes Game Development - XNA Game Studio

This was a walkthrough of the new Platformer Starter Kit that comes with XNA Game Studio 3.0 - my main take home was the message that you should create your objects/types as "Drawable Game Components" and then the engine will call LoadContent, Update, Draw, etc on them for you - keeps your main Game class fairly lightweight.

DVP02-IS: An Agile Talk on Agility

This was an interactive session run in an Agile style - so we started by coming up with a list of questions (the Back Log), ranked them by priority, and started discussing them for 15 minutes, checked for completeness, new questions, re-prioritised, rinse and repeat.

Stack rank: float most important issues to top - the order is the priority - there are not multiple items at the same level.

Q) How long is this going to take/cost and how many people will we need?
A) Assumes we know all requirements up front.
T-shirt sizing estimates: XL is broken, need more of a conversation, but gives an idea of size. Large = 2/3 weeks, Medium = ~week, Small = few days, XS = few hours.
Doing this gives you a better idea of how much you have to spend. If you have an idea of cost you can change priority - something uber important that's going to take 4 months and mean you're not going to get 6 other features, might not actually be that important.
Need trust - getting into the first iteration generally wins the project.
Fully stack ranked: not grouped, order is priority.

Q) Does this work with fixed price contracts?
A) Becomes a series of smaller fixed price contracts - that either side can cancel.

Q) Time slicing between support and new development?
A) Ideally a developer is either on or off the development team - ROTATE. However if something happens such as the CEO/Client comes in and says "you must all work on X": It should be explained that the original quote was an estimate, not an absolute commitment. The CEO/Client must be made aware of impact - you can change/scrap the current iteration if needs be, if the dialog is there between the development team and stakeholders.

Q) Does this work with fixed resource bids?
A) Pre-agile: Profit by change request (obviously dishonestly) - lock in to contracts with no deviation. Alternatively, tell them the actual cost, but give exit conditions up front: we'll deliver something every 2-4 weeks if you like it you pay for it, if you don't want to pay us any more then that's fine, you get what we've built so far.

Q) How do you deal with a late discovered design flaw?
A)
Probably caused by a new feature. Do not like to put "redesign business layer" as a backlog item - it's probably not true anyway - estimate for work should include redesign work - may become lower priority again. If not feature based, it's probably a newly discovered requirement (performance/scalability/reliability). Spikes must be time bound. If business decides to add a new thing right now, you can choose to throw away all current work in the sprint and start over: prefer small iterations as reduces waste in these situations; however that's up to you.

Q & A

Should review estimates each iteration, as customer needs that information to properly prioritise.
Planning: Iteration ratio: 2 weeks = 4 hours; ~month = ~2 days. Also be aware that you have an iteration tax: check-ins, builds, client meetings, etc are going to take the same amount of time in each iteration, and will eat into the iteration time.

Filed under: Conferences, Tech.Ed

Tech.Ed Day 1 Roundup

Posted 04 December 2008, 23:19 | by | | Perma-link

Well, these are only nearly three weeks late, but better that than not at all - and I've written most of them up now...

Having been organised, and registered on Sunday, I was able to take a leisurely commute in to Barcelona, check out my route, and then have some free time at the convention centre - which I put to good use by going to the Hands on Labs and doing the ASP.Net MVC lab - I've been playing around porting this site to the technology, so it was only once I got to exercise 4 that I really learnt anything new. My only real complaint with the lab was the "voodoo magic" of some of the set-ups - for example, why was the site in the forums exercise loading /Forum when it should have been loading the default controller first - checking the "default" default.aspx page I saw that had be changed to perform this redirect instead - it would have been nice to have that called out.

Keynote

This focused quite heavily on Visual Studio 2010 - including some elements not announced at PDC, so yay!

The standout demos for me where:

  • Architecture Analysis: At first glance this looks a lot like some of the things coming out of NDepend - graphical representation of dependencies, etc
  • Sequence Diagram Generation: Most handy - I see the value of these, but have never really drawn any - generally sticking to Class Diagrams and Use Cases.
  • Testing: Some fairly big changes coming here. The VS For Testers allows you to open up a test plan, and start going through it - while you are doing this, VS is recording a screen cast of what you are doing, as well as the state of the machine the application is running on (usually a Virtual Machine of some kind). Once the tester finds a bug, VS will create a bug issue in TFS, attach the video and machine states to issue, and allow it to be assigned to a developer. The developer can then review the video, and step through the code at the point of failure - no more "Works on my machine"!
    • Lab Management: As an addition to the testing, the management of the testing labs has been greatly improved for your long suffering System Administrator.
  • Many more snippets: I've not really used these all that much as I have ReSharper and its Live Templates, but some of these look quite handy - lots of HTML based ones for example.
  • Config Transforms: There's no getting away from it, there are settings in the application config file that are platform dependent, no matter how hard you try - with Config Transforms you define a build configuration, and part of that can include transformations to the config file - by default this includes ensuring that debug="true" is removed in release builds.
  • SharePoint Development: A new SharePoint Server Explorer has been included in VS. It can talk to remote SharePoint setups - you no longer need to run VS on a server. VS will also now properly keep track of all assets added to the solution, and generate the packages for deployment correctly.

TLA201: Introduction to F#

My first breakout session, and I go to something designed to melt my brain. F# is Microsoft's functional programming language offering running on the CLR - I've been reading up on this mostly via Matthew Podwysocki on CodeBetter.com the few take-homes I had were:

let

Like var in C#, but it's static. Use the mutable keyword to change the value - this is deliberately ugly so that you don't do it very often.

|>

Pipelining, allows you to compose operations as you go along, piping the result through each successive operation.

fun ->

Defines a new inline function.

The "Extract Method" refactoring was quite clean though - select the block of code you wish to make a method, hit [Tab] to indent it, and then add let [functionName] parameter = in front of it, and you're done.
For asynchronous programming (one of the strengths of a functional, immutable language) you wrap it inside an async{  } block, and can then call Async.Parallel and Async.Run.

WUX312: Web and User Experience/ASP.Net AJAX

A good overview of the different flavours of web development from Microsoft, from straight web forms through what Stephen Walther calls "AJAH - Asynchronous JavaScript And HTML - a.k.a. The Update Panel" all the way up to ASP.Net AJAX with jQuery and ASP.Net MVC.

Some of the nice new things are Template controls - declare them using $create, and then use placeholders like {{title}} to replace data.

It was good to see someone else talking about accessibility for a change - Stephen pointed out that both FireFox and IE8 support ARIA, and it's also a lot better in ASP.Net 4.0 - the control adaptors for example are built in, rather than being an optional extra.

Another useful titbit - the ActionResult of an MVC control can actually be a JSON object Smile

Filed under: Conferences, Tech.Ed