Thursday, 30 July 2009

.NET Framework source code

I knew that Microsoft were making it possible to Step Into .NET source code when you are debugging (if you configured Visual Studio to use the correct symbol and source server), but I didn't know that you can download the entire source by itself as well.

They currently have various bits of .NET 3.5, ASP.NET MVC and WCF. Hopefully more will follow.

More details are on the Reference Source Code Center Team Blog, and there's a forum too.

Monday, 27 July 2009

P2P online backup

Very rarely you see an online ad that is interesting.. Today I noticed one for CrashPlan.

They offer both a free and paid online backup solution. The interesting thing about the free version is that you back up your data on your friends' or family's computers (rather than a central remote server). Quite a novel approach. About the only downside is that the free version apparently is ad-supported. Not sure how annoying they would be.

I think all the computers would need to be online at the same time for backups to work properly. Presumably the same would apply if you needed to do a restore too. Something to take into consideration.

There is also a paid offering too (for orphans or people without any friends?)

Thursday, 23 July 2009

Updating assembly versions in Visual Studio project files

Sometimes you need to update all the references to a particular assembly so that they use a newer version than the original one that was added to the project.

One option is to manually edit the references for each project, removing and re-adding the assembly.

Option two, which is a bit nicer, is to use something like this PowerShell script:

Get-ChildItem -recurse -filter "*.*proj" | Foreach-Object { (Get-Content $_.FullName) | Foreach-Object { $_ -replace "1.0.3.0", "1.1.0.0" } | Set-Content $_.FullName }

In this example, we are replacing instances of "1.0.3.0" with "1.1.0.0" – handy if you just happened to be upgrading to the latest version of Castle.

Note the use of the parentheses () around the Get-Content - without those you'll end up with an Access Denied error as it will be trying to write to the same file it is reading from.

Sunday, 19 July 2009

CodeCampSA 2009 – Day 2

Presentation notes

Nigel Spencer – WPF in 2010

  • Easing functions – affect animation velocity
  • Behaviours
  • Demo of customising Visual Studio home page – XAML-based
  • Model View ViewModel – templates

Greg Low – Spatial SQL

  • sys.spatial_reference_systems

Dave Glover – Windows 7 APIs

  • Windows 7 Training Kit

Omar Besiso

  • Sync Framework (seemed strangely familiar!)

Jason Stangroome – PowerShell and build automation

Jason Schluter – Silverlighter

  • XHTML to Silverlight converter

James Chapman-Smith – Model View ViewModel and Unit Testing

  • ViewModel handles
    • UI logic
    • input validation
  • Thought while observing Jame's code – could you have INotifyPropertyChanged take a lamba expression instead of a string? – Apparently yes!

Peter Cornish – AdWords

CodeCampSA 2009 – Day 1

Presentation notes

David Gardiner – Generating Unit Tests with Pex

  • Fantastic
  • Inspirational
  • I wish I could present like this guy
  • :-)

Anthony Borten – TFS 2010

  • Always try to install TFS, SharePoint and Build on separate servers if possible
  • Make sure you launch config tool immediately from the installer
  • Note the 'test' buttons to check your server names
  • Team Foundation Administration Console
  • Branching – better in 2010
  • Team Build
    • Build controller
    • Build agent
    • Gated checkins

Allan Baird – UniSA

  • Industry partnerships – opportunities to have students work for 6 or 12 month placements.

Rob Farley – The problem with BEGIN and END in T-SQL functions

  • Useful tool - "fences" – hides desktop icons
  • Generally modularisation in T-SQL is good
  • Funny joke about COUNT(dracula)
  • Compare two queries – one using a user-defined function, the other just has SQL
    • function query appears to run faster according to query plans
    • BUT, using SQL Profiler, it is actually much less efficient
    • SQL sees BEGIN/END and can't inline the function

Liam McLennan – MVC is better than WebForms

  • WebForms is to imperial as MVC is to metric

Tatham Oddie – WebForms are better than MVC

  • Used WebForms for graysonline
  • Used application/xml mimetype to validate XHTML content with Firefox during testing
  • XHTML 1.1 templates for Visual Studio
  • Tool to convert bad HTML to valid XHTML
  • .NET 4.0 – Can disable page-level ViewState, but enable it on specific controls

Scott Barnes – Silverlight

  • Was a Flash developer before joining Microsoft
  • 400 million downloads of Silverlight
  • Biggest competitor - HTML+JS!

