Monday, September 12, 2005

PDC PreConf Day 1: .NET Framework 2.0 - The Smart Client Perspective

As part of my work I make decisions on which client projects should be implemented as Web Applications and which should be Smart Clients. Because of this I decided to attend the pre conference session on Smart Clients and .NET 2, to see if there were any new issues that I was not yet aware of. The session was being presented by Rockford Lhotka and Billy Hollis, two gentlemen who’s sessions I’ve had the pleasure of attending before. I’ve been working on a project using Visual Studio 2005 since February, and that project involves some Smart Client elements. So most of the stuff covered by this session was pretty familiar to me, but it was still nice to hear how these two cool guys view these things.

The session started out with a discussion on the history of client user interfaces, focusing on how we’ve moved from mainframes and client server apps to web apps and now back again. The guys also touched on one issues I come across quite a lot – namely that by now people have finally gotten used to UIs being browser based and there is a fair amount of resistance towards going back to making “real” Windows applications again. One of the major issues they recommended was to take a look at how you calculate the cost of different alternative and especially how calculating the per user-cost of a web application can be misleading. The reason for this is that in so many cases you will end up having to add a lot of quite expensive hardware and licenses to your server setup when your user amounts increase. If you work with Smart Clients you might get away with less investment on the server, since you can actually use some of that computing power in the usually quite expensive desktops or laptops that your users are equipped with.

A lot of interesting and funny stuff was covered during the intro and the Smart Client background, and I won’t repeat it here, except for one last thing; how there basically no general agreement on what a Smart Client actually is. My view on it is that the name is horribly misleading and that they should actually have been called “Windows Applications – Finally Done Right” (WAFDR). But I guess that would have been too long for the Microsoft Marketing Department to accept it. Sigh. But that won’t stop me from using it!

Data and Data Binding

They kicked off the proper session with a look at the data and data binding stuff in VS 2005 and how it has evolved from the .NET 1,1–world. One of the really major new things I’ve found in Windows Forms 2 is the ability to do data binding to objects, which is is essence the only decent way to do it in a client server application or in a real WAFDR application. It’s also become a lot easier to work with data sources, ranging from how to create them to how to use them in your forms. One thing I really like is that VS now comes with a proper data set editor, instead of just using the regular XSD-editor, which isn’t really that good for data sets. I’ve done some work with this stuff, and I can tell you it’s actually quite good. A clear and great step forward for data binding, and even though I’ve been quite sceptical towards data binding in the past I have to say that has mostly changed over that past 6 months because of working with VS 2005. And most of the stuff is nowadays strongly typed, which is the way it should have been to start with.

In Windows Forms 2 there’s a bunch of new UI controls, and for the first time ever there’s a pretty good grid control included (the GridView control). It used to be so that you couldn’t really understand why Microsoft even bothered to include their own grid control in Visual Studio, since it was so crap. But that’s changed now, because the GridView is actually quite nice. It lets you use proper controls in the cells, and it also lets you set a bunch of display properties all the way down to the cell level. At work we’ve used a bunch of third party controls in order to get decent grids and certain other UI controls, and we’ve not really been happy with them. Most are simply too bloated to be practically useful in a business environment where some of the client machines might be a bit old and therefore not able to deal nicely with the multitude of events firing all over the place in the grid. And not to mention what a disaster they tend to be in ASP.NET, especially in an environment where every machine is not set to use English (United States) as their regional settings. We’ve used Infragistics a lot, and by now I pretty much consider them to be the unholy Spawn of Satan. With VS 2005 we’ve been able to avoid using third party controls for several new projects, which I’m quite happy about.

Rhockford talked quite a bit about the data stuff, and I won’t repeat all of it here, but one thing I got stuck on was where to place business logic in an application. Quite obviously it should not be in the UI, and it seemed that his opinion was that the reason why people tend to put it there was because you couldn’t data bind properly to object before (not without a lot of work), and you couldn’t really put logic in the dataset. Either that or stupidity. But in this presentation he talked about how now it is possible to put logic in the data set, and seemed to be of the opinion that this is a good thing. I haven’t had time to think about this myself yet, but I have to say I am rather sceptical. Perhaps what he meant is having it in the object that contains the data in general, and since the data source could be an object as well then perhaps he meant was having it in a custom object and binding to that. Or then perhaps I just didn’t catch was he was on about.

Break for lunch, I’ll post more in the afternoon.

Smart Clients Continued

(This is the second half of my post from the first day of the first pre conference day at PDC 05)

The afternoon started off with some more discussion on data binding and on objects with a focus on business logic. At this point the session started to get more interesting, since now they were starting to cover the parts of application design where I still have some doubts and unclear issues regarding Smart Clients (or WAFDR applications, if you read my previous post). Here it also became apparent that Lhotka did put the business logic in custom objects on which he did data binding, which I was wondering about in my previous post. How to move the data between the client and the server was discussed at some length, with a jab at Juwal Löwy on the topic of whether to use web services, enterprise services or remoting (Juwal is fanatic about Enterprise Services, I’ve heard him preach on the subject in a number of presentations). Basically the point here was that using IIS is the easiest and Enterprise Services the fastest. So regardless of what the Enterprise Services Taliban says I guess at least I would recommend using the simplest solution available, as long as it still does the job. In many cases that means hosting your server in IIS.

