Introduction

Microsoft Surface Touch TableI was hearing about Microsoft Surface far last few months, but did not get much information. Recently, I saw a post "PDC 2008" by Robert Levy and Brad Carpenter having a video session demonstrating the capabilities of Microsoft Session. The demonstrate the unique attributes of Microsoft Surface computing, with a dive into vision-based object recognition and core controls like ScatterView, and how the Surface SDK aligns with the multi-touch developer roadmap for Windows 7 and WPF. The software giant has built a new touch screen computer — a coffee table that will change the world. Forget the keyboard and mouse, the next generation of computer interfaces will be NUI (Natural User Interface) which uses natural motions, hand gesture and real world physical objects. The surface is capable of object recognition, object/finger orientation recognition and tracking, and is multi-touch and is multi-user. Users can interact with the machine by touching or dragging their fingertips and objects such as paintbrushes across the screen, or by placing and moving placed objects. This paradigm of interaction with computers is known as a natural user interface (NUI). Surface has been optimized to respond to 52 touches at a time.

Microsoft Surface applications can be written in Windows Presentation Foundation (WPF) and .Net language like C# or VB.Net. It is nicely integrated with Visual Studio 2008 following the same pattern of programming paradigms the .Net developers are used to. However it has custom WPF controls to allow programming for the unique interface of Surface. Developers already proficient in WPF can utilize the SDK to write Surface apps.

Object RecognitionMulti User Application

Microsoft Surface SDK 1.0

Right now, Microsoft Surface SDK is not available for public. It has been distributed only to some of the Microsoft partners. I am eagerly waiting to get my hands on the SDK once it is launched. Since, I have already worked with SilverLight and WPF, I think, it would be quite easy to pick Microsoft Surface. This is true for every developer worked on WPF and used XAML. However, there is a small catch ... Working for surface would require more creativity and unlearning the GUI which we are used to. The new interface requires us to think about the UI from entirely a new perspective ... a 360 degree multi-touch perspective.

I am sure the developers deep in love with .NET programming and having high respect for Microsoft Technologies, would be very excited after seeing the video session of PDC 2008. The features demonstrated, and the ease of programming together with seamless process of learning would make you sit up staright on your seat, open Google to find out whether you can get hold of Microsoft Surface SDK. Hmm! As you might be thinking after watching the video, whether you need the touch screen device which costs $10K-15K, to practice Microsoft Surface? The answer is No! Microsoft has a simulator for Surface which would allow you to deploy and play around with your surface code. Unfortunately, that too is not available to public right now. So you might have to wait a little more, until of course you are working for the company included in the Microsoft's Partner list, currently allowed to download and use Microsoft Surface SDK and Simulator.

It Is Not Just Another Glorified And Hyped Touch Screen Computer

Many had a wrong impression about Microsoft Surface thinking it to be another glorified and hyped touch screen computer. The touch screen computers enable users to do away with keyboard and mouse. They can navigate the menu by touching various options to reach a logical end of viewing data or printing. And there ends the comparison. Microsoft Surface device also known as Microsoft Tabletop can do many more things, which you might think are not possible!

The three main components that differentiates it from a regular Touch-Screen device, Direct interaction, Multi-Touch Contact and Object Recognition.

 Object Recognition
  • Multi-touch contact: User need not use only one finger to manage digital data. If user dips five fingers in five different colors in the on screen paint palette and draws five lines with five fingers, you get five lines with five colors . . .
  • Direct interaction: Facility to manage digital information with hand gestures and touch instead on mouse and keyboard.
  • Object Recognition: This technology allows non-digital objects to be used as input devices. This means that the input source does not necessarily have to be digital in form.

This Is The Future

Companies are putting in millions of dollar in research for NUI. There is a nice video "TED: Sixth Sense" from Pattie Maes' lab at MIT, spearheaded by Pranav Mistry. It's a wearable device with a projector that paves the way for profound interaction with our environment. It demonstrates a device which responds to natural gestures of hand which is read by a camera. The UI is developed and projected using a small projector fitted in the same device. If you guys have seen movies like "Minority Report", see these technologies nearing to the imaginations.

