|
Archives
|
| | Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|
| 26 | 27 | 28 | 29 | 30 | 1 | 2 | | 3 | 4 | 5 | 6 | 7 | 8 | 9 | | 10 | 11 | 12 | 13 | 14 | 15 | 16 | | 17 | 18 | 19 | 20 | 21 | 22 | 23 | | 24 | 25 | 26 | 27 | 28 | 29 | 30 | | 31 | 1 | 2 | 3 | 4 | 5 | 6 |
|
|
Disclaimer
The opinions expressed herein are my own personal opinions and do not represent
my employer's view in any way.
Copyright 2010 Manish Kumar Singh
|
|
 Saturday, May 16, 2009
Beautiful Dream
It was a Dream
Sometimes a dream seems so neat and well formed in its set of events and story line up, that it makes one feel like a creative writer. Though, I am nowhere near to good novel and creative writers, I hope the beauty of this story would appeal to the readers.
This was a dream that has nothing to do with my real life, but still had a lot of steam in its story and hidden meaning. This is my first write-up for the same and I would try to bring it very near to what I dreamt and how I felt while seeing it. I hope I would be able to generate the same enthusiasm and excitement going ahead.
Even though, I was playing the role of main character in my dreams, feeling every part of the emotions gushing through his nerves, in real life, I didn't have any resemblance to the face, background, nature or story of the character. It is more like as if, I got attached to this character at a different dimension of time and space (for few hours), feeling his inner realm without him noticing it. It is like as if, I stayed as a host inside that character for some time sharing every piece of his thoughts and emotions. The only thing I know better is it was not me still it was me.
Hence, let’s replace the name to say “John”, and let me take you to meet John, his emotions, thoughts and his story.
John!
John was in his teenage happily living with his family. The family consisted of his father, mother and an elder sister. Everyone in his family was an earning member employed. John was the only one studying. In his general routines, he used to spend the first half of the day at his college nearby, and then the rest, either playing basketball with local friends, or staying back at home doing some studies. He really cherished the great moments spent together with his family, and eagerly waited for them to return. John’s dressing sense was like many other teens, wearing rugged jeans, t-shirt and his favorite red cap having the letter “J” embroidered on the front. He used to wear it front-side-back.
John and his family stayed in a beautiful city with a lot of greenery and beautiful weather. Let me describe the place I visited in my dreams. Let me show you what I saw. It was a beautiful city having mountain ranges on one side, hazily visible, with peaks touching the sky. It was a pleasant weather, generally found in cities located near to major mountain ranges. It was not a place with high rise buildings. In fact it was a wide open area with condos located at a good 200-300 meter distance from each other. The area had an uneven slope (common near hilly areas), nicely covered with evenly cut grass and trees planted randomly all over. It did not seem to be a crowded place, an area with a small population but well designed and clean. It seemed it was a time of autumn when I visited the place in my dreams, though in realty it was winter. The fallen yellow leaves all over the place, including roads supported my assumption of less traffic here. It was a windy day as well.
There was a big common play ground at half a mile on left of John’s house. It was a good hangout for John and his friends. It was the only place where I saw a little crowd. Children playing outdoor sports, people walking or simply time passing. It had a basketball court where John used to play with his friends. Located further ahead of the play ground, maybe another half a mile was a church, clearly visible from John’s house. As what I read from the illegally invaded thoughts of John, was that a graveyard was also located behind the church.
Memories
It was the last working day of the weekend. At 1 pm, John was eagerly waiting for the last class to get over - the math class. It was not common for John to feel gloomy, especially in his math classes, which was his favorite subject. He was blaming it to the weather and his not-so-good night sleep. He was having hard time concentrating in the class, while his mind today was wandering more on the philosophical side. Memories from past were dominating his present. Some childhood games, he used to play, the kind of comics he used to read, how preciously, he used to keep those comics in the drawer, places he remembered, the things of his childhood, precious memories of friends and family get together, all this were hovering inside his head, one after another like several movie clips knitted into a sequence.
His mind was wandering in his past while his eyes were looking outside the classroom window where some kids were playing near a tree located few meters away. Those kids were playing with the fallen leaves, arranging them on the ground to form an art work like house, tree, animal and other nice things. One of the kids had scribbled a word out of those fallen leaves. It read “Happy Birthday”. Seeing, this John’s mind started knitting the memories of his birthdays he had enjoyed the most. Then suddenly he remembered the date today – It felt like an important day, it appeared as a day, having some event associated with it. “Was it someone’s birthday?” …. “Something, forgotten falls on this day”. John was trying hard to remember, but somehow, he was not able to recollect any event associated with this date. Yet the date was hovering like a feeling of Déjàvu. The shadows of past memory had now stopped disturbing him and the date had taken its place. John was now randomly picking up his family, friends and relatives to figure out whether today was associated to any of these people.
The class had ended and his colleagues were all packing up their bags. John too started packing his bag and wishing his friends. One of his friends had probably noticed his state of absence in the class. Peter came to John and enquired – “Hey John, something wrong? You seem a bit disturbed today.” “Oh no, nothing serious”, replied John. They walked out of the class together while John explained him about his mood swing and past memories. Soon, they were on the street and walking towards home. John’s house was just a mile away and he preferred walk down. Peter usually accompanied John, till the nearby bus stop, from where he used to take a bus to his house.
After Peter had left, John started walking down towards his house. On his way to home, and, even while he was talking to Peter, his mind was busy figuring out any event associate with today. He was sure that today was some important day, and he was trying hard to remember any event associated to this day. The feeling of Déjàvu was strong yet the answer seemed far away.
Déjàvu
After arriving home John threw his bag on his bed and picked up the TV remote to watch some of his favorite channels. He pushed himself into a comfortable couch in front of the television and started playing with the remote. John was glad to find a sports channel showing a basket ball tournament. John made himself comfortable, almost in a lying position, concentrating on the match. The match kept him glued to the television till it ended in a tie. It was a great match, the game was now over and the commentator was uttering his final speech. Before, ending his speech the commentator revealed that the captains of both teams were a childhood friends and also, one of the captain was having his birthday anniversary today. On hearing this, the Dejavu effect again engulfed John’s thought and he started thinking about event that slipped out of his mind. For few minutes, he concentrated hard thinking about it, but in vain, no auspicious event he could memorize had a date today. Then he stopped thinking about it and planned to visit his friends for some refreshment and game at the playground.
John reached the playground and found three of his friends already practicing basket ball. John was greeted with warmth and he joined them. He stayed there for an hour chatting and playing, then decided to go back home. Then suddenly, it clicked to him, and he asked his friends – By the way! … any Birthday today? I mean do you guys remember today as any important day? They looked puzzled, and then answered in chorus – No, Nope, Why? John knew they could not remember any important event for today and thus confused, so he said – Just a thought, forget it – and then left for his home.
On his way back he saw a person selling flowers on the roadside. He had not seen that person selling flowers before, here in this place. John kept walking looking at the person, who noticed his attention, and greeted him – Sir, any occasion today, would you like to buy some flowers; they are fresh, handpicked! - John was caught in a bit of surprise, by the coincidences happening one after another, that seemed like pointing to something that he was unable to remember.
It was now getting on his nerves, something inside his head was clearly indicating him that today was special, but it was like pondering in dark, as he had no clue about the event, its type and whether good or bad. The Dejavu effect felt stronger now, the birthday written with leaf, birthday of the basketball team captain and now this person selling flower asking him to buy few for an occasion.
Something urged John to buy some flowers and he followed his urge. He bought some flowers and headed to his home.
Revelation
John kept the flowers on the table and went to bathroom for a shower. After a hot bath, John felt more relaxed, though he was still wondering about the incidents. It was already 5 pm now and, he had no clue of any event today. He looked at the flowers while combing his hairs, as if these flowers might help him to find another clue, or solve the mystery for him. He did not want to act like a crazy asking people about any event today, just because he was experiencing a strong force of Dejavu. But, the day was about to end and soon it would be all over, which made him more impatient. He was thinking about ways that can help, in revealing the Dejavu effect. At the same time he did not want to push things beyond logical explanation, making a fool out of himself. Finally, John decided to give up and stop thinking on the issue. He went to the kitchen to make some sandwiches for himself.
It took him just a few minutes to get the grilled vegetable sandwich ready. He took the sandwich on a plate and came back to his room. He again sat on his couch watching television and enjoying his sandwich. He had switched on a channel showing the top number songs. It was an old Phil Collins number playing on the screen “Another day in paradise…”. John had listened to his song many a times before, and liked it. He started singing along in a low voice trying to match the words and tune. John remembered he had performed the same song in school and had received a flower vase as prize for a good performance. His eyes instantly went to the flowers he had kept on the table, and then he stood up and headed towards the store room, where he remembered he had kept his precious belongings – the flower vase too. His whole day spent roaming in the past and now looking at his belongings were pretty exciting for him. He wanted to see and cherish few of his memories which had gripped him since morning.
The store room was small with lot of things stuffed and piled inside. It was untidy with dust filled all over. Most of the things were John’s childhood possessions. John’s eyes started searching for the most probable place for the vase. His eyes went to a box, which was of the size of vase. John immediately recognized it – it was the vase he had received as a prize. John reached for the vase but, it had other thing piled upon it. John was careful about taking it out without disturbing the balance of other items on the top. John almost succeeded except one thing that fell from the top when he brought out the vase. It was an old album containing photographs. John stared at the album lying beside his feet filled with dust, quiet old, but he remembered it. It was his precious procession, and a time to go back into the past. He picked it up and kept looking at it for a while, then saw up from where it had fallen. Probably, it had touched his heart. He brought it, along with the vase and cleaned the dust. After keeping the flowers in the vase, John sat in his couch with his album on his lap.
John turned the page and saw young John in a school dress smiling at him. His memories started sketching scenes he remembered about the photograph and his school. He turned to next photograph, which was a group photograph of all his class mates and teachers. He kept looking at the photographs with his finger touching every person in the photograph. His mind was helping him to regenerate the live moving images of these persons. Suddenly, his finger stopped at a boy – Steve, his best friend. Steve and he were the one who had sung this song in school. Steve had also received the same prize. They had spent a real good time together. In most of the games and plays he was either his partner or rival of equal potential. Steve was always there to help, whether study or play. They had even childishly decided to opt for same school, same job and even same city when they grow up. Unfortunately, Steve had not kept his promises - he had left him alone and moved to a different world. It was the sample place, same city, John was still there but Steve had left. John remembered how bad he felt when he heard about Steve’s demise. It was an unfortunate accident, which had taken Steve away. He remembered putting flowers on his grave and promising that he would never forget the friendship and Steve. It had been seven years now, without Steve.
Suddenly, John jumped out of his couch - the album fell from his lap on the floor. He was now feeling guilty, he had actually forgotten his promise and not only that, the Dejavu effect was now very clear to him, it was his birthday today – Steve’s birthday. The circumstance, past and the clues were all clear and revealed.
The “Happy Birthday”, with the fallen leaves The two childhood friends playing basket ball as a rival team captains. The man selling flowers, the same flowers that he had kept on Steve’s grave.
But how was this happening to him, how come the coincidences matched so well, how can it be logically explained, why was he feeling not-so-good in the college today.
John was guilty, confused and surprised all at the same time. Lot of emotions were exchanging hands at the same time, increasing his breathing speed.
John decided to go to his grave behind the church. It was 6 pm by now; it would take him around 20 minutes to reach there. He quickly, dressed up, grabbed the flower and ran to the door.
Forget Me Not
It was windy evening; the sun had already set, but it was still not dark yet. There were multiple graves lying in peace, very silent and calm. The sound of wind was loud and clear.
John was standing in front of Steve’s grave - his eyes were glimmering with water. He was thinking about the good times and emotions he had shared with his best friend. He wanted to ask Steve, why he left and remind his promise. On the other hand his mature mind was telling him, it is not possible – Steve has gone, gone forever – But, then why these coincidences, clues and Dejavu. Was it not Steve, who was trying to remind me of my promise? Why did birthday appeared so many times in front of me, Why was I feeling gloomy today, Why did I bought flowers today, Why did I thought of the Vase today – the vase, which we had received as a prize together, Why did the album fell today – Was it not Steve’s attempt to remind me my promise made at his grave? Was it really a coincidence and so many of them together? John, was so confused and affected by the Dejavu effect, that he softly spoke to Steve’s grave – Steve was it you, did you try to remind me, are you there? There was no reply, John new there won’t be any.
After spending some time there – praying for Steve – John decided to go back home. It was already late and the sky was quiet dark now. John remembered, his family members would be arriving anytime now, and would get worried not finding him at home. John kept the flowers on the stone and after giving it a last soft look, turned around. Suddenly, he felt, a paper fluttering sound behind, he turned again and saw an old and dusty greeting card stuck on the cross of Steve’s grave making the fluttering sound due to the wind, causing its edges to strike on the cross.
John slowly picked up the card removing it from the cross and saw a sketch of two cute little children embracing each other. It was a friendship card. John was amazed, and started looking everywhere to see where the card came from. There was no one around. Can this be another coincidence? He then slowly, with trembling fingers, turned the card, which had no name but a one liner printed in bold calligraphy “FORGET ME NOT”!
This was the instance when I woke up and the story ended right there. But I got up remembering each and every scenes. I decided to blog it, since it was too precious to loose or forget. General
Saturday, May 16, 2009 9:16:59 AM (GMT Standard Time, UTC+00:00) Trackback
|
|
 Saturday, May 09, 2009