Layers in a Smart Client

Next was the topic of layers and tiers, and why they matter when designing an application. This was pretty basic stuff, at least if you’ve worked on reasonably large applications. The “traditional” view on this topic works somewhat well in a Smart Client scenario, but since most Smart Clients need to work off line that adds some complexity to the picture and has an impact on the application architecture. Since the business logic needs to run on at least the client, and in many cases some of it has to run on the server, you need to slightly rethink how you structure you app. Lhotka was describing it through a data portal pattern, which was just a way of describing an architecture where you had a server that exposed a bunch of data-related services that were exposed to a client, where they were hidden away by a facade. The business logic accesses the data through the facade, without having to concern itself with from where and how the data is being produced. Pretty basic stuff, and I was happy to see that they were recommending some of the same solutions that we have been putting into our solutions for the past half year. The major of the remainder of this part of the session was spent on talking about which part of the business objects live in which layer, and where it exists as data and where it exists as a business object (the difference between business logic and data here is that a business object contains layer). The model Lhotka came off as recommending was one where the business objects exist both on the client and the server, so that you can have a situation where you don’t need to trust the client; the server can make its own choices on the data in the objects without assuming that the client has used the correctly.

I had been a bit worried about the risk of finding out a bunch of new and superior ways of architecting a distributed app for a Smart Client compared to the stuff I’ve been doing at work, but fortunately that was not the case. That could have resulted in some re-engineering in a bunch of customer objects, which I would prefer not to have to do at this point… There was a lot of nice details here, and it was good to get confirmation of the design choices we’ve been doing.

New stuff in Windows Forms 2.0

I won’t write about this in great length, it’s a topic that has been covered quite a lot in other blogs. I’ll just quickly mention some of my favorite things (I already mentioned the grid in my previous post). The first would be the two new layout controls (flow and table layout). This is basic stuff if you’ve worked with UIs in Java, but it’s new in Windows Forms. Hollis pointed out that in the Smart Client world you can’t make so many assumptions about what the user’s screen proportions and size are (consider Tablet PC:s for example), and therefore the layout controls can be very useful. I agree completely with this. Furthermore they help in making sure your UIs always look and behave the same. The next thing I’d like to mention are the new toolbars and menus, now they look like proper Office menus and toolbars, which is something I’ve missed in the standard controls. Basically we’ve had to use third party controls in all our apps, and I mentioned what I thought about that in my previous post… Finally the fact that you can tell your text boxes what kind of data you want them to accept (in the shape of format strings) is very nice and a great help in making it easier for users to enter correct data.

New language features in VB and C#

Why this was included in this session is beyond me. I won’t cover it here, except for to note that VB (which I don’t use) has a new keyword called “IsNot”. So you can write grammatically disastrous code along the lines of:

“If myVariable IsNot Nothing Then”

English is not my native language, but isn’t that a double negation? Shouldn’t it have been called:

“If myVariable IsSomething Then” or “If myVariable Is Something”?

The first alternative is a bit illogical (which would make it excellent for inclusion in VB), but I really like the second one. That would only have required that they would have introduced an alternative (or actually an opposite) of the already existing “Nothing”. Neat. That would have allowed you to write stuff like:

“If Something Is Nothing Then”

and of course, instead of writing “1 = 1” or “2 > 1” to indicate statements that would always be true you could instead type “Something > Nothing”. But then again I guess that you can’t always know if Something actually is more than Nothing. If Freedom can be a another word for Nothing left to lose, and Nothing ain’t worth Nothing but it’s free, then quite obviously Nothing is Free, and therefore it is also Something. This is getting rather philosophical, which again would have put it firmly out of reach of VB. Hmm, wouldn't it be valid VB code to write “If Nothing IsNot Nothing Then”, and that would always evaluate to false? Does that mean that VB is trying to tell us that Janis was wrong? Damn this jet lag.

Click Once install

I’ve blogged about this before, so I won’t go into detail on it now, except for to say that I really like it. I think it will considerably simplify application deployment, at least for deploying applications in a corporate scenario. One thing I believe I didn’t mention last time I wrote about this is that Click Once can not do background updates (like Windows Update and the Application updater block does). This will be added later, apparently when Vista comes around. I do think this is a bit of an annoyance, but as long as the application is running on a fast network and not over the Internet is should not be a problem. On the other hand, with careful use of the options for selecting how the update should behave (check on startup, compulsory update etc.) I think it will not make such a big difference that the application can’t update in the background. Will have to get back to this when I’ve had a chance to test it out a bit more.

The bootstrapper is nice. If it works as promised then Click Once will be able to install stuff like the .NET Framework and SQL Server Express as part of the installation processes. That will be seriously cool.