Archive for January, 2009

Instance Manager Object

Sunday, January 25th, 2009

I have been using a new pattern for managing instances of JavaScript widgets in applications. I define a widget as any component in an app that is JavaScript enhanced. This could be anything from a DataTable to a button.

In the YUI 2X idiom of interface development, you would create a namespace for a section of your application. All of your instances, constructors, and various other junk would live in the scope of this namespace. My instance manager pattern would slightly change this in that constructed instances of widgets would be stored in a Instance Manager object. This object would be constructed as a member of any namespace that would be home to an instance of a widget. All of these instances would be kept in a sub-object of the Instance Manager which would be known as the “map” object.

The Instance Manager object would have 3 more methods:

  • get
  • set
  • delete

“set” method
The “set” method that can be used to add an instance to the “map” object. Passing the constructor as an argument instead of passing an instance will delay the instantiation until the first time the instance id is called from the “get” method this is known as lazy loading.

“get” method
The “get” method that can be used to return an instance from the map object by passing its key as an argument.

“delete” method
The “delete” method will remove the instance from the map object by passing its key as an argument.

The point of this pattern is to create a consistent way to create and get instances of widgets. This is especially useful for use with the Unobtrusive JavaScript pattern because code written to look for special markup conventions on page load can be generalized

Community building for developers

Saturday, January 24th, 2009

Empty cubesLast week I traveled up north to the location where most of the customers of my group work. We put together 2 days of training mostly focused on new code but including some best practice stuff like rapid iteration and test driven development. The over-all response was good. People thought that the information was useful and they were eager to hear when our next event would be.

The highlight for me was a roundtable session where we suggested topics and allowed the group to have an open discussion. Some of this became a Q&A for our team and other parts were an open debate about best practice. I am happy to say that this entire roundtable session was captured on video and we will soon take note of every good idea shared in the room.

This feel this session may have done something that in all of the time I have been on this project, I am yet to see: it sparked a community. I hoped that after this event, we would all leave with a better understanding of who our team-mates are, and how we can work together to innovate. It turns out a lot of people want to innovate, I just think that they feel they are the minority. They let their urge to innovate give way to their need to just get the job done; since it seems the fight would be pointless otherwise. I hope out hour of open discussion was enough to tear down this misconception once and for all and let the ideas flow free.

We made a point to ask for feedback with some success. As we all know however, people are much more willing to share their true feelings when they are anonymous. I used SurveyMonkey.com to create a truly anonymous survey on a third party site. It turns out that we did get a lot more candid feedback but it was still all very gracious. I suppose we can count this first event as a success.

PHOTO CREDIT: Uploaded to Flickr by Shashank