Category Archives: Professional

Dojo & GWT – Templated Widgets

We had – and still probably have – a tough time porting Template-Based Widgets in Dojo for Google Web Toolkit.

The reason is – Templates defined attach-points and attach-events, variable names / function names that are to be made use of at runtime. However, GWT optimizes the Java function names and as such one does not know what will be the function name at runtime.

And hence the conflict and an area of problem.

The DWT team has posted a writeup at their blog that outlines the problem and proposed solution.

If you find the problem interesting or have an opinion, please do write in.

4-Sutras to work with JavaScript

(Sutra: noun, that which runs through and holds things together)

JavaScript is a fantastic language to work with. I will, personally, prefer to work with runtime dynamic language like JavaScript than compile-time feature constrained languages like C++ or Java (well, C# is still far richer than C++ and Java).

However, working with JavaScript is not – quote-unquote – trivial noting that majority of the developers start with C/C++ or languages evolved from them.

I’m not here to talk about JavaScript, but 4-Sutras that I’ve developed that one should keep in mind while working with JavaScript.

These sutras are:

  1. All data-types are infinitely flexible.
  2. All objects are infinitely extensible.
  3. Objects are associative arrays.
  4. It’s all about functions.

Let me explain them in some detail…

In JavaScript, we can provide more functionality to any data-types, including the predefined ones through the prototype object. Infact, there exists a JavaScript library with this very name. For example, we need to add a function insertAt to the Array object. Here’s how we can accomplish the task.

Array.prototype.insertAt = function(item, index)
  if(index >= 0 && index < this.length)
    this.splice(index, 0, item);

And then, I can do:

var a = new Array();
a.insertAt('two', 0);

alert('Item at index 0 = ' + a[0]);

So, what I meant in “flexible data-types” is that we can add (infact, remove and change as well, at will) the functionality to any data-type (native JavaScript object) irrespective of whether the code for the type is available or not. Isn’t it great?

Coming to the next point – properties / methods associated with any object (instance) is totally configurable. Assume that we have a reference obj to which we want to associate two properties – exx and vayee – and one method checkPoint, we can add that!

Note that this is different from the flexibility of the data-type. Here, only obj will have these properties, any other object obj2 will not have these properties and methods.

var obj = new Object();
bj.exx = "Value x";
bj.vayee = "Value y";

obj.checkPoint = function()
  if(this.exx && this.vayee)
    return true;
  return false;

What do you gain out of this? Well, this extensibility allows you to grow your objects – at runtime, on demand. And that’s one of the features that I love in JavaScript.

Everybody loves OOAD because it helps us relate programming to our real life – objects with attributes and functionalities. However, it fails to address one key issue – objects in real life grow. They grow as themselves not requiring a child. However, this is absent in almost all languages barring JavaScript and Smalltalk.

btw, do you remember Smalltalk? The world’s first object oriented language. But somewhere, C and C++ grew more popular and we really lost the fun and power of Smalltalk. Sad. :(

So, I am assuming that you’ve understood what I mean when I say that all objects are infinitely extensible.

Let me proceed to the next item. It may or may not be classified as a sutra, because it’s a very basic feature of JavaScript. However, we tend to forget about it while working with JavaScript. So, I thought about making it a sutra so that it’s not forgotten.

Objects internally are implemented as associative arrays, or whatever alternate name you want to use. The effect is that you can use any object in two ways, as given below:

var obj = new Object();
//Assigning as a property
obj.x = "Ex";

//Assigning as an associative array
obj['x'] = "Ex";

//Similarly, assining a function
obj.fn = function()
  alert('Hello, World!');

//And calling it

The two ways to work with properties, as given above, are identical. So, don’t worry if you do not know the name of the method or property at design time. Just store it in a variable and access it using the format given above!

Voila! So easy! And damn powerful! Isn’t it?

And finally, never forget about functions. JavaScript is all about functions – to start with and till the end!

The attributes associated with JavaScript functions are:

  1. Functions are the ways to create data-types: Encapsulation
  2. Functions can be nested, any level deep: Some kind of private functions?
  3. Functions can be used as simple functions as well as constructors
  4. Instance functions (associated with any object) can be called with any context, so that the value of this can be changed on the fly! Voila!
  5. And there’s a lot more magic that you can do with functions in JavaScript.

Adobe Flex, RIA and Web 2.0

Last week I delivered a week long training on Adobe Flex 3 (yet again). Apart from the technologies – Adobe Flex and ActionScript – the training aimed to focus on Web 2.0 and RIA.

Web 2.0 and RIA, today, are more or less established philosophies.

However, what I think is that the world is heavily divided on which framework / toolkit to go for. Most of the web revolves around JavaScript & Ajax and/or Flash & ActionScript. Slowly and gradually, Silverlight & WPF/JavaScript seems to be making inroad on the development front – not quite sure how fast.

So, I thought let me try to compile a few frameworks (partial list inspired from the one at Wikipedia):

Barring Adobe Flex, all other frameworks use a common technology – JavaScript and Ajax.

However, some toolkits like Dojo uses / used Flash for offline storage. Some of them are moving to Google Gears for offline store.

And at the moment, I have to rush to the market… will build on this in my subsequent articles.

A Trainer’s Life – Why he must be a team!

Today, I will try to answer a question, “Why an individual, working directly with end client, cannot survive long in training ?”

Well, this question is based on my perspective – “An indiviual cannot go long”.

Or, as we call in Hindi, “Akela Chana Bhaand Naheen Phod Sakta (अकेला चना भाड़ नहीं फोड़ सकता)”

Given below are my justifications, based on my experiences.

Let’s try to look at the activities in a smart trainer’s life:

  • Know / Learn, in depth, about the subject to provide training on.
  • Have / Get practical knowledge to be able to provide effective training. Otherwise, it remains a pure theoretical “teaching” rather than practical “training”
  • Prepare effective case-studies, that more real-world than theoretical. The training should comprise of some “best practices”.
  • Be prepared to answer queries from the “related areas” rather than only “the subject / topics”
  • At times, sit with the team undergoing training to analyze their project and provide best approach for implementing solution to business problem.
    Trainer should understand the business problem as opposed to only technical problem since unless a technology solves the business / human problem, the technology or solution is of no use!
  • Ensure that he is on the cutting edge of the technology, lest he becomes obsolete.
  • Prepare the literate to be handed over to the audience.

However, if the trainer is an individual he will need to, additionally, work on the following:

  • Negotiate price.
  • Check his availability and giving immediate commitment, which he / she may not want to do.
  • At times, run around places at the client premises to get his payments. The payment cycle can be from around 10 days to 60 days.
    Which means that the trainer cannot work with the companies where the payment cycle is long lest he has enough buffer with himself.
  • Look at taxes, especially TDS
  • Ensure that the tax is not deducted for reimbursements. Ensure that Debit Note is taken care of appropriately.
  • Participate in regular “vendor meets” organized by the clients.
  • Prepare the literate to be handed over to the audience. Here, the physical delivery – may be a book or a CD/DVD etc.

Now, my simple question – “How much of this can an individual do effectively ?”

Once he starts running around to collect the payments, his precious training time is gone. Also, once he receives the payment after running around, he may be simply too tired physically to check up with the latest in the world.

At least two people are required. One to focus on the first set of activities, and the other for the latter set.

That’s how we – Yashwanth C and Gaurav Vaish – started Edujini.
I’ll find time to write something on the “history of Edujini” later on…

Dojo on Google Web Toolkit

My real love for GWT started only a couple of days ago… and it prompted me to get started with Dojo on GWT.

I have, so far, written a couple of core-classes in Java mainly to abstract out the interaction with JavaScriptObject.

My next target was to directly jump on to dijit, and start creating the UI. And then I realized that it uses mixins. And now I am left wondering what’s the best way to handle mixins.

For the new comers, JavaScript allows single inheritance but Dojo (and other libraries) make use of mixins to pseudo-inherit methods and properties from other objects by copying them to the sub-object.

In Java, this can be achieved only by making use of interfaces. The other possibility is to introduce a class between the parent and the child class that encapsulates the mixin objects.

I think the latter is a better approach. Simply expose the object or may be create delegate methods.

Let me think over it… what’s the best way to marry Java and JavaScript.

Events during training on Monday

Without any introduction, let me just list down some intersting events of the day…

Reached the entry gate of the company premises only to find that the contact person is on leave.

The contact person did not delegate his responsibilities, if at all any, to somebody else.

Upon reaching the training room, there was not a single computer for the audience to lay hands on for the case studies. Hey, you know that it’s an IT Training.

Read more …

Customizing Team Foundation Server

Yes, that’s what I am doing for couple of days.

No, it’s not about customizing how TFS works but looking at the integration points. In short, the TFS SDK.

The following items are the items on my radar immediately:

  • Customizing WorkItem Types
  • Creating custom fields
  • Creating custom UI controls during WorkItem display in Visual Studio
  • Creating custom check-in policies
  • And making all of them backed by some database?

Well, I have already worked with the first two items – creating custom fields and customizing WorkItem types, predominantly using custom fields and choosing the layout – several times.

Now, I need to master the remaining items.

And yes, it’s mainly for Edujini™, my baby. So, what I promise is that once I am through with my experiments, I will publish them at Eduzine™ and Edujini Downloads™.

Room Setup for a Technical (IT) Training

When I started my day yesterday, I thought I would be going off to a great day ahead for my training.

The Monday evening, I was severly troubled because of the red-burning-eyes and severe headache caused due to inefficient and insufficient lighting in the training room. As such, I did nothing in the evening but took dinner and went off to a long sleep.

Reaching the venue, I noticed that not all machines were properly configured, yet. We spent another 1hr for the setup – just to ensure that we get going as quickly as possible and do not waste more time.

And by the end of the day, I figured out that we are running late by around 4hrs or so. Really, couldn’t see any hope to recover that time anywhere.

So, here’s a list of things that you must take care of before / during the training:

  • There should be appropriate and sufficient ligthing
  • There should be lights focussed at your laptop screen, to say the minimum, lest your eyes get strained
  • The screen should be sufficiently large
  • The maximum distance between the screen and the participant should be such that he is able to view any content / text / code written at font-size of 14-16.

If not, be prepare to strain yourself and get doomed!