Monday, June 07, 2010

Programming and Home-making

What a tedium it used to look to write functions, let alone classes! During my ME, while I was generally regarded as a good programmer, my obsession with good programming practices was almost jeered at by my colleagues. Once, one labmate of mine had some programming issue which he said he wished to take my help in. While I waited later for a few days, he never came to me. Finally, I asked him what happened. He said that he was afraid I would use a lot of functions in the program which would then make it difficult for him to understand it. Instead, he had taken help of another PhD student there. He had made a program which was one straight line monolithic piece of code with not a single function call. Then I had felt funny. These people are definitely stupid -- incapable of appreciating the beauty of programming, I had thought.

About a decade afterwards, starting to live with a wife who was pedantically disciplined in keeping the household in shape was a shock. It was a toilsome process to learn that each thing had to have a designated place for itself, and that every time after being used it was supposed to be put back to that place. It automatically created an entry barrier to introducing housing articles. The process of procuring a domestic article was invariably accompanied by the process of figuring out where it would sit. The need to avoid cluttering the house with unnecessary articles was paramountly important. The household must be lean and mean. It was more in the fear of meeting with angry stares and words from the better half than from any real appreciation of the method that I learned it.

I haven't changed much fundamentally. I am still a bit untidy and need some monitoring to keep things in place; I am very much absent-minded and need uncountable reminders to keep doing my stuff. But, where I have really changed is in my appreciation of that household discipline that I had to initially imbibe with so much unwillingness. Now, I can see how similar it is to maintain the household in order to the problem of writing a large and complex computer program that is usable and enhancable by others. Same principles apply.

Intuitive variable/function/class naming; using of namespaces/packages and folders to arrange the source code, these are all programming parallels to the discipline of having a place for everything and everything in its place. Encapsulation and modularisation are similar to the division of responsibilities. Maintaining punctuality at home is not so much about mindless discipline. It's objective is the same as that of the discipline of concurrent programming -- to optimise use of processors, to about race-conditions and deadlocks, to keep multiple threads/processes from interfering with each other in destructive manner. All this eventually boils down to good timing. Each process doing its job isn't enough; it must do it when it's supposed to, so that other processes who arrive expecting a readymade output from the process don't have to wait.

Now I am surprised how, in my younger days, I couldn't see that what good principles and practices apply to my intellectual life are applicable to my day to day life too. In fact, I would go to the extent of saying that loyalty to good methods in professional life, if not present to the personal life, loses much of its meaning.

Related post:

5S -- the Management Mantra of Tidiness


Pritesh said...

A very nice post Sujit. I don't think I would go as far as saying that meticulousness (and in my case intuitive capability to know what ratios would work) can translate one-on-one to personal dealings as well. I can boast of a nearly 100% success rate in chemical reactions I carry out, intuitively knowing that they will work. But in cooking, when I experiment with a new combination of spices, this intuition just disappears. And I didn't realize this until Ananth pointed this out the other day.

I guess, there is to be given some credit to the fact that we're 'trained' to a good degree in our professional fields. Such a thing generally isn't applicable to living a life. Yes, most of us do get scolded by mothers for not being clean etc, it isn't equivalent to having been given hours and hours of classes and of course, exams and marks.

So, when I probably estimate chemicals' response to a reaction in my head, there is a lot of 'knowledge base' that goes into it without my knowing it. No one formally teaches the effect of spices and when I experiment with them, it's a much smaller knowledge base. So, as a chemist, I can proudly say that my work rarely fails but as a cook? Nopes.

I guess, your programming vs. house-organizing meticulousness is suffering from a similar difference. And besides, Shilpi di has a certain 'training' from how things were in her house and what 'she' thinks is a logical place for something. But my marriage of 11 months has taught me, "logic" isn't as objective as it's made out to be. Please refer to my 'Husbands' post on my blog and you'll know why I say this! :-)

PS: These differences due to subjective logic make for a lot of spice and fun in marriage and I wouldn't trade them for anything :-)

fuse me said...

I think good practices are good only if they can be applied. If you are writing a piece of code which is likely to be used by several generations of programmers or by several groups of programmers, then it better have extremely meticulous methodology. But on the other hand, if you are writing a code which should simply work for now and everyone, including you is going to forget about it in a while, then it does not make sense to use good programming practices and waste time on the logistics, overhead and planning that is associated with good practices. It works the same for house-keeping too. If you are the only person in your house, then why waste time organizing it using best practices. If it is just the two of you, then why waste time and effort organizing more than you require? In my opinion, good practices are good practices if they serve a higher purpose. If not following certain practices is likely to lead to future problems then it better be followed.

The way I organize my space may seem haphazard to everyone but me. It isn't haphazard for me, because I know how I spread my things out. Very rarely would I actually have to search for something in my room (also that it was very small.) But when both of us are using it, and now a third person, it better be convenient to use for everyone in the question. I think I adapted to Pritesh's style of organizing things pretty quickly, and sometimes I point out to her where she had kept a certain thing, because I got her system of organization explained to me. Now I can follow it like my own.

Sambaran said...

Sujit, the following links might interest you. It seems to me that you are already practising what is preached here:

Sujit Kumar Chakrabarti said...

Pritesh, the idea about years of training is true. Perhaps, trying to target 100% methodicalness in a non-competence area upfront is a prescription for failure. But, I still find two things very interesting:
1. the consciousness of the fact that certain principles apply to many more things than we imagine in the start
2. the parallels that I am able to draw between two different looking things.

Ananth, I feel there's also an overhead associated with the decision-making whether to be methodical or not. One has to be careful in being too flexible on that. Regarding programming, I work at just the level where I never know if my code will be read by anyone or not. Mine are mostly prototypes which don't get used at all, and in certain cases have become crucial tools for software engineering teams. And while programming I never realise which of my programs will get used by others. As far as my own programming goes, I re-use to a wild extend what I have programmed and designed earlier, sometimes years earlier. You will find a lot of similarity in the programs I write now and those I had written in the early days of my Phd. Not because I haven't grown as a programmer, but because there's a significant amount of copy-paste. So, I would feel free to sell myself to the idea of neat programming any day. It works for me! :) I am newer to the trade of homemaking. But I sell myself cheaply to the idea of neatness there too, albiet for different reason -- I'm saved from working out things myself by accepting someone else's (wife's) methods! :)

Sujit Kumar Chakrabarti said...

...and Ayan, Anya is very cute. We still fondly keep talking about her 'Oh dear!' Please kiss her on my hehalf.