Silverlight. Thinking Small with Big effect


Silverlight is a cut down version of the Windows Presentation Foundation, and was formally known as Windows Presentation Foundation Everywhere (WPF/E). This cut down version includes the base class library and WPF libraries that allow .NET developers to program .NET code that can be hosted in any web browser and on any platform – Windows, Linux and Apple Macintosh.

Silverlight 1.0 was released some time ago and concentrated on media, i.e Video and Music players. There was nothing of any real interest for 50 hour a week coders. This however, has changed with a Silverlight beta 2.0, that is available which incorporates a whole host of controls. In traditional ASP.NET applications, AJAX is the most recent technology to be used to enhance user interaction with a web-page. AJAX is client focused, which means that as one browses through a web-site, one doesn’t get the page flicker and reload each time you interact with a server control or web-page. Traditionally you send a HTTPGET request to the server and it responds. AJAX uses JavaScript heavily to interact in the browser on the client machine. AJAX is essentially a hack, but it works. It gets rid of the annoying flickering, and the whole experience with the web-browser is ostensibly mellifluous.

With these two client focused technologies, Microsoft have had to shift focus to the client machine again. I started out in ASP.NET and recently returned to client development, and can truthfully say that Microsoft have put enormous resources into their web stack. Which is server based. Independent ISV’s have supplied the client stack rather well, so for a while, things trundled along nicely.

Then along came Silverlight. The principal requirement for Silverlight (like Adobe flash) is that end user download a plug-in for their browser. Microsoft have had to do some really deep thinking into what they put in and leave out. The total size at the moment is less than 5MB, so space and optimised code became a priority by default. They needed to provide a plug-in that was as full featured, but as small as possible.

One of the undoubted results of this ‘trimming-down’ exercise is the procurement of the client profile. This is such a big feature in the forthcoming .NET 3.5 service pack, and it’s all been brought about thinking as small as possible and getting the biggest result, insofar as ease of deployment.

Why Vista is perceived to be a failure


Building software is like architecture in a lot of ways. An array of engineering disciplines is required to pull off the feat of building a house or apartment block. Civil engineering is a requirement for the foundations and structure of the building. Mechanical engineering is a requirement for the materials that are structurally used. Electrical engineering is required for the wiring, not to mention all the above and more to get the supplies to and from the building site. The electrical and water supply connection to the house are likely to use Automotive engineering and Aeronautical engineering as well.

Windows Vista is built on a superfluity of computer science and engineering disciplines, all the way from in-house coding implementations, native code, to managed code. The more one delves into writing code, the more appreciation one has for the underlying operating system. This is why I love Windows, Linux and Apple Macintosh equally. Yes all have their strengths, but as software engineer and someone that adores software, I find it beyond belief, that one can ever entirely dismiss one platform for another. They are all marvellous achievements!

As a .NET developer though, my day to day focus is on Windows, and the Vista operating system is where most of my day is consumed. I have written about the lacklustre finish of this operating system, but am even more disappointed with the lack of Windows Presentation Foundation applications that are available to use on the platform. It was a decision by Microsoft to implement this new presentation layer for Windows Vista, but they have not supplied any applications for the general user to enjoy. This is why the operating system has got so much bad press, because as a general user, nothing ostensibly distinguishes XP from Vista at present. The same 100% of applications one used on XP are the same 100% of applications you use on Windows Vista. Microsoft is reluctant to update any of its successful applications, because there is no profit in it.

You have to have a very good reason to knock a house down and rebuild it. It is apparent immediately that it is very expensive, when you consider the expertise required to engineer a house. Microsoft has done this with Windows Vista and Windows Presentation Foundation. Anyone that has ever programmed Win32 or Windows Forms will tell you what a nightmare it is to try and change the appearance of a control. Take the built in calendar control for instance. It is painful. Microsoft resolved to change this, alleviate the pain and introduce WPF. The only problem is they have yet to release a major application that uses WPF, and at present, appear unlikely to do so until the next Windows 7 version. This is poisonous, because Vista will now always be seen as a failure, because it ostensibly failed to improve the application environment from XP. Most users are not silly and know this.