The NUI immensely increases interaction with digital contents in a more simplified manner. One does not need to practice with mouse. It won't be a single user interface anymore. Two users can open two different menus at the same time .... (Right now your application would open one menu at a time). A 360 degree interaction, with each person using the same application independently. Surely, we need to think and see the UI very differently now and you are bound only by your imaginations.

So friend's start unlearning the GUI you are accustomed to, and buckle your seat belts for the next gen -- NUI.

Manish


 
  Posted in:  .Net Thoughts



Introduction

Rich media advertisement is a buzz word today. Organizations are spending a huge amount to move out from a traditional banner advertisement approach, booklets and television to a more effective tactics where they can reach out to a wider mass through internet. Rich media advertisement forms a basis of wider coverage at less cost together with a wonderful user experience.

Macromedia Flash, already provides a state-of-art solution for it. However, it is mostly tied to its proprietary engine for shock wave and interaction. Flash are further, required to be embedded as a compiled unit. Besides all, it requires you to learn Flash an extra skill.

Something I like about silverlight is that it supports XAML based platform with language support for programming. EXtensible Application Markup Language (XAML) which is pronounced as Zamel, is used to define your canvas and storyboard, which are easy to manipulate at runtime using languages like C# or VB.Net. These are further deployed as a compressed unit rather than a compiled unit. This is no doubt a step further than what Flash has achieved. One drawback, however, is, adoption among wide number of serious users. I don't see it as a big drawback as long as Microsoft is serious about this product.

Silverlight Kickstart

My silverlight development environment includes VS2008 with SP1, Framework 3.5, Silverlight SDK and Microsoft Expression Encoder. I would not get into these details for the scope of this article. You may refer to Getting Started article for Silverlight, to setup your development environment. Further, if you donot want to get into the intrecacies of XAML, then you might also require Microsoft Expression Blend.

WMV for streaming Video with Silverlight

Silverlight supports WMV format for videos. Using Microsoft Expression Encoder these WMV files can be encoded to have markers on their timelines. These markers can be used by siliverlight for interaction. The markers are simply names given to a time in the video's timeline. Silverlight raises MarkerReached event (if registered) when a marker is reached while playing the video. This forms the basis of interaction between silverlight and streaming videos. There is a nice video tutorial explaining, how to add a marker using Microsoft Expression Encoder.

Silverlight UI

XAML in Silverlight allows you to do a lot of stuffs with the UI using its declarative tags. Few, real interesting things you can do, without any extra skill required, includes, drawing a curve, masking, controlling opacity, define animation ... all through XML like declarative tags ... Wow!. In this tutorial, I will be showing you how to create an interactive overlay on a running video. For this, I have a video with three markers defined on it (using Encoder). Now let us first examine the UI.

The UI

Few things, I would like to explain here, before we proceed to next step, since they have been referred ahead. Take a sneak into the code for things, I have marked in bold. Notice that:

  • Movie name is "MainMovieStream" defined as an attribute "x:Name".
  • The "MarkerReached" event is registered for the movie as "MainMovieStream_MarkerReached".
  • Canvas with a name "TopOverlay" which is placed -325 pixels on the left.
  • "TopOverlay" canvas has an inner element "TopText" with an event "MouseLeftButtonDown" handled by "TopText_MouseLeftButtonDown" function
  • A Canvas "BottomOverlay" is defined in a similar faishon except its top is "131".
Silverlight Story Board

Take a sneak into the code for things, I have marked in bold. Notice that:

  • Storyboard "TopOverlayIn" targets the canvas "TopOverlay".
  • The "Storyboard.TargetProperty" tells us that the "Left" property has to be changed.
  • The "SplineDoubleKeyFrame" defines, that after every 1 sec the target property moves near to the "Value=0". Hence, the Canvas.Left moves from -325 to 0
  • The Storyboard "TopOverlayOut" does exactly the opposite of "TopOverlayIn".

MediaControl.xaml

The Storyboards are treated as Canvas resource which would be used when required. Let us see the complete XAML for our tutorial.

C# Code

