grasping the lightswitch paradigm

39
Grasping The LightSwitch Paradigm (The Taming of the Tool) Level: Intermediate October 20, 2011 Andrew Brust Andrew Brust CEO and Founder Blue Badge Insights

Upload: andrew-brust

Post on 25-Dec-2014

1.838 views

Category:

Technology


3 download

DESCRIPTION

From Visual Studio Live! Redmond presentation "Grasping The LightSwitch Paradigm (The Taming of the Tool)"

TRANSCRIPT

Page 1: Grasping The LightSwitch Paradigm

Grasping The LightSwitchParadigm

(The Taming of the Tool)

Grasping The LightSwitchParadigm

(The Taming of the Tool)

Level: Intermediate

October 20, 2011

Andrew BrustAndrew BrustCEO and Founder

Blue Badge Insights

Page 2: Grasping The LightSwitch Paradigm

• CEO and Founder, Blue Badge Insights• Member, Microsoft BI Partner Advisory Council• Microsoft Regional Director, MVP• Co-chair VSLive! and over 16 years as a speaker• Founder, Microsoft BI User Group of NYC

– http://www.msbinyc.com

• Co-moderator, NYC .NET Developers Group• http://www.nycdotnetdev.com

• “Redmond Review” columnist for Visual Studio Magazine and Redmond Developer News

• brustblog.com, Twitter: @andrewbrust

Meet AndrewMeet Andrew

Page 3: Grasping The LightSwitch Paradigm

The LightSwitch White PapersThe LightSwitch White Papers

• Go to microsoft.com/lightswitch and click on white paper links

• Or use these direct, shortened URLs:• http://bit.ly/vslsoverview

• http://bit.ly/vslsfirstapp

• http://bit.ly/vslsdata

• http://bit.ly/vslsui

• http://bit.ly/vslsextensions

• Get these slides on SlideShare

Page 4: Grasping The LightSwitch Paradigm

AgendaAgenda

• Intro• Basic Skills• Advanced Techniques

Page 5: Grasping The LightSwitch Paradigm

INTROINTRO

Page 6: Grasping The LightSwitch Paradigm

What is LightSwitch?What is LightSwitch?

• A streamlined, optimized system for building line of business applications

• A SKU of Visual Studio – introduces new C#/VB project types

• Built on the existing MS stack• Uses Silverlight on the front-end, leverages IIS

• Uses Entity Framework, RIA Services and other core .NET components too

• Uses SQL Server if maintaining its own database•Can also connect to existing SQL Server and other databases

• Can Read/Write SharePoint 2010 Lists

Page 7: Grasping The LightSwitch Paradigm

Core ConceptsCore Concepts• Data Sources

• Entities/Tables and Properties/Columns

• Screens• Template-based, but full control over design• Groups and controls; lots of nesting

• Access Control• Built-in role-based security

• Code• Computed data properties• Full event model

• Extensions• Controls and more

Page 8: Grasping The LightSwitch Paradigm

What’s Different?What’s Different?

• Model-driven• No forms package. Instead, you design

screens schematically.• Generic structures with specific implementations

• Business Types, not just data types• Built-in export to Excel• No requirement to code…and yet plenty of

opportunity to do so

Page 9: Grasping The LightSwitch Paradigm

What Else is Different?What Else is Different?

• Many things are inferred:• Screen scenarios

• Screen region layout

• Control types, and read-only equivalents

• Invoking your default detail screen when Summary Property clicked

• Impact of access control on UI

• The context-sensitive role of buttons (Command Bars)

• Very cloud-capable• Works with Windows Azure and/or SQL Azure

• Might have the best deployment story in the stack

Page 10: Grasping The LightSwitch Paradigm

BASIC SKILLSBASIC SKILLS

Page 11: Grasping The LightSwitch Paradigm

The IDE: DataThe IDE: Data

Toolbar

Can have multiple data sources

Our entity, in the singular

Our entity set, pluralized

Entity type becomes field type

Propertieswindow

Page 12: Grasping The LightSwitch Paradigm

Business TypesBusiness Types

• Imply UI, formatting, data validation• Built-In:

• Phone

• Email

• Money

• Others can be added through extensions• Business Types can be very useful when

connecting to an existing database• Just change underlying data type to business type in

the data designer

Page 13: Grasping The LightSwitch Paradigm

The IDE: ScreensThe IDE: Screens Members area

Query and its properties. Can drag properties onto visual tree

Methods (editable)

Toolbar

Layout Group

Controls.Icons represent control types. Click drop-down arrow to change.

Add more elements

Screen Name (editable)

Command bars

Page 14: Grasping The LightSwitch Paradigm

Screen TemplatesScreen Templates

• Details• Editable Grid• List and Details• New Data• Search Data

Page 15: Grasping The LightSwitch Paradigm

Adding an EntityAdding an EntityAnd Building a ScreenAnd Building a Screen

Page 16: Grasping The LightSwitch Paradigm

What You Get For FreeWhat You Get For FreeRibbon

Menu

Tabbed layout

Toolbar

Search box

Data Navigation

Design while executing!

Data Validation UI

Page 17: Grasping The LightSwitch Paradigm

Design ModeDesign Mode

Commit or roll back the changes andyou’re done!

This is an actual live copy of your app.

You can even do data entry and click controls

Visual tree and Properties window for you to make live changes interactively

