Sunday, March 09, 2008

I'm just back from the MIX 08 conference. This was the first conference I've attended in many years (around 10 I think) where I wasn't speaking or somehow working. I'd forgotten just how fun and inspiring it can be to simply attend sessions and network with people in the open areas. No wonder people come to conference!! :)

Not that it was all fun and games. I did have meetings with some key Microsoft people and Scott Hanselman interviewed me for an upcoming episode of Hanselminutes (discussing the various data access and ORM technologies and how they relate to CSLA .NET 3.5).

The Day 1 keynote was everything I'd hoped for.

Well, nearly. The first part of the keynote was Ray Ozzie trying to convey how Microsoft and the web got to where it is now. The goal was to show the vision they are pursuing now and into the future, but I thought the whole segment was rather flat.

But then Scott Guthrie came on stage and that was everything you could hope for. Scott is a great guy, and his dedication and openness seem unparalleled within Microsoft. I remember first meeting him when ASP.NET was being unveiled. At that time he seemed so young and enthusiastic, and he was basically just this kick-ass dev who'd created the core of something that ultimately changed the Microsoft world. Today he seems nearly as young and easily as enthusiastic, and he's overseeing most of the cool technologies that continue to change the Microsoft world. Awesome!

So ScottGu gets on stage and orchestrates a keynote that really illustrates the future of the web. Silverlight (which makes me SOOoooo happy!), IE8, new data access technologies (like we needed more, but they are still cool!) and things like ASP.NET MVC and more.

As I expected, they released a whole lot of beta code. You can get a full list with links from Tim Sneath's blog. He also has links to some getting started materials.

The real reason for keynotes though, is to inspire. And this keynote didn't disappoint. The demos of Silverlight and related technologies were awesome! There was some funny and cute banter with the casting director from Circ del Sole as she demonstrated using a cool disconnected WPF app. There was a fellow RD, Scott Stanfield, showing integration of SeaDragon into Silveright so we can look (in exquisite detail) at the memorabilia owned by the Hard Rock Cafe company, some thought-provoking demos of Silverlight on mobile devices and more.

Now to be honest, I've never been a fan of the web development model. Having done terminal-based programming for many years before coming to Windows, I find it hard to get excited about returning to that ancient programming model. Well, a worse one actually, because at least the mainframe/minicomputer world had decent state management...

AJAX helps, but the browser makes for a pretty lame programming platform. It is more comparable perhaps to an Apple II or a Commodore 64 than to a modern environment, and that's before you get into the inconsistencies across browsers and that whole mess. Yuck!

Which is why Silverlight is so darn cool! Silverlight 2.0 is really a way to do smart client development with a true web deployment model. Much of the power of .NET and WPF/XAML, with the transparent deployment and cross-platform capabilities of the browser world. THIS is impressive stuff. To me Silverlight represents the real future of the web.

It should come as no surprise then, that I spent my time in Silverlight 2.0 sessions after the keynote. Sure, I've been working (on and off) with Silverlight 1.1/2.0 for the past several months, but it was a lot of fun to see presentations by great speakers like Joe Stegman (a Microsoft PM) and various other people.

One of the best sessions was on game development with Silverlight. I dabble in game development whenever I have spare time (not nearly as much as I'd like), and so the talk was interesting from that perspective. But many of the concepts and techniques they used in their games are things designers and developers will likely use in many other types of application. Background loading of assemblies and content while the app is running, and some clever animation techniques using pure XAML-based concepts (as opposed to some other animation techniques I saw that use custom controls written in C#/VB - which isn't bad, but it was fun to see the pure-XAML approaches).

Many people have asked about "CSLA Light", my planned version of CSLA .NET for Silverlight. Now that we have a Beta 1 of Silverlight I'll be working on a public release of CSLA Light, based on CSLA .NET 3.5. Microsoft has put a lot more functionality into Silverlight 2.0 than they'd originally planned - things like data binding, reflection and other key concepts are directly supported. This means that the majority of CSLA can be ported (with some work) into Silverlight. The data portal is the one big sticking point, and I'm sure that'll be the topic of future blog posts.

My goal is to support the CSLA .NET 3.5 syntax for property declaration and other coding constructs such that with little or no change you can take a business class from full CSLA and have it work in CSLA Light. This goal excludes the DataPortal_XZY implementations - those will almost always be different, though if you plan ahead and use a DTO-based data access model even that code may be the same. Of course time will tell how closely I'll meet this goal - but given my work with pre-beta Silverlight 2.0 code I think it is pretty realistic.

