Saturday 20 June 2009

One Month On... Why Silverlight Development Can Be Painful

What happened to the daily link dumps?


It's over a month since I posted my last set of daily link dumps. Not through choice! Google decided that a blog with lots of links indicates spam, and it took more than 3 weeks to get this blog unblocked. Needless to say I'm now looking at moving my blog to somewhere that gives me more control (and responsibility :-( ) as part of migrating my embarrasingly poor company web site (shoemaker's shoes and all that!) over to Silverlight. I need a framework where I will not be at the mercy of some unresponsive remote conglomerate that gives no direct route for problem escalation or even point of contact and can arbitrarily shut me down for no meaningful reason! More on this site migration when the current workload subsides in a couple of weeks!


Why no recent blog entries?


The last few weeks have involved some pretty crazy hours working to get a Silverlight 2 application delivered to constantly changing requirements (or 'minor tweaks' as the customer likes to call them!), and whilst I've mostly been enjoying it (it's hard to 'enjoy' layout tweaking at the pixel-perfect level!), I've been somewhat frustrated at the amount of time the project has taken - all detracting from personal time that I'd rather spend getting involved in research and online conversations around Silverlight 3, MVVM, Blend 3/SketchFlow, PRISM 2 and .NET RIA Services. These are all technologies which are going to become VERY important to the long term future of Silverlight, which I see as playing a large part in my company's future.


Silverlight 3 'Launch Date' is July 10th


July 10th is the date being officially touted as the 'launch date' for Silverlight 3 and it was almost amusing to see the explosion of information across Twitter and various blogs in the days following discovery of the original press release (I think Ziff-Davies were the first to go public with it). The launch date almost inevitably ended up being 'spun' as the official release-to-web date of Silverlight 3 (and even the associated Blend 3 tooling!) by some of those who didn't actually bother reading the press release in their rush to spread the news!


So let's be very clear here: launch date does NOT mean release date, as anybody who attended the SQL Server 2005 launch event only to find it would be several months before RTM of that product will remember! All that is certain is that July 10th is the date where a much more interesting date is likely to be announced!


Silverlight 2 Books and Web Searching


One thing that has impressed me on my Silverlight 2 learning experience has been the quality of most of the books out there on the subject. Admittedly most (all?!) suffer from having been released based on Release Candidate rather than the final release of Silverlight 2, but fortunately changes were relatively minor, and most of the books out there at least do a great job of covering the fundamentals and minimising the errors in the code listings and examples they use. Some of them have even used colour, and used it effectively (alas, not for any of the Blend books, which is where colour is really needed). All of this is a real move forwards from the bad old days of production line 'just commission and rush it to market based on flavour of the month rather than quality' that Wrox in particular seemed to get into before it went bust the first time (presumably because the target market woke up to the fact we were just being ripped off and stopped buying).


I'm often asked which of the many Silverlight 2 books I've purchased (I buy too many books!) is 'the best' one to purchase for the beginner. I hate to be drawn on this because the answer is nearly always 'it depends' (on what your background is, and what you want from the book). You really can't go wrong with any of the main ones from Apress, Manning or SAMS for the basics and John Papa's book on Data Services Access from O'Reilly is essential too, and not just because it's the only book covering its subject matter. However I do feel I should give special mention to the Silverlight 2 Recipes book from Apress here, since it rarely (never?) gets mentioned in despatches, presumably because the title/formula of the book is off-putting to those just wanting to learn a new technology fast. What I like about Recipes is it has most of the stuff that the main books have, but with a lot more depth tucked away in its pages and copious code examples. I hope there will be a Silverlight 3 version, but suspect the title is compromising its sales success.


Searching on the web for information is far more problematic. One of my great frustrations has been the number of high-ranking articles, even in the official QuickStarts or MSDN articles, that turn out to contain significant misinformation because they were written based on a beta version not the final release. Simply having Visual Studio upgrade the obsolete downloadable source code doesn't work, especially if we're talking custom controls which the books tend to be exteremly 'light' on. I'm guessing these problems are because generic.xaml had its location forcibly changed to comply with WPF's Themes folder at the last minute, but haven't had the history with Silverlight 2 or the time to research it to know if this is the reason. Too often basic tutorials (want a 'glass button' anyone?) turn out to have step-by-step instructions that don't work, bear little relation to the associated code download (which does work despite containing such gems such as placing controls using Grid.Row=3 when the grid is zero-based and only has 3 rows defined!). The quality of this stuff is extremely low, despite the high search rankings and hits on Google and the like.


The biggest problem/cause of time-wasting with Silverlight 2 education is that on the web nobody goes back to update the articles they wrote when they were playing with beta 2. Probably the worst offenders are those authors who happily take your book money hiding the fact they weren't written to the released version on some obscure page inside the book, promising 'updates available on my site' never to be heard from again! Do I sound bitter yet? (I really should have learnt my lesson from the WCF initial release days, so have nobody to blame but myself!)


The real problem with Silverlight development, if there is one (I'm willing to conveniently forget the buggy controls and complete lack of printing support, if you are ;-)) is that the release schedule is so fast that any 'expert' who's doing stuff beyond the most basic examples is rushing onto the next beta as soon as the previous one goes RTM. If my experience is typical most of the Silverlight 2 articles/code samples are not just poorly written and explained, but will lead you down blind alleys, quite aside from any problems inherent in not working as promised when applied to your own scenarios. In this instance, Google is NOT your friend (but Community is :-))


Ironically, there's a wealth of really good Silverlight 3 stuff published, but, again, it's BETA stuff. Alas, for those of us developing real applications to real delivery dates using a beta technology for which there is still no 'go live' license or even likely release date this does NOT reflect any kind of real world that we work in. Frankly I'm amazed that Microsoft seem to think, and not just think - positively encourage - the illusion that it does! If Microsoft want people to take Silverlight 2 seriously - and Silverlight 2 is still the officially released and available version at the time of writing - please guys at least go back and update your own 'official' quickstarts so they work (and don't contain comments about 'updating this beta 2 code when the release candidate becomes available in a few weeks'!?!) Yeah, I know you're all so busy trying to get your head around the crazy number of technologies Micrsoft keeps throwing out, but so are hundreds of thousands of developers! And a few hours of the one person controlling this stuff NOW will save HUNDREDS OF THOUSANDS of hours wasted by those trying to get to grips with the stuff based on what's being sold as the 'official' documentation today!


