CSLA Light Preview Drop

Rocky Lhotka recently announced a pre-release drop for CSLA Light (the less filling version of CSLA 3.6).  Silverlight raises special problems for creating tiered applications.  CSLA Light tries to fill this problem domain by providing a framework for building bindable objects that know how to interact with Silverlight.  This is the sort of solution that will allow us to do more than simply build cool games with Silverlight, since the real promise of Silverlight is the ability to write business applications that are also RIA’s.

One of the few alternatives to CSLA Light that I’ve seen is Shawn Wildermuth’s work integrating Astoria with Silverlight.  I’m keeping an eye on both of these technologies to see how line-of-business Silverlight applications will shape up over the next year.

Learning Silverlight: Day Seven

watson-crick-dna

The seventh day of any project should always be devoted to rest and reflection.

There is a passage from James Watson’s account about discovering the structure of DNA, The Double Helix, in which Watson decides that he wants to study X-ray crystallography (the technique that eventually leads to the discovery of the double helix structure).  He is told by an authority that because the field is so new, there are only five papers on the subject worth reading — five papers to read in order to master an entire field of science!

This is also the current state of Silverlight development.  The final framework is not yet out, the books are still being written as authors hedge their bets on what will be included in the RTM of Silverlight 2.0, and there are no best practices.  Moreover, Silverlight development is so different from what has gone before that no one has a particular leg up on anyone else.  The seasoned ASP.NET developer and the kid fresh out of college are in the same position: either one can become a master of Silverlight, or simply let it slide by and work on other things instead.

So is Silverlight worth learning?  It basically fills in two pre-existing development domains.  One is Flash, and the other is ajax web sites.  It can improve on ajax web sites by simply having a simpler programming model, and by not being dependent on Javascript (as of the 2.0 beta realease) which tends to be brittle.  The update panel in ASP.NET Ajax and the Ajax Control Toolkit have made component based programming of ajax web sites easier, but if you ever read the Microsoft Ajax web forums, you’ll quickly see that it still isn’t easy enough, and people supporting sites that have been up for a year are starting to come forward with their maintenance nightmares.  The introduction of the Microsoft MVC framework raises further questions about whether the webform techniques that so many Microsoft-centric web developers have been working with will continue to be useful in the future. 

Silverlight, in some sense, competes with Flash, since it is a web based vector graphics rendering framework.  It is more convenient than Flash, for many developers, since it can be programmed in .NET languages like C# and VB, rather than requiring a proprietary language like ActionScript.  Even better, it does something that Flash does not do easily.  Silverlight talks to data, and it does so without requiring an expensive server to make this possible. 

When you are thinking about Silverlight, then, it is appropriate to think of a business application with a Flash-like front-end.  This is what it promises, and the technology’s success will rise or fall on its ability to make this happen.

So if you believe in this promise with, say, 65% to 75% conviction, then you will want to learn Silverlight.  There are currently about 5 articles worth reading about it, and they can all be found here.  Most other tutorials you will find on the Internet simply deal with bits and pieces of this information, or else try to pull those bits and pieces together to write cool applications.

But after that, what?  The best thing to do is to start writing applications of your own.  No company is likely to give you a mandate to do this, so you will need to come up with your own project and start chipping away at it.  The easiest path is to do try to copy things that have gone before, but with Silverlight, to see if it can be done.  Many people are currently trying to write games that have already been written better in Flash.  This is a great exercise, and an excellent way to get to know the storyboard element in XAML.  It doesn’t really demonstrate any particular Silverlight capabilities, however.  It’s pretty much just an "I can do it, too" sort of exercise. 

A different route can be taken by rewriting an data aware application that is currently done in Winforms or ASP.NET AJAX, and seeing what happens when you do it in Silverlight instead.  Not as cool as writing games, of course, but it has a bigger wallop in the long run.  This will involve getting to know the various controls that are available for Silverlight and figuring out how to get data-binding working.  (Personally, I’m going to start playing with various interactive fiction frameworks and see how far I can get with that.  It’s a nice project for me in that it brings together both games programming (without fancy graphics) and data-aware applications.)

Finally, after getting through the various Microsoft materials and reading the various books from APress and Wrox and others that will come out shortly, where does one go to keep up with Silverlight techniques and best practices?

Learning Silverlight: Day Six

battleships

