Microsoft trips on Visual Studio Lightswitch
Latter-day Access needs less code
Review Microsoft's Visual Studio LightSwitch, just released to beta, is a new edition of Visual Studio 2010 and will become the next step up from the free Express.
In other words, it will be paid-for but cost less than the existing Professional version. Do not be fooled though: although this is a low-end tool it is one with high ambitions.
Some two years in the making, it aims to simplify the building of business database applications, particularly at the departmental or small business level, but to do so in a way that respects Microsoft's current ideas about best-practice software architecture.
You can think of it as a modern-day Access or FoxPro, except that this is 2010 and LightSwitch builds Silverlight applications, both desktop and browser-hosted, that retrieve data over the internet or intranet and which might even run on a Mac.
LightSwitch is a departure from a model of visual programming that Microsoft has used since the first Visual Basic in 1991. This old model involves building a form with drag-and-drop visual components, then writing code to make it work. LightSwitch has no visual form designer, at least not in that sense.
Screen designer is where ease of use begins to break down
Screens are defined as a list of components bound to data, and you can only find out how a screen will look by actually running it. The size and position of components is set by LightSwitch. It is an implementation of Model/View/ViewModel (MVVM), which is a variant of the Model-View-Controller (MVC) pattern currently fashionable in Microsoft circles. While the merits of NVVM are arguable - some find it over-complex - Microsoft deserves credit for creating an easy to use tool that at least attempts to follow a sound architectural pattern.
Database connectivity and user authentication in LightSwitch uses WCF RIA Services, Microsoft's web service framework for Silverlight, though developers are shielded from the details. This means there is a middle tier running on Microsoft's IIS web server.
The middle tier connects to data via Microsoft's Entity Data Model, and out of the box LightSwitch supports SQL Server, SharePoint, or any generic WCF RIA Service. Azure support for both data and deployment is promised in the final release, as is Microsoft Access databases, but neither is present in the beta.
So how does this look to the developer? LightSwitch is firmly data-centric, and after choosing between Visual Basic or C#, the first thing you have to do is either to create a new table, or attach to an existing database. If you are starting from scratch, LightSwitch uses SQL Server 2008 Express. The table designer is a good effort, simplified but still powerful, with common-sense business data types like EmailAddress, Money and PhoneNumber as well as the usual Ints and Doubles.
LightSwitch aims to handle as much of the plumbing as possible, leaving you to concentrate on the business decisions. For example, ID fields are there by default, and when you create screens, client-side validation based on data type is automatic.
The table designer also handles queries, relationships and computed fields. When you create a relationship, a diagram and plain English description explains your choices, such as: "An invoice can have many InvoiceDetail instances." You can also specify delete behaviour, and LightSwitch will either implement cascading deletes, or prevent deletes that would leave orphaned rows.
Once you have defined the data, you can add screens using templates such as search forms, editable grids, or list and details. LightSwitch then builds a screen and displays it for modification. The screen designer is where LightSwitch's ease of use begins to disappear, though in simple cases you may not need to make many modifications. This is also where you can add custom code for events such as screens loading, controls changing their values, or data saving. It is not too bad; but one can imagine occasional developers used to Access or Visual Basic finding this designer perplexing.
Runtime customization mode is the nearest thing to a visual form designer
An intriguing feature is that you can customize a form in the debugger. This helps to mitigate the lack of any visual designer. In customization mode, you get access to the component list and property editor along with a preview of your screen, all implemented in Silverlight.
LightSwitch is impressive, even in its beta state, which is by no means fully stable or complete. But does it succeed in its aims? As an effort to simplify database design, it is Microsoft's best effort yet, but as an application building tool I am not so sure.
LightSwitch creates large amounts of code: I followed through the tutorial for a simple application and the generated files included 4,500 lines in a file called DataRuntime.cs, for example, though you are not meant to care about this. This may be why performance seems disappointing; but this is an early beta so that may change.
Another issue is that moving from the pre-built screens to something more fully customized is a challenge: you have to create data-aware Silverlight custom controls and hook them into the screens. Finally, there is the question of whether the target developers are ready to abandon the comforts of Excel and Access for the mysteries of Silverlight, LINQ, MVVM, and no visual form designer.
This is a brave effort though, tackles a real need, and shows Microsoft's continuing commitment to the Silverlight platform. ®
Sponsored: Fast data protection ROI?