To put it another way, you have smashed down your old house, and built a new one (albeit with a stronger foundation, but the old one was strong enough – other houses in the same street are still standing. Like XP), and then proceeded to use the same 15 year old dirty carpets, and 10 year old gas boiler, even the sinks, shower and bathtubs are the same grotty ones you had in the previous house. You’ve also decided to paint the house exactly the same colour as previous, kept the same sofas that the dogs have chewed over the last 5 years; even the beds and bedding have remained the same. It’s the same 10 year old television (some people have flat screens now in the same street), the same phones and light fittings, the same toilets and curtains, even down to the same dustbin and doors. You have added a state of the art security system though from a company called UserAccountControl. Your washing machine and fridge have both worked for the last 15 years, so you see no reason to change to newer models because there is no benefit; it costs more, for the same functionality.

I know this analogy is rather ‘over-the-top’, but this is how your users feel, and this is why they complain, and it will only get worse for Microsoft, unless it changes the furniture for something newer, nicer, fresher, lighter and brighter. This is how people feel about software. This is the place we live in visually, more and more each day. We will never come to your dinner parties again (Vista) because your house is grotty, depressing and archaic. We also know to look out for the same furniture in Windows 7

Easing .NET Framework deployment for Windows Forms and WPF


One of the real pains with deploying a .NET 3.5 application on Windows XP (OS of choice for business) is the fact that you need to install .NET 2.0, .NET 3.0 and .NET3.5 frameworks. The first two are plus 100MB, and the last is around the 60MB mark (last time I checked). Windows Vista comes with .NET 3.0 pre-installed.

This does cause headaches for IT professionals trying to deploy a new application, or if you write a managed application distributed on the Internet, users need to download and install all the aforementioned versions before the application works. This is cumbersome, awful first impression and bad user experience when starting to use a new application.

With the forthcoming Visual Studio 2008 and .NET framework 3.5 service pack around the corner, a new feature called ‘client profile’ has been created. This, in a nutshell, removes all the extraneous libraries a client application does not use, like ASP.NET for example, and retains the most common client application libraries for both Windows Forms and Windows Presentation Foundation. A step by step tutorial is available here.

ClientConfigs_web_2

The total file size will be around 27 MB, which is tiny, and will please all the IT departments no end, that have to deploy managed applications either locally or distributed. Even if you have just a .NET 2.0 application, that is around 120MB in size, so you immediately shave off 100MB in the install. I must reiterate, that this affects both Windows Forms and Windows Presentation Foundation, and you can ease deployment for both presentation layers. You will reduce the install imprint of you application by at least 400MB and save at least 30 minutes at the start, while the client machine installs .NET 2.0 then .NET 3.0 and finally .NET 3.5 (with the restarts in the middle).

Stunning open source Silverlight 2 charts


One area Windows Presentation Foundation is leaps and bounds ahead, even at this early stage, is in charting components. The graphical possibilities of WPF/Silverlight are so good, that there really is no comparison. It is what is known commonly as a ‘one horse race’.

Visifire have released their free open source data visualisation charts which are of a very high standard. The best window forms charting suites are either, Devexpress or Dundas but both are expensive (especially Dundas) and still incomparable – quality wise. Component vendors like the aforementioned are going to really have to raise their game, because WPF/Silverlight makes it so much easier for creative people to create visually stunning components.

Windows Presentation Foundation gathering momentum


As a run-of-the-mill business application developer, one usually pays for presentation layer software from DevExpress/Infragistics and so forth.
Money usually goes to attaining the latest and greatest Office mimicking UI, and your developers ‘thrash out’ the necessary business logic. Rudi Grobler has just posted a simply excellent example of creating an Office 2007 Navigation Pane in WPF, using just the standard WPF tab control. Usually one  would have to spend $200-$400 (without the source code) from – to choose two random presentation vendors –  http://www.actiprosoftware.com/Products/DotNet/WPF/Navigation/Default.aspx
or http://www.devcomponents.com/.
The real beauty here is that one can skin the complete application using the same resource dictionary, which is super-duper-powerful! This allows for a uniform ‘look and feel’ across the application, normally an absolute pain to implement with windows forms.
When you also take into account that Scott Gu recently announced that a major update to WPF is imminent (summer 2008), and that WPF will have a new Ribbon Control and DataGridView out-of-the-box, a personal proclivity is developing toward WPF.

This summers update will address key problems I have highlighted in the past with WPF, primarily poor performance with list type data, and an unavailability of third party controls. If you also ‘factor in’ .NET cold and warm start up times being significantly improved, the WPF ‘stack’ is certainly gathering momentum.

Windows Forms still ahead of WPF in LOB applications


Just reading the roadmap from DevExpress