I’ve spent today going through all of the Hands-On-Labs provided on the silverlight.net site.  The five labs are basically word documents, with some accompanying resources, covering various aspects of Silverlight 2 development.  More importantly, they are extremely well written, and serve as the missing book for learning Silverlight.  Should anyone ask you for a tech book recommendation for learning Silverlight 2 beta 1, you should definitely, emphatically, point them to these labs.  They are both comprehensive and lucid.  These labs are supposed to take an hour to an hour and a half each, so all tolled, it constitutes approximately seven hours of work.

 

1. Silverlight Fundamentals is a great overview of the features of Silverlight and how everything fits together.  Even though it covers a lot of territory you may have come across in other material, it does it in a streamlined manner.  In reading it, I was able to make a lot of connections that hadn’t occurred to me before.  It is your basic introductory chapter.

2. Silverlight Networking and Data demonstrates various ways to get a Silverlight application to communicate with resources outside of itself using the WebClient and WebRequest classes.  I couldn’t get the WebRequest project to work, but this may very well be my fault rather than the fault of the lab author.  The lab also includes samples of connecting to RSS feeds, working with WCF and, interestingly, one exercise involving ADO.NET Data Services, a feature of the ASP.NET Extensions Preview.

3. Building Reusable Controls in Silverlight provides the best walkthrough I’ve seen not only of working with Silverlight User Controls but also with working between a Silverlight project and Microsoft Blend.  This is also the only place I’ve found that gives the very helpful tidbit of information concerning adding a namespace declaration for the current namespace in your XAML page.  I’m not sure why we have to do this, since in C# and VB a class is always aware of its namespace, and the XAML page is really just a partial class after compilation, after all — but there you are.

4. Silverlight and the Web Browser surprised me.  In principle, I want to do everything in a Silverlight app using only compiled code, but the designers of Silverlight left open many openings for using HTML and JavaScript to get around any possible Silverlight limitations.  This lab made me start thinking that all the time I have spent over the past two years on ASP.NET AJAX may not have been a complete waste after all.  A word of warning, though.  The last three parts of this lab instruct the user to open projects included with the lab as if the user will have the chance to complete the lab using them.  It turns out that these projects include the completed versions of the lab exercises rather than the starting versions, so you don’t actually get a chance to work through these particular "hands-on" labs.  On the other hand, this is the first substantial mistake I’ve found in the labs.  Not bad.

5. Silverlight and Dynamic Animations begins with "This is a simple lawn mowing simulation…."  The sentence brims with dramatic potential.  Unlike the previous lab, the resources in Silverlight and Dynamic Animations include both a "before" and an "after" project, and it basically walks the user through using a "storyboard" to create an animation — and potentially a game.  It’s Silverlight chic.

In retrospect, if I had to choose only one resource from which to learn Silverlight 2, it would be these labs.  They’re clear, they’re complete, and best of all they’re free.

Popfly: Silverlight Game Designer

enterprise

Have you always wanted to create a Flash game but found it too daunting?  Microsoft’s Popfly site now lets you create Silverlight games using templates and pre-created images following a sort of wizard approach to game design.  There are some working games on the site that you can start from, including a racing game and an Asteroids type game, and then modify with new behaviors or new animations to get the game you want.

The Popfly game creator is currently in alpha, and the intent is to make it easy enough for a child to use.  To tell the truth, though, I’ve spent about 20 minutes on the site so far and still can’t quite figure out what is going on.  All the same, it’s a great idea, and may be the sort of gateway tool that leads kids to want to use Visual Studio and Blend to create more sophisticated games until they are eventually fully hooked developers — if that is the sort of life you want for your children, of course.

 

***

 

Update 5/3/08: after three hours on Popfly yesterday afternoon, my seven year old son has created his own Silverlight game, while my daughter is learning the intricacies of Microsoft Blend 2.5 in order to create her own animations (the Popfly XAML editor is mostly disabled in this alpha version).  I’m proud of their appetite for learning, but am nonplussed at the prospect for their future careers.  I’d prefer that they become doctors or lawyers — or even philosophy professors — someday, rather than software developers like their old man.  Then again, maybe in the world of tomorrow everyone will know how to work with Visual Studio 2020 and there will be no need for people like me who specialize in software programming.  Software development might become an ancillary skill, like typing, which everyone is simply expected to know.  Or maybe our computers will have learned to program themselves by that time.