Compile .NET code on the fly
In this section I would like to demonstrate how to compile a .NET code on the fly. The code has been written in C#. It contains a class "InlineParser" which does the main job. It mainly, defines the class, does in-memory compilation and exposes a method for the execution of an inner method defined in the class. It also supports a choice of language whether C# or VB.NET for compilation.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using Microsoft.CSharp;
6 using Microsoft.VisualBasic;
7 using System.CodeDom.Compiler;
8 using System.Reflection;
9 using System.Xml.Linq;
10
11 namespace com.eforceglobal.crux.bre
12 {
13 internalclassInlineParser
14 {
15 string expression = string.Empty;
16 string functionArguments = string.Empty;
17 string language = "CSharp";
18 XDocument paramList = null;
19 object objBase = null;
20
21 public InlineParser(string expr, string functionArgs, XDocument parameters, string lang)
22 {
23 expression = expr;
24 functionArguments = functionArgs;
25 paramList = parameters;
26 language = lang;
27 }
28
29 publicbool init()
30 {
31 if(language.ToLower().Equals("csharp"))
32 return InitCSharp();
33 else
34 return InitVB();
35 }
36
37 internalbool InitCSharp()
38 {
39 // Compile the expression in a class on the fly
40 CSharpCodeProvider cp = newCSharpCodeProvider(
41 newDictionary<string, string>() { { "CompilerVersion", "v3.5" } } );
42
43 //ICodeCompiler ic = cp.CreateCompiler();
44 CompilerParameters cparam = newCompilerParameters();
45 cparam.GenerateInMemory = true;
46 cparam.GenerateExecutable = false;
47
48
49 // Reference Assembly
50 cparam.ReferencedAssemblies.Add( "system.dll" );
51 cparam.ReferencedAssemblies.Add( "mscorlib.dll" );
52 cparam.ReferencedAssemblies.Add( "System.Core.dll" );
53 cparam.ReferencedAssemblies.Add( "System.Xml.dll" );
54 cparam.ReferencedAssemblies.Add( "System.Xml.Linq.dll" );
55
56
57 // Write your code
58 StringBuilder sb = newStringBuilder();
59 sb.Append( "using System;\n" );
60 sb.Append( "using System.Collections;\n" );
61 sb.Append( "using System.Collections.Generic;\n" );
62 sb.Append( "using System.Text;\n" );
63 sb.Append( "using System.Text.RegularExpressions;\n" );
64 sb.Append( "using System.Reflection;\n" );
65 sb.Append( "using System.Linq;\n" );
66 sb.Append( "using System.Xml.Linq;\n" );
67
68 sb.Append( "namespace com.eforceglobal.crux.bre {\n" );
69 sb.Append( "public class EvalClass {\n" );
70 sb.Append( "public EvalClass(){}\n" );
71 sb.Append( "public object Evaluate(\n" );
72 sb.Append( functionArguments ).Append( " ) {\n" );
73 sb.Append( expression ).Append("\n");
74 sb.Append( "}\n}\n}" );
75
76 //Console.WriteLine( sb.ToString() );
77
78 string code = sb.ToString();
79 CompilerResults cres = cp.CompileAssemblyFromSource( cparam, code );
80
81 // Compilation Unsuccessfull
82 StringBuilder errors = newStringBuilder();
83 foreach ( CompilerError cerr in cres.Errors )
84 errors.Append( cerr.ErrorText );
85
86 if ( cres.Errors.Count > 0 )
87 thrownewException( errors.ToString() );
88
89 // Compilation Successfull
90 if ( cres.Errors.Count == 0 && cres.CompiledAssembly != null )
91 {
92 Type ClsObj = cres.CompiledAssembly.GetType( "com.eforceglobal.crux.bre.EvalClass" );
93 try
94 {
95 if ( ClsObj != null )
96 {
97 objBase = Activator.CreateInstance( ClsObj );
98 }
99 }
100 catch ( Exception ex )
101 {
102 throw;
103 }
104 returntrue;
105 }
106 else
107 returnfalse;
108 }
109
110 internalbool InitVB()
111 {
112 // Compile the expression in a class on the fly
113 VBCodeProvider vb = newVBCodeProvider(
114 newDictionary<string, string>() { { "CompilerVersion", "v3.5" } } );
115
116 //ICodeCompiler ic = cp.CreateCompiler();
117 CompilerParameters cparam = newCompilerParameters();
118 cparam.GenerateInMemory = true;
119 cparam.GenerateExecutable = false;
120
121
122 // Reference Assembly
123 cparam.ReferencedAssemblies.Add( "system.dll" );
124 cparam.ReferencedAssemblies.Add( "mscorlib.dll" );
125 cparam.ReferencedAssemblies.Add( "System.Core.dll" );
126 cparam.ReferencedAssemblies.Add( "System.Xml.dll" );
127 cparam.ReferencedAssemblies.Add( "System.Xml.Linq.dll" );
128
129
130 // Write your code
131 StringBuilder sb = newStringBuilder();
132 sb.Append( "Imports System\n" );
133 sb.Append( "Imports System.Collections\n" );
134 sb.Append( "Imports System.Collections.Generic\n" );
135 sb.Append( "Imports System.Text\n" );
136 sb.Append( "Imports System.Text.RegularExpressions\n" );
137 sb.Append( "Imports System.Reflection\n" );
138 sb.Append( "Imports System.Linq\n" );
139 sb.Append( "Imports System.Xml.Linq\n" );
140
141 sb.Append( "Namespace com.eforceglobal.crux.bre \n" );
142 sb.Append( "Public Class EvalClass \n" );
143 sb.Append( "Public Function Evaluate ( " );
144 sb.Append( functionArguments ).Append(" ) As Object\n");
145 sb.Append( expression ).Append( "\n" );
146 sb.Append( "End Function\n" );
147 sb.Append( "End Class\n" );
148 sb.Append( "End Namespace" );
149
150 //Console.WriteLine( sb.ToString() );
151
152 string code = sb.ToString();
153 CompilerResults cres = vb.CompileAssemblyFromSource( cparam, code );
154
155 // Compilation Unsuccessfull
156 StringBuilder errors = newStringBuilder();
157 foreach ( CompilerError cerr in cres.Errors )
158 errors.Append( cerr.ErrorText );
159
160 if ( cres.Errors.Count > 0 )
161 thrownewException( errors.ToString() );
162
163 // Compilation Successfull
164 if ( cres.Errors.Count == 0 && cres.CompiledAssembly != null )
165 {
166 Type ClsObj = cres.CompiledAssembly.GetType( "com.eforceglobal.crux.bre.EvalClass" );
167 try
168 {
169 if ( ClsObj != null )
170 {
171 objBase = Activator.CreateInstance( ClsObj );
172 }
173 }
174 catch ( Exception ex )
175 {
176 throw;
177 }
178 returntrue;
179 }
180 else
181 returnfalse;
182 }
183
184 publicstring Evaluate()
185 {
186 string result = string.Empty;
187 Type type = objBase.GetType();
188 MethodInfo mInfo = type.GetMethod( "Evaluate" );
189
190 if ( mInfo != null )
191 {
192 ParameterInfo[] pInfo = mInfo.GetParameters();
193 object[] arguments = null;
194 if(pInfo!=null) arguments = newobject[pInfo.Length];
195 if ( pInfo != null )
196 {
197 foreach(ParameterInfo p in pInfo )
198 if ( paramList.Element( "arguments" ).Elements( p.Name ) != null )
199 {
200 arguments[p.Position] = (paramList.Element( "arguments" )
201 .Elements( p.Name ).Single().Value);
202 }
203 if ( pInfo.Length != arguments.Length )
204 thrownewArgumentException( "Insufficient parameters." );
205 }
206
207 result = mInfo.Invoke( objBase, arguments ).ToString();
208 }
209
210 return result;
211 }
212 }
213 }
Notice that the class name of the class to be compiled is "EvalClass" and the inner method of the class is "Evaluate". Calling the "Evaluate()" method requires you to execute the following lines of code.
1 var parser = newInlineParser(subExpression, funcArgs, Arguments.Document, lang);
2 parser.init();
3 retString = parser.Evaluate();
Manish .Net
Saturday, May 09, 2009 6:21:03 AM (GMT Standard Time, UTC+00:00) Trackback
|
|
 Sunday, March 29, 2009