Introducing Microsoft Silverlight 3 (Book Review)


Which nicely brings me on to Laurence Moroney's Introducing Microsoft Silverlight 3 book, published by Microsoft Press, and already in stores despite no date for even a 'Go live' license for this technology having been announced. In its favour it does highlight the fact that it is 'Based on' a beta on the cover. This appears along with a promise that updates will be available online. Given my previous experience of such empty promises and - forgive my cynicism - the fact the author's last blog update was back in March, I'm not entirely convinced the promise is anything more than the usual empty guff designed to encourage you to part with an outrageously high asking price of 40 dollars. Like I said, I'm bitter after my WCF experiences in this area (where one author even stopped comments on his blog to avoid addressing the issue of having sold a book and downloadable code samples that never worked!)


I would argue that Introducing Silverlight 3 is not so much a book, as an extended marketing brochure for the technology, written by someone obviously so busy in his day job he just didn't have the time required to put together AND PROOF-READ/TEST an introductory book like this. It's effectively an extended marketing brochure that you're expected to pay 40 dollars for! I could, and perhaps should, forgive it such sins. After all the title and the Microsoft Press record on these things pretty much gives the game away. But when the book contains so many inconsistencies, errors and lack of anything approaching appropriate instruction for a beginner I feel it's justified as the target for a full-on rant masquerading as a blog entry! ;-)


First, I should probably justify my 'it's a marketing brochure masquerading as a book' comment. Well, here's the book explaining the new 'Code Behind' feature of Blend 3


You can also edit the code-behind with Expression Blend 3, a new feature that wasn't available in previous versions. For example, originally the text block in Figure 1-6 had no name set. You can change this to txtHello and then open the Page.xaml.cs file.


Fair enough, you might think. But where does the author explain HOW to do this? He doesn't! He moves onto some other subject in the next paragraph. The book is too much 'you can' not 'you do'. Given the fat volume's 356 page count I'd expected rather more, but with each sentence being presented as a new paragraph (I reformatted the above italicised snippet from two different paragraphs) it's not hard to see how the seemingly high page count and volume thickness has been achieved.


I could perhaps forgive the lack of real 'meat' if what little meat that was presented wasn't so obviously out-of-date - even at this early stage where we're still in beta and not all changes to the core product have been made! But any newbie is going to get totally confused by the so-called explanations that permeate this book. The author is in a permanent state of confusion about whether the default page created in the simplest application is called Page, MainPage or MainControl!


Did ANYBODY bother proof-reading this book? (that's a rhetorical question, as it's obvious within minutes of starting to read it that the answer is most definitely 'No'!)


Even the most rudimentary code block appears to have been published unchecked. You want an example don't you?! One of the first code snippets shows what gets generated for you automatically in your application. It has four lines showing the auto-generated class MainPage that works for you in a default application. Which is pretty neat given that it shows the class's constructor is called Page!


Suffice to say, if you're excited about the upcoming release of Silverlight 3 (and you should be!) then the best thing to do is wait for books based on the reality of the product to be released after the release date, not this sham of a cynical exercise in making money (or over-hyping 'free book' chapter extract giveaways at costly conferences!) by exploting the current buzz around the new technology.