It is an internal peculiarity of the software development professional that he constantly demands new tools and frameworks that will make programming simpler — the simpler the better — which in a sense is a demand to make his own skills obsolete.  His consolation is found in Fred Brooks’s essay No Silver Bullet, which promises that there are essential complexities in software development that cannot be solved through tools or processes.  The software developer is consequently an inherently conservative person who not only recognizes but also depends on the essential frailty of humanity and our inability to perfect ourselves.  But what if this isn’t true?  What if Brooks is wrong, and the tools eventually become simple enough that even a seven year old is able to build reliable business applications?  That will be a bright day for the middle-manager who has to constantly deal with developers who want to tell him what cannot be done, thus limiting his personal and career potential.  It might also be a beautiful day for humanity in general, but a dark, dark day for the professional software developer who will go the way of the powder monkey, the nomenclator, the ornatrix, the armpit plucker of ancient Rome, and of course the dodo.

Learning Silverlight: Day Five

 hunt

 

Day five picks up with unsolicited errata and general notes for the remaining Quick Start tutorials from the Silverlight.net site.

Notes to Interaction Between HTML and Managed Code (there is only one tutorial in this section, as of this writing):

Accessing the HTML DOM from Managed Code — This is a pleasant tutorial showing how to use the Silverlight Host Control as basically a wedge between code behind and the HTML DOM.  From the user control hosted in the host page, you can basically grab the DOM of the container page and manipulate it.  Because there is a lot of code, this is primarily a copy & paste style of tutorial, which means some useful information is left out.  For instance:

  • If you name your Silverlight project qsHB, the code will work better, depending on how much you copy & paste and how much you write by hand.
  • The HTML controls you add to the Test html page should go in the same div tag that contains the Silverlight Host object.
  • By default, the dimensions of the Test html page generated with your project are 100% by 100%.  Change this to 10% by 10%, otherwise your controls will be off the bottom of the browser window.

 

Notes to Programming with Dynamic Languages (this section only has one eponymous Quick Start):

Notes to Programming with Dynamic Languages: [Skipped] — some day I may want to learn managed JavaScript, IronPython, or IronRuby.  Right now, however, I can’t really see the point.

 

Notes to Additional Programming Tasks (includes one Quick Start):

Using Isolated Storage and Application Settings — This tutorial walks you through working with the System.IO.IsolatedStorage.IsolatedStorageFileStream, which allows the application to store files in a sandbox on the server.  The application is very rich, which unfortunately means the tutorial itself involves a lot of copy — paste — compile.  To understand what is going on, you basically need to read through all the code you copy & pasted after it is all done.  When a tutorial becomes this complex (and to my chagrin I have written a few like that) it is perhaps best to give up on the idea of doing a tutorial and actually do a "lab", in which the code is already all written out, and the author’s job is merely to walk the reader through what is going on.  This is a cool little application, all the same, and I foresee using it as a reference app for lots of future projects.

 

Whew.  That’s it for the Quick Starts found on http://silverlight.net.  Tomorrow I’ll start on the labs.

Learning Silverlight: Day Four

HMS_Surprise_large

Day Three concluded with finishing the QuickStart series on Building Dynamic User Interfaces with Silverlight, from the official Silverlight website.  Day Four continues with notes and unsolicited errata on Networking and Communication in Silverlight.

A. Sending and Receiving Plain XML Messages with Silverlight — I learned a new acronym in this very brief tutorial.  POX stands for plain ol’ XML.  The System.Net.WebClient class allows us to call a web service (in this case, a DIGG service) and pass the results to a callback method.

B. Building a WCF Web Service and Accessing It by Using a Proxy — Very nice.  A somewhat sophisticated small application combining Silverlight and WCF, explained clearly.  Someone went through and proofread this particular walkthrough, and the effort shows even in the details — like stating what namespaces need to be referenced before one actually needs to use them.

C. Accessing Syndication Feeds with Silverlight — Very simple tutorial on how to access an rss feed in Silverlight using the System.ServiceModel.Syndication.SyndicationFeed class.  The only problem is that if you follow the instructions precisely, it will not work.  The sample code uses the Silverlight.net rss feed, http://silverlight.net/blogs/microsoft/rss.aspx, as its source.  Unfortunately, in order to access an rss feed, the server hosting the feed must have a policy file set up to allow cross-domain access, which the Silverlight.net rss feed does not.

A tad annoying, no?  Or perhaps this is a some sort of Zen exercise intended to reinforce the principle that a Clientaccesspolicy.xml or Crossdomain.xml file must always be properly configured on the feed server. 

Learning Silverlight: Day Three

 Tomadevaldivia