When you add a XAML file into your solution, visual studio responds with adding an associated code behind file for the XAML. Besides, you would also find a App.xaml and its code behind file with same name. While doing any development on Silverlight, most of the time you would ask "How can I pass values to Silverlight application at runtime" or in another way "How can I make it as a component to be used in other projects?". This is done through parameter passing at the time of initialization.

App.xaml.cs

Let us sneak into App.xaml.cs file where the necessary changes has been made for the same. The only changes required in the App.xaml.cs file are:

  • Declare an "IDictionary" object for paramters as a class variable

    public partial class App : Application {

        privateIDictionary<string, string> initParams;


    ...

  • Initialize it in the "Application_Startup"

    private void Application_Startup(object sender, StartupEventArgs e)

    {

        this.RootVisual = new MediaControl();

        InitParams = e.InitParams;

    }

MediaControl.xaml.cs

Now let us sneak into the MediaControl.xaml.cs file to see how we collect the parameters and how we handle the animation and events.

In the code above we get the reference of the Silverlight application using "Application.Current as App" (marked in bold) in the "Page_Loaded" event. Once we have got the handle of the application we can access its public properties. In this case the parameters. As you can see, I am iterating through each parameters and storing the values into my local variables. The marker parameters here contains the storyboard names that we would see in the next section. Also notice, how I am handling the "MarkerReached" event and the "MouseLeftButtonDown" events. The actions are self explanatory here.

Embedding Silverlight RichMediaAd Control

Once you have done with this code, your control is ready to be used. When you compile a Silverlight application, you would notice that it generates a RichMediaAd.xap file under ClientBin folder of your web application which references the Silverlight application. This .xap file is nothing but a compressed file containing your application manifest and the DLL. You can use a simple un-zip command to view the files inside. In the page

Now let us see the code where we embed this Silverlight control we made.

Once you have embedded the XAP file. It is ready to run. Notice, that I am sending all necessary parameters at runtime, including the media I want to use.

Happy Silverlight Programming !!


 
  Posted in:  .Net



Skillz is my current project, where I have been involved for over 6 months now. The core part of Skillz is to do a Talent Management while additionally it supports performance management.

This is a breed of very interesting project for me with lot of grilling, learning and testing one’s self Talent Quotient. We faced lots of challenges and kept working our ways through to achieve what we initially set out to achieve. With time the product evolved as we developed a stronger understanding of the requirements across industries and formed our own opinions on how these should be addressed. It has been a real interesting journey, delving into unknowns, digging out answers and putting it into implementations. I feel like sharing some of my experiences with Skillz here for benefit of all developers and architects, trying to decipher the same unknowns.

The Challenges

The First Challenge

On this project the biggest challenge was the need to correctly understand what Talent Management is and what is really expected of a Talent Management application. While researching, I found many articles and blogs explaining Talent management.

The problem with the information and articles out there is that it creates a fair amount of confusion between talent management and performance management. Both are fairly inter linked. So much so that at times it becomes hard to differentiate between the two. It is like you have been asked to differentiate between the words [opinion, attitude, belief and faith]. We compared few products currently available. Some of them were far from catering the actual need of talent management, while others offered a wide range of tools most of which, would be of no use to most organizations.

Only some were quite near to what was expected. There are quiet good articles out there on the web, worth mentioning here. Tony DiRomualdo in one of his article defines seven management practices that matters. He is in a view that for becoming a well rounded talent requires continuous learning and development of knowledge and skills. One of the articles published by Nasscom and written by Prof. Peter Cappelli, Center for Human Resources, University of Pennsylvania, explains the more subtle difference between Performance and Talent Management titled Talent Management is a business problem.

The Second Challenge

Another, challenge was about architecting Skillz, such that, it fits into the requirement posed by different industries. A skill itself varies hugely from industry to industry. To explain this, try comparing some common skills for a Doctor, Bank Manager and a Software Developer. Specializations for a doctor (like MD, MBBS etc), matters much more, than it does for a Bank Manager or a Software Developer. Similarly, Global Client Exposures for a Software Developer is more important than it is for a bank manager or for that matter, a doctor. Accounting exposures stands more important for a bank manager. Thus a common skill like education or experience needs different design for different industry/practices. This is because individual professions and verticals vary hugely from each other. This leads to a fresh challenge; the very fundamental nomenclatures used in the application, changes completely depending on which vertical the system is deployed in.  A classic example for this is the entity ‘user’. For every vertical where skillz is implemented, the very meaning and attributes for a ‘user’ changes drastically. Attributes like medical registration number and Medical Specializations make more sense for doctors than they do for developer or a bank manager. Rank/Grade does not imply to a doctor or a software developer.

Further, aspects like Security, Reporting, Usability together with the nature of Talent Management, additively, pushed the design of Skillz to a level of challenge.

Solving the challenges

Solving First Challenge

The first challenge took the major portion of our time; which was spent in   discovering the true nature and taste of Talent Management vis-a-vis differentiating it with performance. Talent Management is all about getting the right people with right skills into the right job by measuring the following quotients:

  1. Learning Quotient (LQ): Measures how an individual learns and improves
  2. Conceptual Quotient (CQ): Measures the ability of thought process in solving a problem.
  3. Relationship Quotient (RQ): Measures how an individual behaves in a group
  4. Action Quotient (AQ): Measures the individual as a team member by his actions.

For an individual the Talent Quotient (TQ) = (LQ+CQ+RQ+AQ) * Values.

Well, how do we measure it? I am sure our HR would be highly interested and can add another hundred paragraphs here about these quotients, process of measuring it, appraisal, questionnaires and many more.

Different companies have adopted different techniques to measure the TQ. The most common techniques  used are appraisals, interviews, trainings and feedbacks. But, seldom people understand the continuous nature and difference between the talent management and performance.

Now the most interesting part, Talent Management is not only about measuring TQ. It is about Identifying TQ, Acquiring TQ, measuring TQ, mentoring TQ and Retention of TQ. So where does Performance comes in? The answer is:  

TALENT MANAGEMENT + PERFORMANCE MANAGEMENT = PERFORMANCE

Put simply, tracking ‘performance’ is much more than most people think of it. It doesn’t start and end with performance management. Talent management which involves acquiring, goal setting, training, mentoring and retaining individuals also forms a huge part of tracking their performance.

Building a system which allows administrators and implementers to capture talent management and beyond was our initial design goal for skillz and after months of hard work, eating our own dog food and months of testing with a couple of beta customers, we believe we’ve come decently close to achieving it.

This solves the first challenge!

Solving Second Challenge

The second challenge was to design a system which fits into various industries catering to their unique needs. We decided to have a core system and extend it according to the organizational need. User, Skills, Activities, Trainings are entities within the system which are simple, flexible and easy to extend.

Security within individual organizations can be easily configured and tweaked by individual organizational administrators. Skillz is designed to be offered as a service (SaaS). For us this means easier deployments for all our customers and for our customers it means easy updates to newer versions as we continue to work on newer versions and add new functionality.

Skillz is a result of months of hard work, countless brainstorming sessions and a lot of thought that has gone into areas like security, reporting and usability. We’ve given special attention to extendibility so that customers can tweak skillz to fit their requirements.
 
The following diagram defines some interesting prepositions that are uniquely available in Skillz.

Skillz Features

Even though we’ve been using it within small teams @ eFORCE and with some of our beta customers, the official launch date for a public beta will be announced soon.

The entire team is very excited about its acceptance, performance and criticism in the world of PERFORMANCE. This release for me is the starting of the race which we struggled to qualify and it took us almost one full year.

I hope this article is helpful for those working in similar areas. I would keep posting more about Skillz as and when time permits.

Thanks,
Manish


 
  Posted in:  Skillz



I have seen many programmers and senior programmers showing their prowess in implementing and justifying a design pattern implementation. Before doing so one should ask a very simple and honest question to self, “Do I fully understand it?” I am sure many of you, would say off course, what’s the big deal. Now look at your decision once more by answering the following questions:

  1. Does your team, working with you also understand the pattern correctly? Are they comfortable with its implementation?
  2. Would you be there till the project reaches its logical end or do you have at least one successor who would be there and understands the pattern correctly?
  3. Does it require other members to follow a set of rules while coding?
  4. Do you understand “What it solves” OR “How it solves”?
  5. Are you thinking about scalability or maintainability?

Thoughts on Question 1

Most of the serious projects require a team of developers working together on different modules. If they do not understand the pattern, it is more likely, that you would encounter chaotic and unorganized codes. The common evils are repetition of codes which explains the lack of understanding the design pattern, code tweaking to override design pattern, hard coded lines, code spaghetti and more. Wow these codes could kill.

Thoughts on Question 2

Something that remains constant in software development is “Change”. It is inevitable and the requirement itself keeps changing. No doubt the design patterns are there to help, but when it requires any change, who’s going to do it? In case it falls in a wrong hand, it would shit all over your effort and logic.

Thoughts on Question 3

If your answer to this question is YES, then you must ensure you understand question one, and keep a constant vigil or do a knowledge sharing for your team to bring them on the same page, else the errors and problem can pretty quickly escalate making your module a piece of shit. If your answer is NO, then you need to worry about question two only.

Thoughts on Question 4

A big question! It is really easy to say what it solves, but knowing how it solves is entirely a different ball game. You need to think on what is the price you need to pay for implementing it, what are the other alternatives, is there a mix and match of patterns to suit your need, does it increases the complexity of the module or simplifies it, what is the cost of maintaining it, how frequently it is expected to change, what are the impact points etc. etc. I am sure it would make you crazy, at first it seemed to me as a simple question but later wow!

Thoughts on Question 5

You must read what other people think about scalablability. Damien Katz, in his post, writes about crappy programmers, boasting about concepts like enterprise, scalability and patterns without actually understanding it. Another hilarious and a bit “PG” post by Ted Dziuba, where he is really pissed off and frustrated with people talking about scalability without having a good knowledge of it. In sync, there is another post by Rajiv Popat where he talks about the best practices and people who seriously talk about such concepts but are not able to answer the simplest questions he asked.

Design patterns are not meant for scalability. It is about extension and maintenance. It should reduce the impact of change, help in decoupling the elements of module interacting with each other, reduce maintenance cost, provide extra room for extension.


 
  Posted in:  Thoughts



Few months back while upgrading my project to .NET Framework 3.5 for using LINQ, I had conducted a knowledge sharing session for LINQ. The piece of code and explanation are the parts taken from the knowledge sharing session.

Before we start off with "Getting started with LINQ - Part I", I would like to explain few good things I learnt while working with LINQ. Also I would assume that you are familiar with the Generics, C# 3.0 language enahancements and basics of SQL. If you are unaware of the language enhancement, I would like to recommend visiting MSDN where you wouldfind some good videos about Visual C# 3.0 enahancements. You can also visit a nice blog by Mike Hanley where he quickly reviews most of the C# 3.0 Language enhancements with examples and comparison to C# 2.0. For Genrics you can visit MSDN article "An Introduction to C# Generics".

Introduction

LINQ is not just a query, it stands for "Language Integrated Query" and more than that it is a data iteration engine applied to the language. The iteration engine is inbuilt in the language. LINQ uses mainly IEnumerable<T> for iteration and IQueryable<T> for querying. C# 3.0 enhancements introduced the "var" keyword which is an anonymous type.

var m = new { FirstName = "Manish", LastName = "Singh" };

Notice the use of "var keyword" and "anonymous class". The first thing that should strike in your mind is - "Hey! Is C# still doing the type checking here?" The answer is YES! C# is still doing the type checking here. The first time you use "var" type, it gets intialized with the type inferred from RHS. If you try to change the type of the variable later in the code, C# complains with an error. The CLR is clever enough to shoot off an error message like "Cannot implicitly convert type 'X' to 'Y'." at the design time itself. However, you must be careful in using "var" keyword or else, very quickly you can land up in a mess, with lots of anonymous variable, making it difficult to debug and maintain. The best is, use it when you know the return type can vary and would be decided at runtime. In short, use "var" when you are confused about the return type :-).

LINQ uses deferred query. This means that the query is not performed when the line containing the query is executed. It is performed during the actual enumeration of the object. However, methods like ToList(), ToArray(), Sum(), Max(), Count(), First(), Last() etc is called immediately and are also known as Non-Deferred queries. The advantage of deferred query is that it executes when required and does not apply any extra overload to your code. Non-Deferred queries execute immediately returning an instance of the IEnumerable<T> list. Why? Because C# 3.0 language enhancement allows you to change the data while iterating using the iterator (Not allowed in C# 2.0).

I would show you LINQ using Lamda expressions. Thus, let us have a little introduction to Lamda expression. Lamda expressions are coma-delimited parameter(s) followed by lambda operator "=>", followed by an expression or statement block. e.g. [(param-1, param-2,..., param-N) => expr]. Example: x => x.FirstName.Equals("Manish"). This lambda expression can be read as "x goes to x" or "input x returns x".

For using LINQ for entities your project must be running on framework 3.5, must reference System.Core and you must be having the using directive "System.Linq". Normally, if you use VS 2008 with Framework 3.5 installed, while creating a new project, VS 2008 does all the work for you.

LINQ Console Program
To start add a new project "Sample Data" of type class library in your solution. This is where all our object declaration and initialization takes place. The following image shows the solution explorer with a project "SampleData" in it.

solution explorer

The "SampleData.cs" int the "SampleData" project includes a classical example of Customer, Product, Order and OrderItem. For the sake of simplicity, I have declared the properties as "public".

SampleData.cs
 The "DataContext.cs" int the "SampleData" project includes the initialization code for Customer, Product, Order and OrderItem. For the sake of simplicity, I have declared all methods static for the sake of simplicity. This method is required from my console program to collect some meaningful data for "Customer", "Product", "Order" and "OrderItem". The next section shows you a sample initialization.

DataContext.cs

To initialize the entities with some sample data you may create the object with fictitious but meaningful data and assign it to a list as shown in the image below. Later we will query these data and check the output.

DataContext.cs

Next, we add a new console project into your solution say "LINQ-Object". Add Reference to "SampleData" project. In the "Program.cs" file that is created by VS 2008 for you, go ahead and declare a bunch of static methods as explained below. After that you can call each of these from the "static void Main(string[] args)" method and check the output. Also try to use break point and see what is displayed.

LINQ: Select
SelectMost of the extension methods of LINQ applied on IQueryable<T> or IEnumerable<T> returns another IQueryable<T> or IEnumerable<T>. This allows you to nest the methods in progressive manner like "Append()" method of "StringBuilder" class. I have purposefully applied nested select to explain this. Select is a deferred query and parsing is done at the runtime.

Output

LINQ: Where Clause
WhereIn this part of the code I have explained a simple "where" clause using LINQ. The query simply returns all customer who belong to "category", "A". If you see the declaration of "Customer" entity explained earlier, you would see that it has an attribute "category" to help categorize the customers into groups depending on their importance.

Output

LINQ: Join
JoinIn this part of the code "Customer" and "Order" to see the customer's full name, order name and order date. When you run the program the output (see image below) would be shown, depending on your data.

Output

LINQ: Group Join
Group JoinIn this part "Customer", "Order" and "OrderItem" is joined to see the customer full name, customer category, order name and order details like product name, quantity and price. When you run the program the output (see image below) would be shown, depending on your data.

Output

LINQ: Group By
Group ByThis part of the code, returns the customers grouped by their category. When using "Group By" extension method in LINQ, it returns a two dimensional list. Each elements of the outer list contains a list of customers belonging to the same group.

Output

LINQ: Order By
Order ByThis section explains the "Order By" clause as seen in SQL. You can have multiple attributes in the "Order By" clause and also provide sorting direction.

Output

LINQ: TakeWhile
TakeWhile"Take" extension method allows you to select items from top while the TakeWhile extension method allows you to select items based on certain condition. The code selects items whose string length is below six.

Output

LINQ: Skip
Skip"Skip" extension method allows you to skip items from top while the SkipWhile extension method allows you to skip items based on certain condition. The code skips five items from the top.

Output

There are several more methods defined in LINQ. I would encourage you to apply more of these extension menthods for practice and clarity.


 
  Posted in:  .Net