Page 18: Grasping The LightSwitch Paradigm

NavigationNavigation

• The side bar menu is generated and updated automatically, as you add screens

• You can customize it though:• Change order of items

• Add, remove or rename screens and groups

• Show/hide screens programmatically•Using the CanRun event

Page 19: Grasping The LightSwitch Paradigm

Pop-upsPop-ups

• Screens for creating and editing individual records are generated on-the-fly by LightSwitch

• See them by clicking the Edit or Add New buttons on the toolbar

• You can replace these generated screens with your own…

Page 20: Grasping The LightSwitch Paradigm

Parameterization and Loading Parameterization and Loading Screens Through CodeScreens Through Code

• You can design your own screens for creating or editing single records & use them in place of the generated pop-up screens• Use New Data and Details screen templates

• For New Data screen:• You must put code in Add button’s Execute event

handler:•this.Application.ShowScreenName();

• For Details screen:• Set the “Use as Default Details Screen” option in the

Add New Screen dialog box.

Page 21: Grasping The LightSwitch Paradigm

Navigation, PopupsNavigation, PopupsButtons, Loading ScreensButtons, Loading Screens

Page 22: Grasping The LightSwitch Paradigm

Data ValidationData Validation

• You can easily add your own Validation in code.• Click Custom Validation in the Properties window,

• Put in conditional logic and pass a string to the results.AddPropertyError method.

• Use AddEntityError method for server-side validation when saving changes

• Or AddPropertyResult and AddEntityResult for info and warning messages

• Validation goes in data model, and flows into all screens. Even generated ones.

Page 23: Grasping The LightSwitch Paradigm

The Event ModelThe Event Model

• Types: General, Access Control• Objects:

• Queries

• Data Sources

• Tables

• Properties (Fields), for validation

• Computed fields, for computation

• Screens

• Buttons (Execute and CanExecute)

• Menu items (CanRun event hook)

Page 24: Grasping The LightSwitch Paradigm

Data ValidationData Validation

Page 25: Grasping The LightSwitch Paradigm

Buttons and Command BarsButtons and Command Bars

• Have Execute and CanExecute events• Buttons are children of Command Bars

and Command Bars are everywhere• Ribbon, toolbar, collection controls, rows within

collection controls

• Simple controls too…just right click and then select Add Button…

• So buttons can go just about anywhere• Lots of predefined buttons:

• AddNew, AddAndEditNew, EditSelected, DeleteSelected, RemoveSelected, Refresh

Page 26: Grasping The LightSwitch Paradigm

Ribbon ButtonsRibbon Buttons

Page 27: Grasping The LightSwitch Paradigm

ADVANCED TECHNIQUESADVANCED TECHNIQUES

Page 28: Grasping The LightSwitch Paradigm

QueriesQueries

• All screens’ data are fetched through queries

• You can edit these and add:• Filter

• Sort

• Parameter

• Group

• Also• Support paging, sorting, search

• Set page size

Page 29: Grasping The LightSwitch Paradigm

LayoutLayout

• Screen layout is based on layout groups:• Rows, Columns, Table, Tabs, Modal Window

• These are nest-able• Scroll bars, splitter bars and relative sizing

of screen region controllable through:• Scroll Enabled, Alignment, Min/Max Height/Width, Is

Row/Column Resizable properties provide

Page 30: Grasping The LightSwitch Paradigm

Queries and LayoutQueries and Layout

Page 31: Grasping The LightSwitch Paradigm

SearchSearch

• Built in to List and Data Grid controls• Implemented automatically on all string

fields• Can be disabled at the property or entity

level using Is Searchable property• Support search property on screen query

• Search-ability defined in the data model; respected by all screens• Even the generated ones

• Search is rather brute force• So don’t allow too many fields to be searchable

Page 32: Grasping The LightSwitch Paradigm

Access ControlAccess Control

• Optional Windows- or forms-based authentication

• You define:• Groups, and their membership

• Named permissions, which you check programmatically in code

• Access control event hooks available for:• Whether visible:

•Screens in the navigation menu•Buttons

• Whether editable:•Properties/fields,

Page 33: Grasping The LightSwitch Paradigm

Access ControlAccess Control

Page 34: Grasping The LightSwitch Paradigm

ExtensionsExtensions

• Controls• Screen Templates• Custom Data Sources• Business Types• Themes• Shells

Page 35: Grasping The LightSwitch Paradigm

Themes and ShellsThemes and Shells

Page 36: Grasping The LightSwitch Paradigm

ExtensionsExtensions

Page 37: Grasping The LightSwitch Paradigm

DeploymentDeployment

• Client is in-browser or desktop• Middle tier on PC, server or Azure• Deploy your database, or use existing db• Work in SQL Server user instance mode +

Express during dev, but deploy to SQL Server or SQL Azure.• Or stay in Express!

Page 38: Grasping The LightSwitch Paradigm

Platform Shifts and Market AnalysisPlatform Shifts and Market Analysis

• Most LOB app tools give high productivity but low customization. LS is different.

• Most are either frameworks or code generators. LS is different.

• LS is model-driven. It renders Silverlight code/XAML today. What about tomorrow?

Page 39: Grasping The LightSwitch Paradigm

Thank youThank you

[email protected]• @andrewbrust on twitter• Want to get the free “Redmond Roundup

Plus?”• Text “bluebadge” to 22828