During the first half of the Tech Tuesday held at the Kennett Square Near Site on 9/13/2011, we took a look at the Microsoft LightSwitch Framework. Offered as an extension to the Visual Studio 2010 IDE, LightSwitch is touted as a collection of starter kits, wizards, and templates that “help you create and easily release custom business apps that look professional and polished, with no coding required”.
Before getting into the details of the framework, we took a two-minute tour of a data management system that was implemented using LightSwitch – the Wind Demographics Database Interface:
When using Visual Studio to create a new LightSwitch project, the framework for a three-tier application is automatically generated. The front-end is a Silverlight client that can be configured as a desktop application, or as a browser-based application hosted by a Web server or the Cloud. “Pages” are added by creating Screens that are based off of Search, New, and Edit templates. The middle (logic) tier is generated using Microsoft ADO.NET Entity Framework and provides a service layer to connect to various third-tier data layers (SQL Server, Oracle, SharePoint, RIA Services). The logic tier offers Entities and Entity Sets that are types (classes) that match the underlying data service constructs.
Using Visual Studio LightSwitch, we were able to stand up very simple web application that connected to a SQL Server database in about 7 minutes (including compilation time). This led us into our “What’s Hot” discussion that centered on some of the impressive features of LightSwitch:
- Relational Data Model – all the CRUD is done for us
- No need to write SELECT, INSERT, UPDATE, and DELETE stored procs for all of the data objects in the model
- Free Validation
- User-edited fields are automatically checked for type and length
- Free Dirty-Checking
- Built-in templates
- Search, New, Edit screens provide default layouts for the generated data types, with the entity fields and related collections automatically added to the screen
- ASP .NET Security
- Windows Active Directory can be tied in automatically, so that users and roles can be managed through the application by administrators – all without custom security code modules
Next we went over some of the less-than-ideal requirements or drawbacks of LightSwitch:
- Data Model must be normalized
- For example, tables that are missing primary keys cannot be imported into the Logic tier
- No class inheritance for Screens
- This leads to a great deal of “copy-paste” code
- Customization of application appearance requires creation of custom Shell and/or Theme Extensions
- Even some as “simple” as adding a logo to the application turned out to be not so simple
- Unit testing is not supported out of the box
To wrap things up, we discussed the overall impressions of LightSwitch. It seems ideal for straightforward data management applications, not only for LOB apps but also for lighter-weight “utility” applications. For example, some of the developers began contemplating the use of LightSwitch to provide a quick and easy interface into databases that normally require “manual” management. LightSwitch offers extensibility and the means to create custom business logic by writing VB or C# code; however, the trade-off is the need to have some technical expertise to create any type of practical application, and to navigate configuration and deployment aspects. Another catch is the necessity to have a sound data model – the automated features of data modeling in LightSwitch are only possible with a normalized data model with primary and foreign keys in place. At the end of the day, LightSwitch is a powerful framework that can stand up applications quickly as long as the proper conditions are met and the proper expertise is driving the effort.