Today I have been working through the Microsoft QuickStarts for Silverlight, which include walkthroughs as well as code source.  Here are the high level topics available:

  • Getting Started with Silverlight Development [Skipped]

  • Building Dynamic User Interfaces with Silverlight

  • Networking and Communication in Silverlight

  • Interaction Between HTML and Managed Code

  • Programming with Dynamic Languages

  • Additional Programming Tasks

     

    Notes to Building Dynamic User Interfaces with Silverlight:

    A. Writing Handlers for Silverlight Input Events [Skipped] — this is covered in most introductory materials.  Didn’t see a point in reviewing it.

    B. Changing the Appearance of an Existing Control in Silverlight — this is interesting, since it covers both styling an app as well as skinning it with ContentTemplates.  ContentTemplates do more than set properties for certain elements in your Silverlight app the way CSS does for HTML elements.  They also let you switch out your Silverlight element with a custom element such that, say, everywhere you have specified a button in your app, you now get whatever is created in the button’s ContentTemplate.  It works a bit like a global replace.  On the other hand, whatever events you have hooked up to your button in order to fulfill business requirements will still work, whatever you do with the ContentTemplate.

    This QuickStart is mostly a copy / paste sort of tutorial.  That said, there are some errors in it such that, if you follow the instructions to the letter, you will end up with a useless application that hangs.

    • In section one of "To create a ControlTemplate for a button," your control template needs to include a TargetType attribute set to Button.
    • In section two of "To create a ControlTemplate for a button," name your grid "RootElement" rather than "ELEMENT_Root", as the instructions tell you to do.
    • Section two of "To specify the appearance of the control" instructs you to Add the following elements after the closing </Grid.Resources> tag, at the comment "Add the elements that specify appearance here." 
    • It ought to read Add the following elements after the closing </Grid.Resources> tag, at the comment "Add child FrameworkElement objects here." 

    C. Creating Custom Controls for Silverlightan eye opening walkthrough.  We create a custom Silverlight control by first creating a standard class that inherits from Control, and a separate XML file with an xaml estension.  XML file is aware of the control class, but the control class knows nothing about the XAML file.  We reuse some of the ContentTemplate techniques from the previous QuickStart to give form to our Silverlight custom control.  Here are some minor issues with the walkthrough:

    • Be sure to add the following using declaration to your control class: using System.Windows.Controls.Primitives;
    • You need to understand Dependency Properties in order to get the most out of this walkthrough.  The article provides a dead link to the MSDN article on Dependency Properties.  It should have linked here, instead.
    • Dependency Properties are a cool concept.  For the most part, they are like property bags, except with special Silverlight hooks.  The terminology, however, is either not fully worked out, or just ill-conceived.  Here’s a sample definition of a dependency property, from MSDN:
    • Dependency property: A property that is backed by a DependencyProperty.  (Oh really?)
    • The tutorial has you start using a Background attribute in your ContentTemplate without first having you add it to your custom class.  You need to add this to your class in order to avoid a runtime exception:

    public static readonly DependencyProperty BackgroundProperty =
    DependencyProperty.Register("Background", typeof(Brush), typeof(NumericUpDown),
                    null);

    public Brush Background
    {
        get { return (Brush)GetValue(BackgroundProperty); }
        set { SetValue(BackgroundProperty, value); }
    }

    D. Displaying a Splash Screen While Loading a Silverlight-Based Application — this QuickStart seems to work.  I actually can’t completely tell what’s happening in the walkthrough, though it seems like it will make a great reference if I ever need to customize a splash screen.

  • E. Working with Data Collections in Silverlight — this useful QuickStart explains data binding and the DataTemplate.  No obvious errors, but a few lacunae.

    • Life will go much easier if you name your project Quickstart_Bookstore.
    • The ObservableCollection type belongs to the namespace System.Collections.ObjectModel.

    Learning Silverlight: Day Two

    hms_victory 

    Today I finished reading through Christian Wenz’s Essential Silverlight Up-To-Date.  According to Amazon, the book ships tomorrow — I was able to read it though my subscription to Safari Books Online.  From what I can get out of browsing the Amazon site, it is the first Silverlight 2 book to come out, and precedes the others by about two months.  It is, essentially, the only game in town for those planning to learn Silverlight 2 from a book.

    It is a bit of a mixed bag, due not least to the difficulties involved in trying to write a book about a technology that is still in flux.  Breaking changes are expected during the transition from the beta 1 to the beta 2 of  Silverlight 2, and most book authors in this sub-genre of a sub-genre have adopted the better part of valor.  So thanks are due to Mr. Wenz for accepting such a difficult task and finding a way to meet his publisher’s deadline.

    That said, while the book offers a good overview of the Silverlight 2 technology, in doesn’t go into any particular depth.  The labs are difficult to follow, at times, because some of the things he writes about do not appear in the Silverlight 2 beta 1, such as a project template for user controls.  Since his walkthroughs require the use of a user control, I was obliged to google the right way to create one, just so I could finish the book.

    Frustratingly, the chapter on Programming Silverlight with .NET is extremely brief, despite the fact that this is perhaps the most interesting new feature of Silverlight 2.  Or perhaps this is merely an artifact of the way I read it, and the physical copy that will be placed on bookstore shelves will have more content.  At least I hope this is the case.

    I was finally able to get a user control into my XAML page by following the official Silverlight 2 hands-on labs, found here.  Microsoft is not known for being good at documenting their bleeding edge technology, but these labs are actually quite excellent, and may currently be the best resource for learning Silverlight 2.  I’ll know more tomorrow, as I plan to work my way through all the tutorials and labs on the official Silverlight site.

    The trick with adding a user control to a XAML page, it turns out, is that a namespace declaration to the containing project has to be added to the page.  The page, for whatever reason, is not automatically aware of the assembly it is in.  Once the namespace is declared, however, Intellisense takes over and makes adding your user controls — HelloWorld.xaml, in this case — quite easy.

    Learning Silverlight: Day One

    cuttysark

    ‘Twas not a propitious day.  Installing the Beta 1 of Silverlight 2 was trying.  Finding the correct place to download the correct version of Silverlight 2 was a bit tricky, but I finally did get to it: http://silverlight.net/getstarted/.

    I downloaded and installed the SDK without trouble.  On reading a bit more around the net, it turned out I also needed the correct version of the Silverlight Tools for Visual Studio 2008 in order to get the project templates I would require to do anything worthwhile, so I did.  This installation didn’t go so well, and I received a message stating vaguely that I had previous software that needed to be removed.

    I removed the Silverlight browser plug-in, but I got the same message.  Since the only other Silverlight component I had installed was the SDK, I decided to remove that also.  This did the trick.  It turns out that what is now being called the Silverlight Tools is actually a comprehensive install that includes the SDK, though at some previous point it wasn’t.  Checking at the Microsoft Silverlight site, it also appears that the site has been updated with a clarification to make this change more obvious.

    After getting everything installed, I fired up the Visual Studio IDE and started working through the examples in Chris Wenz’s Essential Silverlight 2 — Up to Date.  It is the only book on Silverlight 2 I could find, and the "Up to Date" postscript is meant to indicate that it will be updated on a regular basis as different versions of Silverlight are released.  The one I’m reading through is meant to be for the Silverlight 2 Beta 1, though the version being sold appears to have been written before the official release.  I was also told that this was the book which was distributed at MIX ’08.

    I tried downloading the sample code that is intended to go with the book, but it turned out to be a dead link.   Oh well, I thought, I can just build each project myself according to Chris’s instructions.

    At the end of the first chapter, however, I was instructed to create "a new Silverlight Control project within the current solution," and after 20 minutes or so trying to puzzle out what I was supposed to do, I finally realized that no such project template existed.  The version of the Silverlight 2 Beta 1 that was released turns out to be a different beast than the one he was writing about.  So I’ll just skip this example and move on to the rest of the book, hoping that this is the exception that proves the rule, rather than the rule that proves the rule.

    In this first chapter, I also learned a new acronym to add to my bestiary of strange and exotic technical terms.  An RIA is a Rich Internet Application, not to be confused with an AJAX client, or a thin client, or a one-click client, or a rich client application.  Silverlight is an RIA, as is Adobe Flash, Adobe AIR, JavaFX and Google Gears.

    Despite the frustrations of this first day, I am still excited about Silverlight.  The contradictory and confusing nature of the various Silverlight resources can be chalked up to the entry cost for learning bleeding edge technology.  And perhaps it is even intended to discourage those not willing to bear some burden as the price for acquiring new knowledge. 

    On another front, I’ve decided that the best place to renew a study of Husserlian Phenomenology is with Franz Brentano.  I have a translation (which you can read here) by Benito Müller of a series of lectures given by Brentano on descriptive psychology from 1890 entitled Psychognosie, which include Brentano’s influential analysis of the concept of intentionality — the sine qua non of phenomenology. 

    In his introduction, Müller is good enough to provide the most succinct explanation of intentionality I have ever come across. "Every psychical act is intentional in that it is directed upon an object."  Would that tech book authors could achieve a similar standard of clarity.