Anthony Borton – VSTS 2010

  • Eliminating no-repro bugs
  • Virtual Lab Management
  • Test Case Management
    • Record against real application
    • Fast forward through test steps
  • Microsoft Test and Lab Manager
  • Replay – re-run test including launching application under test
  • Coded UI Test
    • Test builder – records UI actions

Paul Turner – SharePoint branding tips and tricks

  • Start with minimal master page
  • Enable debugging
  • Position tool pane
  • Standard delegates (My Site etc)
  • Site actions
  • Digest (MAC)
  • Understand CSS
    • Add custom CSS with CssRegistration
  • Don't put JS in master page
  • Async JS with defer

Wednesday, 15 July 2009

Bringing Developers and Designers closer together (eventually, sort of)

When Microsoft released their Expression suite of products, the marketing claim was that they could be used to edit the very same source files that the developers were working on.

BUT, while Visual Studio 2005 included TFS, the obvious integration with any of the Expression products was missing. So the marketing claim was a bit hollow. Yes, you technically "could" work on the same files, but it was going to be a clunky experience.

So it is ironic that yet again, a version 3 product finally appears to get it right. Note this announcement refers to Expression Blend, and it isn't clear whether Expression Web has similar capabilities.

Tuesday, 14 July 2009

The art of Unit Testing with Examples in .NET

I recently bought a copy of The Art of Unit Testing: with Examples in .NET by Roy Osherove, taking advantage of a discount being offered by Manning.

Already owning xUnit Test Patterns: Refactoring Test Code (Addison-Wesley Signature Series) by Gerard Meszaros and Working Effectively with Legacy Code (Robert C. Martin Series) by Michael Feathers, I was interested to see what new insights Osherove would bring, especially as he would be focussing purely on the .NET platform (code samples are in C#).

The book is divided into 4 sections.

Part 1 (which I skimmed through) was an introduction to unit testing. Osherove uses NUnit for his examples which is reasonable considering it is probably the most popular unit testing framework for .NET at the moment.

His preferred naming convention for test methods is interesting – "[MethodUnderTest]_[Scenario]_[ExpectedBehaviour]". It contrasts with the "natural sentence" style I currently favour (which I'd trace back to Jean-Paul Boodhoo's unit testing episodes on dnrTV).

He also recommends naming test classes with a "Tests" suffix. I've always used the singular "Test", but I take his point that each test class does contain multiple tests so plural may be more accurate.

Part 2 introduces stubs, mock objects and isolation frameworks (aka mock object frameworks). Following a poll held on Osherove's blog, Rhino Mocks was chosen to demonstrate how a framework can simplify creating mock objects. I could be wrong, but you almost get a sense that this was done somewhat grudgingly considering Osherove himself works for TypeMock (who sell a commercial mocking framework). Curiously whilst including a link to the Rhino Mocks download site, he doesn't even mention Ayende's name at all.

Osherove makes the following recommendations about stubs and mocks:

  • Use nonstrict mocks when you can
  • Use stubs instead of mocks when you can
  • Avoid using stubs as mocks

I found this interesting, as we've been writing a lot of unit tests lately, and one of the things we're coming to realise is that brittle tests can be annoying. Tests that still test your code, but are more flexible about exactly how the code under test works (rather than setting strict expectations for each and every method call) are going to be more useful and less effort to maintain.

Part 3 looks at various strategies for organising tests and a number of patterns and anti-patterns to follow when creating tests.

Part 4 covers how to make unit testing the norm in an organisation, and how to work with legacy code.

Having some experience writing unit tests, I did find this book a bit light on. Osherove references Meszaros and Feather's books regularly. I would also consider both of these works cover the topic in a more detailed and thorough manner. However they are probably not necessarily as good a starting point for someone new to unit testing, especially someone who's main experience lies in developing for the .NET platform.

I finished the book surprisingly quickly – pleased that I'd learned a few new things, but left feeling that it would have been nice to learn a few more.

Wednesday, 1 July 2009

Firefox 3.5

Today is "Upgrade to Firefox 3.5" day :-)

My upgrade went very smoothly, and one nice feature was it warned me beforehand which extensions wouldn't work with the new version.

Post-upgrade, it found a compatible version of Firebug, but I'm still waiting for updates of

  • Bookmark Duplicate Detector
  • Google Notebook
  • Live Writerfox
  • Microsoft .NET Framework Assistant 1.0

The following extensions work ok:

  • DownThemAll
  • English (Australian) Dictionary
  • IE Tab
  • Xmarks

They reckon 3.5 is about twice as fast as 3.0. It certainly does seem snappier.

As a side note, I just noticed that Google Notebook is no longer being developed. Might be time to finally make the transition to Evernote.