Microsoft Surface ... CLI to GUI and Now NUI (Natural User Interface)
Introduction
I 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.
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.
- 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 .Net | Thoughts
Sunday, March 29, 2009 9:26:22 AM (GMT Standard Time, UTC+00:00) Trackback
|
|
 Monday, February 23, 2009
Interactive Video Advertising With Silverlight 2
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 {
private IDictionary<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 !! .Net
Monday, February 23, 2009 2:14:53 PM (GMT Standard Time, UTC+00:00) Trackback
|
|
 Monday, January 19, 2009
Life full of Talents and Skillz
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:
-
Learning Quotient (LQ): Measures how an individual learns and improves
-
Conceptual Quotient (CQ): Measures the ability of thought process in solving a problem.
-
Relationship Quotient (RQ): Measures how an individual behaves in a group
-
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.
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
Skillz
Monday, January 19, 2009 2:14:29 PM (GMT Standard Time, UTC+00:00) Trackback
|
|
 Tuesday, January 13, 2009
Do not implement Design Patterns - if you do not understand it
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: - Does your team, working with you also understand the pattern correctly? Are they comfortable with its implementation?
- 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?
- Does it require other members to follow a set of rules while coding?
- Do you understand “What it solves” OR “How it solves”?
- 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.
Thoughts
Tuesday, January 13, 2009 5:17:12 AM (GMT Standard Time, UTC+00:00) Trackback
|
|
 Friday, November 07, 2008
Getting Started with LINQ - Part I
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.
|
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".
|
|
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.
|
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.
|
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
|
Most 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.
| |
LINQ: Where Clause
|
In 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.
| |
LINQ: Join
|
In 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.
| |
LINQ: Group Join
|
In 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.
| |
LINQ: Group By
|
This 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.
| |
LINQ: Order By
|
This 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.
| |
LINQ: 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.
| |
LINQ: 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.
| |
There are several more methods defined in LINQ. I would encourage you to apply more of these extension menthods for practice and clarity. .Net
Friday, November 07, 2008 1:30:05 PM (GMT Standard Time, UTC+00:00) Trackback
|
|
|