http://www.devexpress.com/Home/Announces/Roadmap2008.xml it is pretty clear that that sales for Windows Forms are still very high. This has meant that investment in the Windows Forms platform is to continue.
The principal problem with WPF for LOB applications, is that you need to pay for a designer, and they do not come cheap. In a six month turnaround application, that can easily be £60,000, or much much more. With most LOB applications, you purchase presentation layer components from Infragistics, DevExpress, Component One etc, and your developers thrash out the necessary business logic with the Office 2007 UI or whatever UI is flavour-of-the-month.
Because Microsoft have just created the fluent interface in the Office 2007 ribbon, I cannot see a significant change to this UI in the next office version. Office is still written in C/C++ and I don’t see a re-write for the next office version. As a result most applications written in windows forms today will continue to be relevant. Look at Visual Studio, the toolbar components are pretty much the same as Office 2003, even down to the icons that have not been changed for years. Visual Studio is a tool, and most LOB applications are tools.

Differentiated UI is a big risk in LOB applications, because you usually have a workforce with varying IT skills. You can safely assume that most users are familiar with Outlook, so creating an application with a similar look and feel lessens the learning curve. WPF opens up new doors, and for me in LOB applications, only the subtle use of it with nice 3D charting or reports is the way to go. If you move to far away from the familiar, you will end up with users struggling to learn the application. The net resultant is increased training costs for the application, for no real business value.

Finally, An example of a Multi tier architecture for Linq to Sql


Update 2/6/2008:

The original post for this is available  beneath, but the link to the original article has been removed which turns this post to a pointless rant because you cannot reference the article. Luckily Beth Massi has a very good n’tier Linq example.

Original

Anyone that is aware of my posts knows that I do whinge about the lacklustre implementability of Linq in real world scenarios. I have battled with this for some time now.

Microsoft’s response a few months back was that they were waiting to see how their customers would ‘conjure up’ a method of doing this.
I found this attitude dissatisfactory, because if you’re trying to negate the impedance mismatch between ‘objects’ and ‘data’, the ubiquitous scenario is n-tier. You cannot introduce such a feature (Linq), and not have examples of it being implemented n-tier.
I have just come across an example of implementing Linq to Sql on MSDN. The link is available here.

I have finished testing this and quite frankly, I’m very disappointed. This is not easier than datasets, but more complex, for absolutely no ROI for understanding the raised abstraction.
Validation is pain, even more painful is moving this to winforms/wpf applications, that do not have the object data source.

I keep returning to Linq because of all the noise Microsoft made. Indisputably, one is more expressive when composing queries, but that is just one small part in creating an n-tier app.

Nah, back to datasets for me, and quick. Unless a miracle happens.

Linq to SQL Compact Edition (CE)


I got asked about doing this recently, and needed somewhere to point the individual to.

Presently, unfortunately, Linq to SQL Compact Edition is unsupported. Luckily though, it is quite easy to still perform Linq queries against SQL compact using the command line utility SqlMetal. SQL Compact Edition is very handy for single user applications or demos where you want to retain a very small application imprint, but not lose functionality. All that is required is that you have the object relational mapping (ORM) file that contains the Linq to SQL classes. This in Visual Studio is the .dbml file that is generated when you elect LinqToSQLClasses in the data menu.

Open up the Visual Studio command prompt by going to

You should have the following;

C:\Program Files\Microsoft Visual Studio 9.0\VC>

Enter ‘SqlMetal’ in the command prompt and take time to explore all the options available to you.

I simply want to create a .dbml file from my database which I have in my c:\ drive. You will want to point this to wherever your .sdf file is.

Enter the following path into the Visual Studio command prompt

SqlMetal /dbml:c:\Users\MyName\Documents\Northwind.dbml "C:\Users\MyName\Documents\Visual Studio 2008\Projects\Windows Forms\Code\Northwind\Northwind Database\Northwind.sdf"

Where the above is the format; SqlMetal /dbml:northwind.dbml northwind.sdf

Note that in vista you must specify the path through the ‘Users folder’. Failure to do this will result in a file access error.

As you can see my .dbml file was copied to my documents folder. I then copied this into my project. .To access the file I reference it in the constructor of the form thus;

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        NorthwindDataContext northwindDataContext;

        public Form1()
        {
            InitializeComponent();

            this.northwindDataContext = new NorthwindDataContext(Properties.Settings.Default.NorthwindConnectionString);
        }
    }
}