Monday, January 31, 2005

Manipulating Binded Datasource at runtime is tricky..

Its not that easy as we think to manipulate a collection that is bound to a combobox/listbox. This works out of the box if you are using a DataView but if you are using something like an ArrayList to bind you comboBox control, then the changes in the binded collection will not directly update the control collection.

However you can force this by calling SuspendBinding() and ResumeBinding() on the BindingContext. You might need to do something like this everytime you manipulate the collection..


// code...

BindingManagerBase bindingManagerBase = BindingContext[_documentTypeDTOList];


_documentTypeDTOList.Add(documentType); // manipulating and adding a new type at run
_documentTypeComboBox.DataSource = __documentTypeDTOList;

_documentTypeComboBox.DisplayMember = "Name";



DataBindings in C# .net

I found this interesting in C# the other day I was working on some GUI code. One can actually bind a widget (eg:- ComboBox to an IList ). The IList can be a collection of objects of any custom class, maybe even a DTO.

So if I have my custom class as

class DocumentTypeDTO
public string Name
return _name;
public string Type
public string Code

I can actually bind my control to an array of DTOs .

_documentTypeComboBox.DataSource = documentTypeDTOs;

To specify what member has to be used for display, I have a DisplayMember setter on my widget which takes a property name string.

_documentTypeComboBox.DisplayMember = "Name";

I can also define the value which will get picked up on the selection of a combobox item by:

_documentTypeComboBox.ValueMember = "Code";

Apparently .net uses reflection to get the members out . Sweet !!

Sunday, January 30, 2005

Pair Programming with Pair rotation

My colleague Vivek once blogged about the way we pair in our team. I would say it is like an acquired taste, some people like to pair and some do not. I used to hate pairing earlier , until in this project we started rotating pairs frequently. You get a chance to work with a different person every day, and get a different view of the codebase. Opinions vary and often new ideas come out.

To contrast what Vivek had written , our team size has scaled down temporarily to only 2 developers. Hence I am "stuck" with the same pair. What now happens is that we have developed almost the same kinds of opinion about the code. Over a period of time , it becomes really boring because you for sure know what your "life long" pair is thinking. So if this pair does not beleive in test-first development, you will never get a chance to do that as long as you pair with the same pair. That is probably why I feel we should change pairs after a max of 2 days. Best is to rotate pairs , when finished with a reasonably sized chunk of task.
There is definitely something to learn from every team member. Pair rotation gives you a chance to learn by working with each member closely.
Brent, Paul and I came up with 6 commandments for Pair Programming in our team .
  1. No story work without a pair ..... ever.
  2. Switch pairs often, ideally at the end of a reasonably sized task.
  3. No heroes in the team. ( Everyone knows about the codebase well enough )
  4. After pair switch , newbie to the story must drive.
  5. Driver cannot drive for more than 10 minutes straight.
  6. Driver should think out loud especially if it relates to lunch. ;-)

This worked well for a small sized team , a max of 4 pairs. Wonder what are the experiences in larger XP teams ...?

Standup meeting - Talking token

One of the most common practices in XP teams is to have Standup meetings. Each team member starts by giving an update on what they did yesterday, what they are going to do today and any issues they are facing without actually trying to solve them in the meeting.

This works fine till one of the team member starts discussing a critical issue (eg:- "Oh the build machine is not working because...") , and every member starts voicing there own opinions. Sure recipe for a meeting hijack and future chaos !

We used something called a Talking Token. It can be something from a Kush Ball to a Hockey Stick. The token must be passed around, and each team member has the right to talk if he has the token. If you wish to voice an opinion, on an issue which someone else is discussing, wait for him to finish, and signal (mostly non verbal gesture preferable) for the token. This way we ensured that when one person talks everyone in the team listens patiently. More importantly , in big team standups, they atleast know who is talking.
I had read somewhere that a talking token should be a really heavy object (Like a 10 pound ball ?), and the speaker should hold out the token by stretching his hand. This would ensure that a person cannot speak for more than the ideal 3 minutes or so. Whew!

Sunday, January 23, 2005

A nice end to my birthday

Something different which I did to spend yesterday evening, was to watch a set of plays by Naseeruddin Shah called Katha Collage. This was the first time I had gone to watch a play, and to tell you what , the experience was amazing.

The dialogues, the sets, the music , and above all the acting was indeed mind blowing. No take, no retake, putting up such an awsome and hillarious performance , definitely deserved a standing ovation from all of us in the audience!

Wednesday, January 19, 2005

Working for a Services Firm in India isnt always fun..

I work for an American services/consulting company , which has one of its offices here in Bangalore. In my past 2 years, I have been through a lot of projects and met a lot of new consultants.

