This project is read-only.

Getting Started

Overview

Labs Framework is currently designed to support two primary use-cases:
  1. Unit Experimentation
  2. Hands-On Labs
This document will get you started writing labs for both use cases, simultaneously.

Labs can be extremely useful whether you're an experienced developer or not. The Labs Framework is not intended to be a mere learning tool for novice developers, but instead provides tools that facilitate active cross-platform experimentation throughout the entire software development life-cycle of an application, library or website.

When developing a project of any size, and for any platform, writing labs is the best and quickest way to learn about the behavior of your own code, other developers' code, third-party libraries on which your application depends, the .NET Framework itself, Silverlight and Windows Phone class libraries, the behavior of programming languages such as C#, Visual Basic and F#, web services such as those provided by Twitter and Facebook, and many other subjects.

Here are just some of the benefits of writing labs:
  • Experiment immediately, without having to build a custom user interface to load and run experiments.
  • Experiment without wasting any time organizing temporary throw-away tests, or without even having to decide whether tests should be throw-away in the first place: just persist everything.
  • Experiment without affecting your pristine production code. Don't intermix experiments with production code (sometimes indistinguishably) while developing or debugging, only to comment the code out instead of deleting it, "in case I'll need it again". Instead, create distinct labs in a separate lab project and evolve your production code based on the results of your experiments.
  • Persist experiments in conveniently organized projects within the same solution as your main projects, and in the same source control system.
  • Build applications that can serve as deployable diagnostic tools for gathering valuable information about your applications in staging and production environments.
  • Build applications for end users that contain a set of hands-on labs, which provide official examples and best practices for consuming your product's APIs and services.

Kinds of Labs

There are two kinds of labs that you can create:
  1. GUI Lab: Allows you to create your own graphical user interface (GUI) using XAML.
  2. Console Lab: A GUI Lab that provides a standard GUI for you based on the target platform.
Both kinds of labs allow simple text-based input and output via a cross-platform API. GUI labs also allow you to specify your own graphical user interface (GUI) in XAML. Console labs are easy to create because they are very similar to standard desktop console applications, even having a Main method as an entry point. Console labs also provide additional features for Method Experiments.

When choosing which kind of lab to create, simply consider whether you need a custom GUI. For example, if you're experimenting with a WPF reporting control, then create a GUI lab. Alternatively, if text-based input and output is sufficient, then create a console lab on whichever platform you'd like.

Lab projects build applications with an embedded console user interface for all platforms. The Labs Framework provides a cross-platform API for acquiring user input and tracing text as output. This API is designed to work exactly the same way on all of the supported platforms, which enables you to write a lab once and then link its source files into projects that target other platforms. For example, you can create a lab with a XAML user interface in a WPF project and link that XAML file and its code-behind file into a Silverlight project without any modifications (assuming that you only use XAML and any additional APIs that are supported on both platforms).

The following screen shot shows the labs application for Rxx. The currently selected lab is a console lab. The GUI containing the lab's information and a start button is automatically generated by the Labs Framework. The embedded console can be seen in the lower left-hand corner of the UI.

RxxLabsStockTicker.png
Example: Rxx Labs application based on the Labs (WPF Application) project template.

Creating Your First Lab

To start writing labs you must first create a new lab project. A lab project builds an application for a particular platform, in a particular language.

Labs Framework installs lab project templates for Visual Studio if it detects it on your system (see Release Notes for details). You'll find the lab project templates in the New Project dialog under the Labs category, for each of the supported languages.

CSharpNewProjectDialog.png
New Project dialog showing C# lab project templates.

For example, you can create a WPF lab application in C#, Visual Basic or F# by creating a new Labs (WPF Application) project. Which kind of lab project you'll need depends upon what kind of experiments you'll be creating in your labs.

Here are some recommendations:
  • If you're creating a lab project to experiment with a particular platform, then choose the lab project template for that platform, in your preferred language. For example, if you're a C# developer and you'd like to experiment with Silverlight controls, then choose Labs (Silverlight Application) in C#.
  • If you're creating a lab project to experiment with a particular language, such as investigating the behavior of iterator blocks in Visual Basic, then choose Labs (WPF Application) in Visual Basic.
    • Labs (WPF Application) is recommended because it can provide the richest user experience, even if you're only planning to create console labs.
  • Choose a lab project that targets the same platform and language as the application or library that you're developing. For example, if you're adding a lab project to a solution that contains a WPF Application project in C#, then choose Labs (WPF Application) in C#. This will allow you to easily experiment on UI-dependent classes, such as custom controls or view models. It also makes it easy to link code files for experimentation.
  • WinForms lab templates are not currently provided; however, you can use the WindowsFormsHost control inside of a WPF lab to achieve similar results.
  • If you plan on building hands-on lab applications as learning tools for end users, then consider adding lab projects in multiple languages: C#, Visual Basic and F#.
    • The Labs Framework does not yet convert labs into multiple languages automatically, but this feature is currently being researched. For now, if you want to target multiple languages, then you must create projects for each language and duplicate the labs yourself.
  • If you're going to be writing general performance benchmarking experiments, then consider choosing Labs (Console Application).
    • You can use the TraceTime and ResetTime methods to output time stamps on any platform. The Console and WPF project templates implement these methods internally using an instance of the Stopwatch class.
    • WPF projects are not recommended for performance benchmarking due to the potential of the GUI's overhead interfering with the results, unless of course your goal is to benchmark XAML or WPF controls.

Next Steps

Walkthroughs: Coming Soon

Last edited Sep 7, 2012 at 10:41 PM by davedev, version 10

Comments

No comments yet.