Scott Guthrie indicated that Silverlight 2.0 Beta 1 has a non-commercial go-live license - right now. And that Beta 2 would be in Q2 (I'm guessing June) and would have a commercial go-live license, meaning it can be used for real work in any context.

The future of the web is Silverlight, and Beta 1 is the start of that future. 2008 is going to be a great year!

Sunday, March 09, 2008 5:18:27 AM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [0]  | 
 Monday, March 03, 2008

I am one of the Microsoft Regional Directors, which means that I'm in a group containing some of the most thoughtful (and sometimes challenging :) ) people in the Microsoft community. That's a humbling place to be, especially when we all get together and talk about the current and future state of technology!

The RD program has a web site, www.TheRegion.com, which includes an aggregated blog summary of all the RD bloggers. Not all RD's blog, but quite a few of us do, and the topics run the entire range from gadgets to hardware to networking to software development to architecture. In short, www.TheRegion.com is a treasure trove of great information!

Monday, March 03, 2008 5:32:43 PM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [1]  | 

Another place where I was able to reduce business object code in CSLA .NET 3.5 was to effectively eliminate the GetIdValue() method.

Prior to version 3.5, GetIdValue() was required, and you had to provide a unique value identifying your object. This value was used to implement Equals() and GetHashCode(), and was used as the ToString() value. This was good, because it enabled the concept of logical equality, where objects were equal to each other based on their id value.

For better or worse, WPF doesn't support logical equality. They only support absolute equality - ideally implemented by comparing all properties of the two objects so two objects are only equal if all their properties are equal. A poor man's replacement is to use reference equality - which is much faster but is technically less accurate. The effective default in .NET is reference equality.

CSLA .NET 3.5 no longer overrides Equals() or GetHashCode(), so it now uses the .NET default behavior. This makes WPF happy. This might break some people's existing code (though a poll on the forum indicates it is a non-issue for virtually everyone), because there is no longer any idea of logical equality unless you implement it yourself.

The upside though, is that you no longer need to override GetIdValue(). I left the method in the framework for backward compatibilty, so if you do override it your code will continue to compile (though the value is now only used in a ToString() override).

Monday, March 03, 2008 8:53:36 AM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [3]  | 
 Thursday, February 28, 2008

One of my primary goals with CSLA .NET 3.5 was to reduce the amount of code necessary for common business object tasks - like declaring a property or implementing a parent-child relationship. I've mentioned what I'm doing on the forum and elsewhere, but I thought a summary blog post would be nice. I'm motivated, because I spent some time earlier today upgrading some business object code based on CSLA 3.0.3 to 3.5 and it was just fun to watch the class shrink :)

Basic Properties

Prior to 3.5 my properties were comparatively large:

public string Name
{
  [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
  get
  {
    CanReadProperty(true);
    return _name;
  }
  [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
  set
  {
    CanWriteProperty(true);
    if (value == null) value = string.Empty;
    if (_name != value)
    {
      _name = value;
      PropertyHasChanged();
    }
  }
}

Now the same property looks like this:

private static PropertyInfo<string> NameProperty =
  RegisterProperty<string>(typeof(CertificationEdit), new PropertyInfo<string>("Name"));
public string Name
{
  get { return GetProperty<string>(NameProperty); }
  set { SetProperty<string>(NameProperty, value); }
}

I think that is so cool!! Though there's a performance hit to this much reduction, because you'll notice there's no backing field. In this case CSLA is actually managing the property value in the background and that incurs a little overhead. You can compromise if you'd like:

private static PropertyInfo<string> NameProperty =
  RegisterProperty<string>(typeof(CertificationEdit), new PropertyInfo<string>("Name"));
private string _name = NameProperty.DefaultValue;
public string Name
{
  get { return GetProperty<string>(NameProperty, _name); }
  set { SetProperty<string>(NameProperty, ref _name, value); }
}

Nearly the same code, but now with a private backing field so CSLA doesn't have to manage the value. Slightly faster, with slightly more code.

Either way, all the authorization, validation and data binding support works just like it did with the old syntax, so all the core features of CSLA .NET just keep working in your favor - with less code to write and maintain.

Child Object Properties

This new syntax works for child objects as well. A child used to look like this:

private ChildType _child;
public ChildType Child
{
  [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
  get
  {
    CanReadProperty(true);
    return _child;
  }
}

The new syntax requires that CSLA manage the property value for child objects:

private static PropertyInfo<ChildType> ChildProperty =
  RegisterProperty<ChildType>(typeof(CertificationEdit), new PropertyInfo<string>("Child"));
public ChildType Child
{
  get { return GetProperty<ChildType>(ChildProperty); }
}

The really cool part isn't the minor code savings in the property - it is the code savings elsewhere. Prior to 3.5 a parent object had to override IsDirty and IsValid, and had to hook and re-hook child data binding events. None of that code is required now! Because CSLA is managing the child object value, it can entirely handle IsDirty, IsValid and all data binding events automatically. This saves a lot of code in every parent object.

Even better, this eliminates code that a lot of people forgot to write, or forgot to update when adding a new child. In short, this eliminates a primary source of bugs/pain when dealing with parent-child object relationships.

There are other areas in 3.5 where I've reduced the code required, and I'll blog about others (like reducing data access code, eliminating many criteria classes and more) in future posts.

Thursday, February 28, 2008 9:25:11 PM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [10]  | 
 Wednesday, February 27, 2008

I'm psyched! I finally figured out how to get the Csla.Wpf.CslaDataProvider control to support a Delete command that removes child items from a databound list object.

As you might expect, the answer to the problem was staring me in the face the whole time - I just didn't see it. Isn't that the way things often work? ;)

Since day one, CslaDataProvider has support the Save, Undo and AddNew commands (using XAML commanding), so it has been possible to create Save, Cancel and Add buttons on a form purely through XAML - no code-behind required at all.

Now, with this new change it is also possible to implement a Remove button in a DataTemplate with no code-behind. The button can use the standard Delete command to tell the CslaDataProvider managing the BusinessListBase object to remove the child object bound to that row in the DataTemplate. The XAML looks like this:

<DataTemplate x:Key="lbTemplate">
  <Grid>
    <StackPanel Orientation="Horizontal">
      <TextBlock>Id:</TextBlock>
      <TextBox Text="{Binding Path=Id, Converter={StaticResource IdentityConverter}, ValidatesOnDataErrors=True}" Width="100" />
      <TextBlock>Name:</TextBlock>
      <TextBox Text="{Binding Path=Name, Converter={StaticResource IdentityConverter}, ValidatesOnDataErrors=True}" Width="250" />
      <Button
        Command="ApplicationCommands.Delete"
        CommandParameter="{Binding}"
        CommandTarget="{Binding Source={StaticResource RoleList}, Path=CommandManager, BindsDirectlyToSource=True}"
        HorizontalAlignment="Left">Remove</Button>
    </StackPanel>
  </Grid>
</DataTemplate>

The key was realizing that the CommandParameter could be bound to the entire object that is represented by this DataTemplate - the individual row object. This revelation meant that the CslaDataProvider control can in fact remove that item because an equality comparison is possible. So ApplicationCommands.Delete passes the child object reference to the data provider, which removes the item from the databound list object and that's it!

So this means you can now create a typical maintenance screen with no code behind the XAML. None. You have to write zero lines of VB/C#. Too cool!!

And it means that even on a more complex screen you still don't need to write save/cancel/add new/remove code. That's a lot of code savings! Often all you need to write is code dealing with navigation from this screen to some other screen, perhaps some exception handling code (which I put in a base class) and some authorization code to provide visual cues to the user about what they can and can't do.

Is this really the final step? I doubt it. I already have some ideas on how to expose the authorization knowledge encapsulated by the business object such that it can be directly used within the XAML. I don't know if I'll get that working, but if I can reduce/elminate the UI authorization code (that provides visual cues to the user) and get that into XAML then even more forms will become codeless.

Wednesday, February 27, 2008 8:41:14 PM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [1]  | 

Yesterday I co-presented (with Anthony Handley, one of Magenic's lead designers), giving a talk on building applications using XAML (WPF and Silverlight). It is a fun talk, because we spend the entire time walking through the process and code and design assets we used/created to build an application. And we discuss the great and not-so-great parts of using Visual Studio, Expression Blend, Expression Design, TFS and various other tools in such a collaborative project.

But I did something bad. Something I really know not to do, but sometimes you just get carried away I guess. My mistake? I tweaked some code right before going on stage. I should really know better...

So part way into our talk the code refuses to build. (in retrospect I know exactly what I did, I got two parameters backward on a method) Debugging on stage is never fun, and we surely didn't have time for it in this talk!

Fortunately for us, Magenic provides all consultants with high speed cell modem service for our laptops. This meant we were connected at DSL speed to the Internet, and Anthony was able to quickly use TFS to undo pending changes to the file I'd tweaked. Which goes to show two things. First, good source control is invaluable. Second, Magenic's belief that our consultants should have ubiquitous Internet access really pays off!!

What could have been a demo disaster, turned instead into illustration of the ease with which you can use TFS from within Visual Studio 2008 :)

(p.s. For those living in the Twin Cities area, Anthony and I will be giving a (free, I think) 3 hour version of this talk on April 24 at the Microsoft office in Minneapolis. I'm looking forward to that, because we have to gloss over so much stuff to fit the talk into 60-75 minutes, and it will be great to dig deeper into each sub-topic over a 3 hour period. Watch www.magenic.com for details on registration as the date gets closer.)

Wednesday, February 27, 2008 8:18:49 AM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [4]  | 
 Monday, February 25, 2008

SFVS Live 2008 kicks off in San Francisco on March 30.

I'll be speaking there, giving a talk on merging SOA and OO concepts with a Silverlight 2.0 UI - fun stuff!! :)

And I'll be giving a full-day workshop, showing how to appropriately leverage the broad set of .NET technologies to build applications. There are so many ways to solve the same problem in .NET, whether that be user interaction, getting your data, building a business layer or anything else. Microsoft seems determined to provide 2 to infinity ways to do any given thing, and it seems like chaos. My goal is to provide some sense of order, or at least an architectural model, around the chaos to make it easier to leverage the power of the technologies.

I'm also co-chair of the Core .NET track, and I'm excited about many of the speaker and topic selections for the conference. With so much going on around .NET development, this is a great time to be involved with one of the leading developer conferences in the world!

As a track chair and speaker, I have a discount code you can use to register to get 25% off the registration for a Gold Passport. Just go here to register and use code SPLHO.

See you in San Francisco!

Monday, February 25, 2008 8:45:06 AM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [0]  | 
 Friday, February 22, 2008

CSLA .NET version 3.5 is for Visual Studio 2008 and .NET 3.5 only.

If you are using .NET 3.0 or .NET 2.0 then CSLA .NET version 3.0.x is for you. Version 3.0.4 is a maintenance release incorporating some important bug fixes, especially around data binding.

Version 3.0.4 will release concurrently with version 3.5, and I have put a refresh of the 3.0.4 code online for download at www.lhotka.net/cslanet/download.aspx.

This release is quite stable, and you should consider using it if the bug fixes apply to you. See the change log for details.

Friday, February 22, 2008 10:20:15 AM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [0]  | 

CSLA .NET version 3.5 Beta 2 is now available for download from www.lhotka.net/cslanet/download.aspx.

Please read the change log prior to installing/using this release. If you are coming from version 3.0 or lower there are a few potential breaking changes. If you are coming from 3.5 Beta 1 there is one potential breaking change.

There are numerous bug fixes and feature tweaks from Beta 1 to Beta 2. These are thanks to the great feedback and help I've recieved from numerous people on the CSLA forum (http://forums.lhotka.net/) - thank you all for your help!!!

I am excited to release Beta 2, because we're narrowing in on a final release of version 3.5 and any changes now will be bug fixes or stabilization. Any testing you can do on this new release is appreciated and will help ensure high quality in the final release.

Friday, February 22, 2008 10:06:52 AM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [2]  | 
 Monday, January 28, 2008

clip_image001Hear ye, hear ye!  MIX08 to debut the first ever MIX UX Track which is 3 days of solid content dedicated to creatives / designers.  Lou Carbone, David Armano, Dan Roam, Kim Lenox and others will speak.  In conjunction with Adaptive Path, the User Experience track is just one of the many great reasons for all types of designers and creative professionals to attend MIX this year.  http://visitmix.com/2008/mixux.aspx

clip_image002 The deadline for this year’s CSS contest, RESTYLE, has been extended.  Folks can still clip_image003restyle the MIX08 Homepage and win a pass to MIX08, 3 nights at the Venetian, $$ and more, more, more! http://visitmix.com/2008/restyle/

clip_image004Have you been listening to The Signal?  Each week a new episode debuts featuring a speaker or MIX crew member talking about some of the upcoming coolness happening at MIX08.  Listen to their interviews with Molly Holzschlag, Kip Kniskern, Jonathan Snook and others as we countdown to Vegas.  http://visitmix.com/blogs/TheSignal/

clip_image006 Perhaps you remembered last year’s MIX, in which we featured Flotzam, a WPF screensaver mash-up that showed MIX07 feeds from Facebook, Flickr, Twitter and blogs. Well, we are doing it again this year with a twist: we are running a contest and will feature community created skins of the application on the big screen and on the screensavers of the computers available to attendees at the show.  The best skin will win an XBOX 360.  Entering the contest is easy: everything you need to know can be found here http://www.visitmix.com/blogs/News/403/ including links to screencasts and instructions that show how easy it is to do the restyle.  

Monday, January 28, 2008 9:35:45 AM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [0]  | 

Just to let everyone know, there's a CSLA .NET training class coming up in Atlanta Feb 18-20. The class is organized by Dunn Training, who has been delivering this quality training for over a year now, with great feedback from attendees!

Click here for details.

Monday, January 28, 2008 9:32:49 AM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [0]  |