The most weird part of the services industry is that most of the Indian consultants, just want to go client sites ("go abroad", "go onsite", whatever u wanna call that ) and make a quick buck. The passion and even the intention to successfully deliver the project you are currently doing is really missing in these people. All they think is "When will they send me to US ? ", "How can I increase my stay there ?", etc... As a team member , when u see your colleagues working with this kind of attitude, it is very discouraging.

From what I hear from a lot of my friends, I guess it is to a lesser extent in my firm , than in a lot of Indian MNCs, who still encourage body shopping ! Wondering when will that change !
There is more to it when people's priorities are like these. They tend to manipulate at work and try to get into the spotlight of their bosses, which in my opinion, is the worst to happen.

Monday, January 17, 2005

Microsoft Support Rocks !!

It was my first experience with Microsoft Support. We were facing a problem of not being able to debug an Office (Word , Excel etc..) Addin component we were devloping under Through some of our contacts in Thoughtworks, we manged to get in touch with an XP Evangelist and BdotNet member Deepak Gulati in Microsoft itself. He promptly put us in touch with Leo, a Microsoft Support Engineer whose expertise was in Development Tools etc..
Leo was amazing in solving the issues we were facing, with regards to following up with us, and even accessing our machine with Remote Assistance to fix the problem.
He also made us understand that we were unable to debug the word Addin due to a conflict of dlls b/w (1.1 and 2.0 beta) . The problem was more so , because we were copying the dlls to the Word install directory for Word to pickup, which was not required, since Word picks it up from the install directory itself.
Now you know that if you are developing using Microsoft Tools and you have a problem which is out of your reach, you know whom to contact with your MSDN subscription.
Microsoft Support Rocks !

Tuesday, January 11, 2005

The Microsoft COM hell

In my current project we have a short release which involves writing addins for Microsoft components like Word, Excel Outlook etc.. It might sound cool until you actually get into writing some COM interop code.

There are some funny things you might need to do when you are calling a class in another namespace from your office addin, i.e doing an interop.

  • Firstly you need to have a Guid for identifiying the interop class. This apparently is used for registering this class as an interop in the registry
  • Secondly you need to set a property at the project level in, "Register for COM interop = true".
  • If you are using an installer , the you need to make sure that in the properties of this project , you have the property "Register" set to "vsdraCOM".

If that is not enough, if you do not do any of the above, you do not get any pretty error messages that tell you to do so. Your addin might just stop working all of a sudden or will work on one box and stop working on the other. Hmpf!!

To add to all this, the documentation for COM is really pathetic , even in MSDN. The best resource for you are blogs of those unfortunate developers , who have suffered the pain and agony of working with Microsoft components

Sunday, January 09, 2005

We are still backward in Urban India

For quite some time I have been wondering about how mature is the thinking of people in our Urban households. I got reminded of the same when I was watching the movie Swades. We show in big screen that a lot of castism and bias based on religion is prevalent in rural areas of the country. I went ahead asking myself the same question , in the context of our urban households.
For an important thing as marriage, we are still looking for bride/groom from the same caste , relegion sect etc.. IMHO this is true for almost 70% of the educated Indian citizens living in big towns and cities. We have still not been able to educate our own parents/relatives/friends to be more mature and broad minded in their thinking., which is really sad.

But there are definitely some people who are trying to do their very bit in the urban society. For example, Times of India Matrimonials, give a 10% discount on ads which do not demand caste and relgion. Way to go Times !

Sunday, January 02, 2005

Development can be fun if the team is Self Organizing

I have been working over 8 months as a developer in an XP team. From the beginning itself the team had been striving to be self organizing, in terms of the tasks we pick up everyday, to how we execute them. A typical day for me started by giving a small update to the whole team , during a standup meeting, then picking up one of the many tasks lined up for the day. This was amazing because every other day, I was allowed to choose what kind of task I wanted to do.

And you signup for the task, with another person and form a pair. When the pair is finished with a reasonably sized chunk of task , we decide to switch pairs, normally this happens the next day.
This allowed us to work closely with all the people in the team, instead of being stuck with one pair for weeks ! (C'mon what if that one pair never took bath..huh !)

Every pair was free to decide how they wanted to go about executing a task in hand. They were free to make any technical decisions. A lot of us , got to the whiteboard at times to draw diagrams, but we were all developers and no one was a so called funky architect. Of course , at a later stage we did form a common metaphor for the project.

Indeed we have an iteration manager for the team, but he was amazing in managing the client expectations, and abstracting the team from a lot of unnecessary client pressure.

Yes there are many ups and downs in such a teams lifecycle which might blog about later. But there is a brief and interesting article here :
which some of you might be interested.

Saturday, January 01, 2005

A Silent Welcome to 2005

One of my new year resolutions was to start blogging. And hence this exists.. !