This article is provided by MVP Ridi Ferdiana. Microsoft is so thankful that MVPs who proactively share their professional experience with other users. The article would be posted on MVP's website or blog later.
Many developer said that LightSwitch is only good for building casual and simple CRUD Application. Developers sometime feel distress when they are building more advanced scenario rather than a simple CRUD application.
The first impression happen since LightSwitch has a different programming model than the casual programming model using Windows Form, WPF, or even ASP.NET. Lightswitch using data driven programming model that provides developer a different point of view to build an application. Therefore, developer needs learn and know when a LightSwitch can solve thier development problem.
This article will provide several tips to adopt LightSwitch programming model using Application Lifecycle Management (ALM) approach.
ALM is an approach how to create an application with software lifecycle in mind. ALM combines a strategy build better software with better tools, better method, and better process to gain better software quality. ALM usually adopted in large scale or enterprise application using Visual Studio Ultimate 2012 and TFS. However, this time we will guide you how to adopt ALM discipline in LightSwitch Application Development. LightSwitch is a rapid development tool to build web or desktop data driven application. In 2012, LightSwitch is integrated in Visual Studio 2012 Ultimate or higher
This article will combine the ALM with Rapid development model using data driven development in LightSwitch. In general, ALM approach has three major steps which are Define, Develop, and Operate. We will discuss each step and relate it with the LightSwitch Development.
Step 1 - Define The Data
LightSwitch using data driven model so the first step is to define the data. LightSwitch using Data Driven model so what we need is to design several data structure which are
Designing and Creating Table. This action is the most vital in this step. The selection of datatype, naming convention, and the data length is three main aspects that need to be handled in this step. Table normalization will help cut development time.
Creating the computed property for each table. Computed property variables will be valuable for any computing purposes.
Creating the screen. Screen is composed logically in LightSwitch. Defining the screen discuss how the data will be shown. Be sure to format the data using forrmatting properties, change the display name properties, and hide the unused data.
Fig 1. Defining data is not only about selecting a data type but also displaying the correct data to the user
Step 2 - Develop The Application
Creating a screen from a Wizard on Visual Studio is not a silver bullet. In many real application, sometime we need to build the screen from the beginning. However, the development consists four main activities which are:
Composing and editing the screen to suit your application need. We should learn a lot about layouting. For example, column layout can be combined with row layout to provide list (master) and detail records. Tab layout will be great to be used when we want to show the relation or dependency between table, Each layout has a purpose, so be sure to learn each layout for better user experience.
Developing the codes. In LightSwitch, we can do a code in Computed Property or write a code in screen. Computed property can reach our data entity while write code will help us to access the screen data. Combining both codes will help to access anything in the application.
Runtime query. In LightSwitch we can edit directly the entity query by using edit mode. In this case, we can access and edit the query on the fly without go back to add query on the table. I suggest to use runtime query when you need a direct interaction with the screen data such as filtering using a control, or creating custom search through parameter.
Building RIA Services. Lightswitch is a combination between Silverlight and RIA Services. Therefore, you can customize LightSwitch further using RIA services. The good news you can host the RIA services within your LightSwitch application. RIA Services can be used for advanced application scenario such as create a custom report, consuming third party services, or even building powerfull business logic.
Fig 2. LightSwitch is a combination between Silverlight and RIA Services Fortunately, LightSwitch provide you a bulletproof when you do code changes, table changes, and others. You have to worry when you changes a table will break the data binding. The screen still work as usual and adopt the changes that you made. You can learn more the development techniques in LightSwitch Blog.
Step 3 - Operate the Application
When building a LightSwitch, you can integrate the versioning system and engineering process with the ALM package in TFS and Visual Studio Ultimate. If you already done with it, your agenda is delivering the application to the customer. Several consideration when you distribute your application are:
Visiting your client and see how you will deploy your LightSwitch application. You can develop your Lightswitch in 2 tier deployment, three tier, and Microsoft Azure deployment. Two-tire is a good choice if you want your customer feel a LightSwitch app just like desktop application so that it can interact directly with Microsoft Office Application and others local resources. Three tier is great way to deploy your application in self hosted Web application. Azure choice is great when we need high performance and elastic LightSwitch application.
reparing the dependency. Your Lightswitch need at least a SQL Server 2008 R2 and Silverlight 5 (for Lightswitch 2012). Be sure to bring that to your client so that they can get better installation experience. Publishing option provide you once click installation, but please be aware that the dependency component should be downloaded and sometimes is not good to see your 20 MB LightSwitch application has 600 MB dependency. Therefore, this article encourage you to have master installation for SQL Server 2008/2012 and Silverlight 5.
Database deployment choice. When you publish your Lightswitch application you have two choices in database deployment which are using SQL script or direct to the database. If you already know or believe that your user doesn't have a SQL Server, the backup-restore can work great. Just choose direct to the database and backup the deployment database and restore in your client database.
Fig 3. Publishing Option in LightSwitch
ALM is not just about tools. ALM also discuss about the discipline when we build an application. This article shows you that a LightSwitch can be a good choice to build Line of Business Application in a rapid way. This article focuses in adopting process through Define, Develop, and Operate a LightSwitch application. This article also discuss what you need to care in each step.
MICROSOFT CORPORATION AND/OR ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY, RELIABILITY, OR ACCURACY OF THE INFORMATION AND RELATED GRAPHICS CONTAINED HEREIN. ALL SUCH INFORMATION AND RELATED GRAPHICS ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT AND/OR ITS RESPECTIVE SUPPLIERS HEREBY DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THIS INFORMATION AND RELATED GRAPHICS, INCLUDING ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, WORKMANLIKE EFFORT, TITLE AND NON-INFRINGEMENT. YOU SPECIFICALLY AGREE THAT IN NO EVENT SHALL MICROSOFT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, PUNITIVE, INCIDENTAL, SPECIAL, CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF USE, DATA OR PROFITS, ARISING OUT OF OR IN ANY WAY CONNECTED WITH THE USE OF OR INABILITY TO USE THE INFORMATION AND RELATED GRAPHICS CONTAINED HEREIN, WHETHER BASED ON CONTRACT, TORT, NEGLIGENCE, STRICT LIABILITY OR OTHERWISE, EVEN IF MICROSOFT OR ANY OF ITS SUPPLIERS HAS BEEN ADVISED OF THE POSSIBILITY OF DAMAGES.