tag:blogger.com,1999:blog-168891652008-09-25T10:20:06.384+05:30Mentioned In DispatchesManoj Govindan's BlogManoj Govindanhttp://www.blogger.com/profile/12734036974316245850noreply@blogger.comBlogger30125tag:blogger.com,1999:blog-16889165.post-45261212824290826482008-09-25T10:16:00.004+05:302008-09-25T10:20:06.391+05:302008-09-25T10:20:06.391+05:30Sabbatical Update #2I completed Chapter 2 of <a href="http://mitpress.mit.edu/sicp/">SICP</a> yesterday. I am taking the day off from my regularly scheduled activities to rest and recuperate and also to write this mini-report. <br/><br/> While chapter 1 was definitely interesting the second chapter was far more meatier in terms of fundamental concepts presented and explored. I have written code mostly in Python and Java and had very conventional notions of 'data' in the programming context. The authors of SICP challenge that notion almost right from the beginning of the chapter. They present - and illustrate - the idea that data can be thought of as "some collection of selectors and constructors, together with specified conditions that these procedures must fulfill in order to be a valid representation". The rest of the chapter builds on this fundamental concept working on more complex data including a mini "picture language". <br/><br/> It took me some time to digest this idea and longer to deal with some of the exercises. One particular exercise involved implementing <a href="http://en.wikipedia.org/wiki/Church_encoding">Church Numerals</a> using Scheme. Church Numerals are the brain child of mathematician <a href="http://en.wikipedia.org/wiki/Alonzo_Church">Alonzo Church</a> who first described a way to embed data and operators into lambda calculus. I thought the name 'Church Numerals' was a misnomer seeing that these were not 'numerals' in any way I have come to understand :-P Jokes aside the exercise was thought provoking. In case you were wondering this is what "0" and "1" look like: <br/> <pre> ;; zero (define zero (lambda (f) (lambda (x) x))) ;; one (define one (lambda (f) (lambda (x) (f x)))) </pre> <br/> I later realized that my troubles arose from my focus on the <span style="font-style:italic;">form</span> of numbers rather than the <span style="font-style:italic;">function</span> they served. Once I understood the distinction between the two it became easier to address the problem. <br/><br/> On a related note I will be putting up my solutions to the SICP problems shortly, starting with Chapter 2. <br/>Manoj Govindanhttp://www.blogger.com/profile/12734036974316245850noreply@blogger.comtag:blogger.com,1999:blog-16889165.post-4242397271852506932008-08-13T21:05:00.002+05:302008-08-14T10:27:23.297+05:302008-08-14T10:27:23.297+05:30Another Recital and Related ThoughtsI played the Piano at a small recital organised in my teacher's home last month. This was my second recital this year. I played two pieces - Theme and Variations by <a href="http://en.wikipedia.org/wiki/Theodor_Kullak">Theodore Kullak</a> and Rocking Horse Ride (Opus 98, No. 5) by <a href="http://en.wikipedia.org/wiki/Alexander_Gretchaninov">Alexander Gretchaninov</a>. Kullak's piece presents a theme followed by five variations of that theme. The hand positions are fixed and the tempo increases in the fourth and fifth variations. 'Rocking Horse Ride' is taken from Gretchaninov's 'Children's Book'. It tells about a rocking horse that starts off slowly enough but soon accelerates and almost rocks too far. But all is well in the end. <br/><br/> The single most important difference from my <a href="http://lawfulsamurai.blogspot.com/2008/02/recital.html">previous recital</a> was my increased confidence. This was not entirely surprising given that I had prepared myself better this time around. It helped that I had been out of work for a couple of weeks before D-Day. And I forced myself to take a quick nap in the afternoon before the event. It was a refreshing contrast from the previous before-recital afternoon when I was tightly wound up and excited. <br/><br/> All of it paid off in the end. I did not mess up any notes but I did feel that I could have done better on the dynamics. <br/><br/> On a related note I was told that my music practice had noticeably improved ever since I left my job. This was a bit surprising especially since I had not drastically lengthened my practice sessions. I think reduced stress levels made most of the difference. In retrospect I can see that work had been so draining that I had become used to being perpetually wound up and did not notice how it was degrading the quality of my life. <br/><br/> I don't seem to be the alone in being stressed out. I learned from my teacher that there was a time when recitals were far more frequent. According to her pupils these days (that includes me) take much longer to get ready for a recital. She stressed how barely half a generation ago pupils - who were also at school, had a job or were otherwise busy - were somehow able to find time to do justice to music. With every passing year pupils seem to have less and less time to practice, or indeed to focus on anything much outside work. <br/><br/> I have decided to actively combat stress the next time I start working a job. This would mean working regular hours, leaving work behind on stepping out of the office, learning to turn off my phone after hours and during weekends. I don't know how I'll achieve all these but I certainly am not going to let work deprive me of life again. <br/>Manoj Govindanhttp://www.blogger.com/profile/12734036974316245850noreply@blogger.comtag:blogger.com,1999:blog-16889165.post-18067467370591286042008-08-10T11:33:00.006+05:302008-08-10T11:46:08.341+05:302008-08-10T11:46:08.341+05:30State of the SabbaticalYesterday marked the end of the first month of my sabbatical. I used the opportunity to sit back and take stock of how far I have progressed towards achieving my goals. For the record I started on my sabbatical aiming to achieve the following before November: <ol> <li>Work through <a href="http://mitpress.mit.edu/sicp/">Structure and Interpretation of Computer Programs</a> (SICP), exercises and all</li> <li>Learn to play Muzio Clementi's <a href="http://manojgovindan.com/music/sonatina-36-1-a4.pdf">Sonatina in C Major</a> (Opus 36 No. 1) well enough to give a recital</li> <li>Read one (non fiction) book every fortnight</li> </ol> Here follows then a quick summary of the state of the sabbatical. <br/><br/> At the time of writing this I have completed the first of five chapters of SICP and started on the second. I am presently working on the second of three movements of the Sonatina. I finished reading '<a href="http://www.amazon.com/Audacity-Hope-Thoughts-Reclaiming-American/dp/0307237699">The Audacity of Hope</a>' and am looking for another book. <br/><br/> Working through SICP is proving to be an eye opener. The exercises look deceptively simple until you try to work them out. I was *very* frustrated in the beginning but am learning relax and re-focus. Some of the ideas took a while to wrap my mind around due to various factors. I had never worked in Scheme before and found it difficult to write programs without explicit looping constructs and variable assignment. For this reason the Chapter 1 exercises dealing with converting recursive procedures to iterative and vice-versa troubled me for several days. I was shocked to notice how long it took me to understand and digest fundamental concepts like lambda. Easy work in enterprise software for 8 plus years seems to have damaged most of my gray cells :( <br/><br/> The Sonatina is proving tough to crack. The first movement was relatively simple. But then came the second movement with its triplets, trills and one-sixteenth notes. It quickly deprived me of the warm glow of working through the first. So far I have hammed my way through five lines. The last line is adamantly refusing to submit. <br/><br/> 'The Audacity of Hope' is a very engrossing read. It is rare to see a politician writing for himself without relying on ghost writers. It was evident after reading the book that Senator Obama can not only write for himself but matches his words with sharp thought and keen observations. <br/><br/> That is all in this week's report. More soon. <br/>Manoj Govindanhttp://www.blogger.com/profile/12734036974316245850noreply@blogger.comtag:blogger.com,1999:blog-16889165.post-70458953068652377442008-04-23T15:12:00.005+05:302008-04-23T15:51:02.264+05:302008-04-23T15:51:02.264+05:30Stuck in a Time FrameThe topic of some mutual friends came up during a recent conversation I had with a friend. After I filled her in about their whereabouts and activities she remarked that said friends and yours truly were "stuck in a time frame". I understood what she meant in the context of our conversation. I realised that she had merely expressed in a catchy phrase an opinion others had expressed before using different words. In order to fully understand the import of 'stuck in a time frame' I will first try to illustrate its opposite concept. 'Moving through time frames', if you will. <br/><br/> The basis of my explanation is my understanding that the (suburban, educated) Indian society expects individuals to live their life in a certain way based on their age "time frame". In Kerala the teen years are considered to be the time for education. You are expected to be in college by your late teens. Some of the non-curricular pursuits of a typical student include dabbling in new hobbies and other activities. These are mostly but not always tolerated. For instance I picked up <a href="http://indiawargamers.com">Miniature Wargaming</a> as a hobby in college. I hasten to add that individuals are expected to outgrow their hobbies or interests as they move on to the next stage in life. <br/><br/> For my generation a person's twenties is the time for seeking gainful employment, sometimes after completing higher studies. As travelling overseas became more common and affordable people were expected to switch to "explore" mode after landing a job. Non-curricular activities of this time frame include visiting various places, picking up hobbies that are made more affordable by technology etc. Most notable among the latter is Photography. Of course there are people I know who used to save their allowances to make money for Photography while in college but that is another story. <br/><br/> Mid to late twenties, as I was told by more than one person, is the time to move on again. Marriage is *the* key social event marking the end of this time frame. This is such a strong social expectation that unmarried people are treated almost as if they are in mortal danger and pose a threat to others. It is common for bachelors and spinsters to be asked even by virtual strangers why they haven't married. Marriage itself is the outcome of a filtration process demanded by society and community and initiated by parents. Criteria of filtration include religion, caste, community, state, and language to mention a few. A list of desirables passing the filter conditions is presented to the "end user" and he or she can pick any one. There indeed are exceptions but these remain a very small minority. <br/><br/> A man in his thirties is expected to start a family and "engage society more actively". "Engaging society" means, among other things, actively participating in social events that you were given permission to avoid as a twenty-something. Hobbies are frowned upon unless they are strictly mainstream. Non work related pursuits are allowed as long as they are for buying a new car, apartment or real estate. <br/><br/> I don't know quite clearly what my generation is expected to do in our forties, fifties and subsequent decades. I speculate that our forties would be the time to focus on children and career growth punctuated by the occasional mid life crisis. The fifties would be time to coordinate marriages of children born to the Indian software generation. <br/><br/> It is interesting to note how a bit of this progression is reflected in the photo galleries of a social networking site popular with Indians. First, snaps of the protagonist in various places around the globe. Some capture their first car or apartment. Marriage photos and pictures of the sweetheart appear some time later. These are in turn replaced by pictures of children and group photographs. <br/><br/> Coming back to my conversation I found that my friend's opinion was apparently based on her observations of the individuals' lives. None of the people we discussed including yours truly had "moved on" as she expected. At least two in the list are pursuing higher studies in their thirties, that too in subjects not necessarily related to their present careers. Three are not married and don't plan to. Not to mention their hobbies. I counted several different hobbies in the group ranging from dancing to miniature wargaming to semi-professional poker to playing the <span style="font-style:italic;"><a href="http://en.wikipedia.org/wiki/Mridangam">Mridangam</a></span>. <br/><br/> I told my friend that all the people we discussed had merely chosen to define the (time) segments making up their life differently. I was not convinced by her arguments that one should drastically change his outlook on life for the sole purpose of meeting popular definitions of "moving on". As far as I see each one of these people *have* been moving on. They are more skilled, know more about their favourite subjects now than they did five years ago and are by no means staying still in any of their chosen fields of endeavour. If anything almost all of them rue that they are not moving forward as fast as they would like to. <br/>Manoj Govindanhttp://www.blogger.com/profile/12734036974316245850noreply@blogger.comtag:blogger.com,1999:blog-16889165.post-75482161910272254402008-04-18T13:06:00.007+05:302008-04-18T19:28:56.710+05:302008-04-18T19:28:56.710+05:30A Tale of Two MoviesThe acclaimed Malayalam movie '<a href="http://www.imdb.com/title/tt0353857/">Paithrikam</a>' came out in 1993, the year I finished school. Directed by Jayaraj the movie told the story of two generations of a <a href="http://en.wikipedia.org/wiki/Namboothiri">Kerala Brahmin</a> family. The father is a soft spoken orthodox Brahmin well respected in the community and a learned scholar-performer of rituals and <span style="font-style:italic;"><a href="http://en.wikipedia.org/wiki/Yajna">Yajnas</a></span>. His eldest son is a vocal atheist who is openly against theism in all its forms including his family's rituals and cloistered lifestyle. Caught between the two are a loving younger brother and a largely silent mother. The movie builds towards a confrontation between the beliefs of father and son culminating in a final act where the son undergoes a spiritual conversion and takes his father's place. <br/><br/> The movie is commendable on its own merits. However I remember it for different reasons. As a Brahmin I witnessed first hand how 'Paithrikam' became quite popular in the Brahmin community shortly after its release. For a while after the movie came out its name came up during conversations in many families including mine. Relatives had good things to say about the movie at family gatherings. I distinctly recall seeing advertisements for the movie endorsed by prominent Brahmin priests and scholars. These usually said something like "I strongly recommend everyone to watch it" or "a poignant narrative". I believe that for some people the movie came as an affirmation of their strongly held beliefs about the "superiority" of Brahmin culture and tradition. Some perceived the movie to be in agreement with their reservations against atheism and progressive trends in the community. <br/><br/> I will not discuss the merits of such beliefs but instead skip ahead to narrate the tale of another movie that came out barely a year later. Hariharan's '<a href="http://www.imdb.com/title/tt0230623/">Parinayam</a>', scripted by veteran Malayalam writer <a href="http://en.wikipedia.org/wiki/M._T._Vasudevan_Nair">M.T. Vasudevan Nair</a> also centred on a Brahmin family. The movie was set in the turbulent decades of late 19th and early 20th centuries that witnessed several changes in India's social order. The events portrayed in the movie occur not long after the Kerala Brahmin community was scandalised by the ritual trial of a Brahmin widow Savithri, alias Thathrikkutty, for adultery. The accused named no less than <span style="font-style:italic;">sixty four</span> prominent persons from different castes as her lovers. This was also the time when progressives led by reformers like <a href="http://en.wikipedia.org/wiki/V._T._Bhattathiripad">V.T. Bhattathirippad</a> organised a movement against social ills prevalent in the Brahmin community. <br/><br/> 'Parinayam' is the story of a young Brahmin girl who becomes the fourth wife, and widow shortly thereafter, of an old Brahmin lord. She becomes pregnant after her husband's death and is tried by a communal tribunal. The movie ends with her being cast out from home and community and starting an independent, defiant life with the help of her rebel/reformer stepson. <br/><br/> Here again the movie shines and can be enjoyed for its own merits. What I want to point out however is how this movie was hardly ever mentioned by the same people who were all praise for the earlier one. Going strictly by quantity and extent of Brahmin traditions portrayed the second movie should have attracted a much wider audience. And yet it failed to be even so much as mentioned in gatherings, much less admired. <br/><br/> Why this difference? I thought about this after I watched 'Parinayam' again very recently. I think that many in the Kerala Brahmin community are guilty of selective adoption and propagation of events defining its History. The dark tales are entirely left out when the story of a vibrant socio-religious past is told. Consequently many youngsters grow up with a skewed knowledge of history which only serves to enforce their illogical belief in superiority by virtue of birth in an "upper" caste. <br/><br/> In this context it is interesting to inspect how the community organisation formed by Bhattathirippad to combat social ills has evolved. What once was the refuge of rebels and progressives is now the gathering place for conservatives and the orthodox. Where membership was once a statement of rebellion today it is a bellwether of social prominence. <br/><br/> I have a firmly held belief that a person's caste has nothing to do with how good or bad a person he is. My beliefs aside I still wish that those who give importance to belonging to a community were more objective in drawing lessons from its past. For it is a fact of history that for every 'Paithrikam' there are all too many 'Parinayam's. <br/>Manoj Govindanhttp://www.blogger.com/profile/12734036974316245850noreply@blogger.comtag:blogger.com,1999:blog-16889165.post-45188876870434433402008-04-16T20:20:00.001+05:302008-04-16T20:24:29.861+05:302008-04-16T20:24:29.861+05:30Extreme Programming in ActionExtreme Programming has become more "mainstream" in the Indian software industry over the past couple of years. For many companies their agile development practices have provided a reason to brag and to attract recruits. One of my friends works for such a company and recently narrated an incident highlighting how "XP" is used in his workplace. I thought I should share it with the rest of the world to provide another perspective on how XP is actually used in Bangalore. <br/><br/> The specific case involved a particular task which came up for development. One of the developers said that it would take him 2 days to finish the task while another thought he could complete it in 3 days. A third predicted four days if he were to do the task. The team leader heard them all out and proceeded to *assign* the task to the third guy. If you are thinking "that's not how it is done in XP" - wait, the best is yet to come. The "leader" expected the "assigned" developer to finish the task in 2 days! <br/><br/> From what I heard the practice is not only widespread in the said organisation but some managers actually *coach* sceptical newcomers to believe that this "auction model" is a core tenet of XP. Those who disagreed are reprimanded for unwillingness to adhere to XP. <br/><br/> The next time someone from this place says "we follow XP" I am going to burst a gut laughing :) <br/>Manoj Govindanhttp://www.blogger.com/profile/12734036974316245850noreply@blogger.comtag:blogger.com,1999:blog-16889165.post-69033919438470838862008-04-14T19:24:00.006+05:302008-04-14T19:42:26.307+05:302008-04-14T19:42:26.307+05:30Of FestivalsMarch, April and May have traditionally been "festival months" in Kerala. Many Hindu temples (as well as a few houses of worship of other religions) celebrate socio-religious festivals during this season which also witnesses the <a href="http://en.wikipedia.org/wiki/Vishu">turn of the Malayalam year</a>. My trip home to Trivandrum earlier this month coincided with the annual festival at a nearby temple. It has been close to a decade since I was last home in time for the occasion. Several things have changed since then. Most notably the noise output has gone up considerably. Loudspeakers heralding the event covered an area approximately 1 Km in radius. As my house is well within this radius I got to hear music (live and recorded, instrumental and vocal), announcements, religious talks and other sounds almost around the clock. My five day visit completely overlapped with the festival's duration of 7 days to the effect that I was almost always raising my voice to talk to my family. <br/><br/> The loudspeakers usually came to life around 6.00 in the morning, more than an hour after the temple opened for the day. They would then blare "devotional songs" for the next three hours or so. The music was periodically interrupted for announcements. Going by voice these were all made by the same person. The announcer typically started by reciting the day's programme. He would then go on to thank individual donors whose contributions went towards paying for the day's events. Names, addresses and the events which benefited were included. He usually ended with a religious greeting. <br/><br/> The speakers were given a break around 10.00 AM coinciding with religious rituals in the temple. Unfortunately this break lasted barely an hour. The next "session" commenced with yet more songs and traditional instrumental music unless there happened to be a religious talk going on. Following another short break around noon the fare would continue well into the afternoon. Unexpected relief arrived on a couple of occasions thanks to the trusty summer afternoon rains. The lightning accompanying the showers forced the operators to shut down their makeshift Public Address system albeit for a short while. <br/><br/> The noise levels went down whenever a ritual was performed in the temple premises. After the main worship ceremony around 6.00 PM the racket would continue well into the night thanks to the "main cultural event" of the day. Such events tended to live performances of music, dance or comedy with the rare <span style="font-style:italic;"><a href="http://en.wikipedia.org/wiki/Kathakali">Kathakali</a></span> session thrown in for traditions' sake. Plays and movies used be a part of the fare ten years ago but have since been dropped. Live performances typically ended by 1.00 AM and the PA system shut down shortly thereafter. On one particular occasion however the music accompanying a Kathakali performance started around 10.00 PM and went on until after 4.00 AM the next morning. The best part was when the announcer came on right afterwards to announce - what else - the names and addresses of the donors! I have since been told that most donors actually expect their names to be aired prominently and repeatedly in exchange for their contributions. <br/><br/> The last day of the festivities was marked by a procession featuring <a href="http://en.wikipedia.org/wiki/Image:ThrissurPooram-Kuda.jpg">decorated elephants</a>. The procession left the temple in the evening and returned sometime after midnight. The sound of the traditional drums accompanying the procession was broadcast for a while until a solitary voice took over to chant "Om....." repeatedly. The chanting lasted for half an hour while the procession re-entered the temple. <br/><br/> Interestingly several otherwise sensitive people seemed not to mind the noise pollution. These were the same folks who bristled when a political party dared to broadcast musical propaganda or speeches for a half day long meeting. One of the supporters argued that there could be no comparison between "devotional music" and "political music". My argument that both impinged on the personal comfort of those not interested was dismissed with a wave of the hand. <br/><br/> I believe this question was posed before the courts some time ago. The only solid outcome of such litigation has been the replacement of old, noisy, ultra polluting horn speakers with modern box models. Very few abide by the prescribed decibel levels and timings. <br/>Manoj Govindanhttp://www.blogger.com/profile/12734036974316245850noreply@blogger.comtag:blogger.com,1999:blog-16889165.post-37973643151774853032008-03-24T20:20:00.002+05:302008-03-24T20:26:15.200+05:302008-03-24T20:26:15.200+05:30Meeting DijkstraI spent the last couple of weekends implementing <a href="http://en.wikipedia.org/wiki/Dijkstra's_algorithm">Dijkstra's Shortest Path</a> algorithm in Java. DSP is a fairly straight forward algorithm built on simple steps. Nevertheless I found it trickier than expected to convert it to code, my "work experience" and familiarity with Java notwithstanding. In the end I was able to work out a reasonable implementation after going through a few iterations. <br/><br/> I realised that in spite of working daily on a large body of code I was out of shape programming wise when it came to implementing algorithms. Part of the reason is my own average skill level; part of it is how rarely I tangle with algorithms at work. I suspect that this is the case with most programming jobs in town. There are other reasons as well not least of them being that algorithms require considerable thought to translate to code. <br/><br/> One of the interesting problems I faced had concerned representing the domain in code. For instance DSP works on Graphs made up of Vertices connected by Edges. It was fun to work out how to represent a Graph programmatically. In the end I chose method #1 suggested by Cormen et al., namely maintain <a href="http://books.google.co.in/books?id=NLngYyWFl_YC&pg=PA527&lpg=PA527&dq=cormen++representing+graph&source=web&ots=BwNsDF-jK5&sig=kqYNk99JvY4Q7vqCf-Cfzig72Sg&hl=en#PPA527,M1">Adjacency Lists</a>. <br/><br/> Overall I found getting back in touch with the fundamentals an enjoyable experience. I plan to take this exercise further over the course of the next six months by working through <a href="http://www.amazon.com/Introduction-Algorithms-Electrical-Engineering-Computer/dp/0262031418">Introduction to Algorithms</a>. In the end I hope to emerge with a better understanding of the fundamentals. <br/>Manoj Govindanhttp://www.blogger.com/profile/12734036974316245850noreply@blogger.comtag:blogger.com,1999:blog-16889165.post-49790431279834112072008-03-14T12:15:00.010+05:302008-03-17T09:40:33.815+05:302008-03-17T09:40:33.815+05:30A Sabbatical TestOne of my friends recently acted on his wish to take some time off from work. He just started a three month break from work. Every now and then I think about taking some time off from work myself. After watching my friend leave town for his sabbatical I gave the topic some active consideration. I realised that while the idea of taking time off from work was very tempting I would have to plan extensively to make it serve my purpose. Following a thought exercise I came up with a check list of things to accomplish before I can take time off. Note that the ordering is random. <br/><br/> 1. <span style="font-weight:bold;">Build A Monetary Base</span>. I should have enough dough in the bank to cruise for the duration of my sabbatical. The time frame I have in mind is about a year. Whether I plan to leave Bangalore or stay in town makes a big difference in the estimate. I can think of a couple of other places that are cheaper but have other, outweighing disadvantages. For instance Chennai is too hot, Trivandrum is too remote and I don't know anyone in Pune :) <br/><br/> 2. <span style="font-weight:bold;">Plan Ahead</span>. I have wasted far too many weekends for lack of proper planning. I do not wish to repeat this mistake during my sabbatical. I will have to work out a clear, weekly (or at least monthly) plan before I start my break. <br/><br/> 3. <span style="font-weight:bold;">Establish Habits In Advance</span>. This follows from #2. I know from experience that even optimistic plans fail because I am not used performing a particular set of tasks regularly. Mental exercise is similar to physical exercise in this context. Even a modestly mind-intensive schedule needs a period of "warming up". I would rather do all the warming up work before I start rather than use the first days/weeks/months of the sabbatical for the same. This involves enforcing basic habits like going to bed and getting up at regular times, not getting "lost" for (unplanned)hours in a task however exciting it is etc. <br/><br/> 4. <span style="font-weight:bold;">Establish A Ready-to-expand Routine</span>. This derives from #2 and #3. I spend around 10 hours at work each day including getting there and back. While all non-work activities look very attractive from the workplace it is not easy to effectively use the 10 hour or so of daily unstructured time that follows leaving work. One solution for the weak minded like me would be to establish in advance a routine that is "ready to expand". In other words I should use the time available to me *after work* every day to the maximum extent possible. Ideally this should lead to a point where any time off from work would be easily filled by one or more of the activities I have been doing. <br/><br/> Good examples include music practice and coding. Say I can spare 90 minutes for music practice each day, split into two 45 minute sessions before and after work. If I can take up a suitably complex piece that demands more than 90 minutes daily and work on it regularly for exactly 90 minutes a day then I would be making progress on conditions #3 and #4. <br/><br/> Similarly I should be able to pick up a a challenging programming goal and spend a fixed quantity of time, say 90 minutes, each day for a suitably long period. <br/><br/> Another important aspect in my case would be to perform *all* tasks *every* day. I don't think it would be realistic to divide a sabbatical into two or more consecutive periods where I only work on any one thing at a time. IMHO the key to making a sabbatical work is to make a little progress on all fronts every day. <br/><br/> 5. <span style="font-weight:bold;">Set "Service Level Agreements" For Friends And Family</span>. IMHO a sabbatical is *not* a vacation. It is a life project with specific time duration and goals. I should make it clear to friends and family that just because I am "out of a job" they shouldn't expect me to spend additional time/energy thus gained on lengthy visits or other activities. If anything I expect to be busier during a sabbatical than I would have been while working. <br/><br/> <span style="font-weight:bold;">Update</span>: One of my friends who wishes to remain anonymous had this useful point to add: "<span style="font-style:italic;">Having a test (to be taken at the end of the period or at specific times) to check whether the purpose of the sabbatical has been achieved will be useful too. The act of coming up with the test will bring the why (take the sabbatical) question into focus. I suppose this will be an outcome of the planning activity.</span>" <br/>Manoj Govindanhttp://www.blogger.com/profile/12734036974316245850noreply@blogger.comtag:blogger.com,1999:blog-16889165.post-30656420828673232692008-02-28T13:34:00.003+05:302008-02-28T13:38:13.647+05:302008-02-28T13:38:13.647+05:30RecitalI played the Piano at a small recital organised in my teacher's home last Sunday. My piece was a <a href="http://www.musicstudents.com/archive/pdf/pian085.pdf">Sonatina in C Major</a> (Opus 34, No. 1) written by <a href="http://en.wikipedia.org/wiki/Johann_Anton_Andr%C3%A9">Johann Anton André</a>. The piece has two movements, a song like moderato followed by a lively Rondo. The event came at the end of slightly more than a year of lessons. Last year at a similar event I was a novice sitting with the audience marveling at the performances. This year it was my turn to get behind the keys. <br/><br/> Unfortunately for me two of my friends were in attendance in spite of my best efforts to prevent them from coming. When my turn came I found myself quite nervous to even approach the "stage", in this case the piano in the middle of the living room. This came as a surprise. I was a public speaker in college and in spite of my many faults have never had a case of stage fright. Playing a well rehearsed piece for 25 odd people should have been easy, but wasn't because I was very anxious about missing a note or phrase. <br/><br/> As it turned out I ended up making mistakes in a couple of places in the first movement. I did not die on the spot; on the contrary I began to relax after completing the first few lines. The second movement went fairly well even if I say so myself. <br/><br/> I don't recall much about the audience reaction. I do recall that my friends did not boo but then they were not experienced enough to have recognised my mistakes :) Tasty refreshments were served afterward but my body was awash in adrenalin for me to work up much of an appetite. <br/><br/> In retrospect the recital was a good experience. It made me realise the need for any student of music to periodically perform in a (semi-)public setting. I would like to be a part of more such events in the future. These need not even be on the same scale as my recital. A group of four or five would suffice. Perhaps these events can be arranged along the lines of the very useful "losers club" meetings I have attended. I can think of several advantages of such gatherings. Besides bolstering their confidence attendees also get valuable feedback. The "mini-recital" format would force all to focus on coming up with measurable output (play a piece) as opposed to talking about it ("I practiced for a total of 15 hours last month"). I am talking to a couple of musically inclined friends to see if we can come up with something worthwhile. Let me see how it works out.Manoj Govindanhttp://www.blogger.com/profile/12734036974316245850noreply@blogger.comtag:blogger.com,1999:blog-16889165.post-80083314806675801812008-02-25T11:24:00.006+05:302008-02-25T11:34:53.442+05:302008-02-25T11:34:53.442+05:30What am I writing?I started the year with a resolution to write more frequently. Specifically I had set myself a goal to write four blog entries a month and thereby work up a total of 52 by the end of the year. As the second month draws to a close I am three entries short (if I count this one as well) and trying hard to catch up. The question is, what do I write about? <br/><br/> I had a discussion with a friend where the same question popped up. I mentioned that I was not sure what to write. He suggested that I ask myself this question: "What would I discuss with a friend if we had 30 minutes to spare?". The question yielded instant results (not entirely surprising given my propensity to talk). There are indeed a bunch of things I would like to talk about with my friends. Here is a partial list. <br/> <ul> <li>Learning (How to have a day job *and* find time and energy to learn; learning "methodologies")</li> <li>Programming (how to use it as a tool to help learning)</li> <li>Hobby - <a href="http://indiawargamers.com/">Miniature Wargaming</a></li> <li>Hobby - Music (practice, objectives, tips and tricks)</li> <li>Tackling the rest of my life (Post Three-Oh blues)</li> <li>Movies and Books</li> <li>History</li> <li>Current Affairs</li> <li>Living in Bangalore</li> <li>Travel plans</li> </ul> <br/> You may have noticed that whatever I have written so far falls under just a few topics in the above list. In retrospect it is evident that I have been writing only about those topics which I thought "people would want to read about". This is not helpful for many reasons. First of all it forced me to think about guessing what "people" liked to read rather than focusing on what *I want to write about*. Such a filter also impeded writing frequently and making enough mistakes to learn from and improve. <br/><br/> Also I have found that writing something down crystallises my thoughts. The absence of writing frequently leads to vague, half-baked ideas and thoughts. <br/><br/> To make up for my mistakes I have decided to actively implement my resolution in the coming weeks and months. I will try my best to write at least one entry a week. Expect to see me back shortly.Manoj Govindanhttp://www.blogger.com/profile/12734036974316245850noreply@blogger.comtag:blogger.com,1999:blog-16889165.post-5472779795693976502008-02-14T15:54:00.005+05:302008-02-14T16:04:53.225+05:302008-02-14T16:04:53.225+05:30Who can conduct a Devcamp?I <a href="http://lawfulsamurai.blogspot.com/2008/02/notes-from-devcamp-bangalore.html">liked</a> the recently concluded <a href="http://devcamp.in/wiki/Main_Page">Devcamp Bangalore</a> well enough to hope for more of its kind. My thoughts about future Devcamps led me to a question: what characteristics should a software company have to organise a successful Devcamp? Based on my inferences I came up with the following criteria. <br/><br/> 1. <span style="font-weight:bold;">Buy-in from Management</span>. I think one of the factors that worked in favour of Devcamp '08 is the way <a href="http://en.wikipedia.org/wiki/Unconference">unconferences</a> tie in nicely with the recruitment and PR strategies of <a href="http://www.thoughtworks.com/">ThoughtWorks</a>. Of course TW is just one example. The necessary precondition is that management should appreciate devcamps and work out ways to use them to help their business plans. <br/><br/> Recruitment is one department that can make obvious use of devcamps. However most software companies in India do little to ensure the actual quality of recruits beyond paying lip service to the "Quality over Quantity" mantra. <br/><br/> The PR value of devcamps may be difficult for traditional managers to understand. The subtle fact is that a well executed devcamp can make a company more popular with discerning developers than full page advertisements in technology magazines ever will. <br/><br/> There is also the question of participation. Unlike with barcamps most managers will find very little to do in a devcamp. The very nature of unconferences will ensure that there is no stage time for top brass who are used to delivering speeches at events organised by their companies. <br/><br/> 2. <span style="font-weight:bold;">Buy-in from Software Developers</span>. For any company to make its devcamp work its programmers should be actively involved. This in turn requires that developers have an active interest in software outside the demands of daily work. An useful metric would be the number of employees who are involved in open source projects. If a software company cannot muster a dozen developers who work with code of their own interest, let alone contribute to OSS projects, then chances are that devcamps will never be popular in such a place. <br/><br/> 3. <span style="font-weight:bold;">Infrastructure</span>. Around 200 people turned up for Devcamp '08 and many of them brought their laptops. Besides managing to squeeze all into their main office TW also put up a wireless network and served free lunch and refreshments. I think more people can be counted on to attend future devcamps. Any future organiser should be able to accommodate 200+ attendees and their computing machines. <br/><br/> 4. <span style="font-weight:bold;">Location, Location</span>. It matters which city and block devcamps are held. In Bangalore the distance from the city centre to the venue will directly affect attendance.Manoj Govindanhttp://www.blogger.com/profile/12734036974316245850noreply@blogger.comtag:blogger.com,1999:blog-16889165.post-46758177292113672112008-02-11T14:49:00.000+05:302008-02-11T15:57:04.087+05:302008-02-11T15:57:04.087+05:30Notes from Devcamp BangaloreI attended the first <a href="http://www.devcamp.in/">Devcamp</a> conducted last weekend at the <a href="http://www.thoughtworks.com/">ThoughtWorks</a> premises in Bangalore. What I liked most about the event was how it stayed more or less true to the goals - developers talking to developers. Unlike in previous barcamps a lot of speakers built their talks around code. Not surprisingly talks involving working code gave me the most returns on investment of time. I do wish some of the talks had gotten more time though. The 30 minute limit on time had a dampening effect on some of the talks. In some cases the speakers managed to get around this by extending their session into the lunch break. Some others booked two consecutive slots but I don't think this would be always encouraged. One way to avoid the problem in the future would be to change the time slots to 45 or 60 minutes. <br/><br/> I found time to attend six sessions. I was very impressed with <a href="http://ravimohan.blogspot.com/">Ravi</a>'s presentation on Monads. Not surprisingly there were a bunch of requests for an encore after his talk. <br/><br/> <a href="http://karthiksr.blogspot.com/">SRK</a>'s work on load testing using Erlang showed a lot of promise. He demonstrated how he was able to harness the unique strengths of Erlang to load test some of his applications. <br/><br/> In spite of my lack of knowledge I could tell that <a href="http://www.jroller.com/viveksingh123/">Vivek Singh</a> was on to something with his new tool for testing Windows applications, '<a href="http://www.codeplex.com/white">White</a>'. More power to him. <br/><br/> I spoke about my experiences developing a hobby related <a href="http://indiawargamers.com/resources/beat_the_drum.html">application</a> using <a href="http://www.djangoproject.com/">Django</a>. Somehow the projector refused to work with my laptop running Ubuntu Feisty in spite of the best attentions of a system administrator. To be fair mine is an old laptop(4+ years) and I should have ensured beforehand that it worked well with a projector. Nevertheless I hope the organisers of the next devcamp will be a little more *nix friendly :) <br/><br/> Following my misadventures with *nix and projectors I did a quick tally of operating systems. I was surprised to see so many developers running Windows on their laptops. Even those who were working for startups deploying their products on *nix boxes seemed to be using Windows (Vista!). I guess all those photographs of tech events overseas that I have seen are to blame for my wrong expectations ;) <br/><br/> As one of my friends told me, one shouldn't speak for other people - "you should speak for yourself". At that time I didn't quite catch the meaning. I do now. Getting up on stage and showing code forces you outside your comfort zone. So if you commit to something that is just outside your current ability level you need to stretch to do a good job. So I hereby commit to talk about implementing algorithms related to Computer Vision in the next devcamp. See you then.Manoj Govindanhttp://www.blogger.com/profile/12734036974316245850noreply@blogger.comtag:blogger.com,1999:blog-16889165.post-39307000658788397292008-01-25T15:39:00.000+05:302008-01-25T16:50:00.195+05:302008-01-25T16:50:00.195+05:30Programmer-Journalists and IndiaA couple of days ago Programmer/Journalist <a href="http://www.holovaty.com/">Adrian Holovaty</a> and his team launched <a href="http://www.everyblock.com/">EveryBlock</a>, a web site that hopes to answer the question "What's happening in my neighborhood?". EB has been described as a "hyper-local news" site that collects publicly available information from a lot of sources and presents it in a neatly summarized form. EB gives you information ranging from local crimes to film shoots. I am impressed by EB; you can read more about how the site has been received at the <a href="http://blog.everyblock.com/2008/jan/24/postlaunchnotes/">EB blog</a>. The EB team is funded by a two year, 1.1 million USD <a href="http://www.holovaty.com/blog/archive/2007/05/23/1145">grant</a> from the Knight Foundation. <br/><br/> After checking out EveryBlock I did a little research about Indian sites that combine programming and journalism. I found that there are hardly any. Although all major Indian newspapers have online web sites none of these do anything much beyond serving as digital translations of printed material. Features focused on disseminating publicly available information in a structured fashion are extremely rare. For instance I couldn't find anything comparable to The Washington Post's collection of <a href="http://www.washingtonpost.com/wp-srv/widgets/">information widgets</a> in any major Indian news site. <br/><br/> Can programming and journalism be combined in the Indian context? What follows are the results of a thought exercise to answer this question. <br/><br/> A crucial difference between the US and India is that structured, publicly available data is hard to come by in the latter. Notable exceptions include election results, budget information, results of certain college/school examinations and cricket match scores. But these have always been covered by print media anyway. (I would say covered to death in the case of cricket. But that is for another blog post) What other data is publicly available? I can think of the following. <br/> <ol> <li>Detailed information about candidates standing in local elections. Income declarations, police/court records, manifestos if any etc.</li> <li>Details of public construction activity. For example the Bangalore City Corporation has made information about road maintenance <a href="http://www.bmponline.org/eng-dept/ward-map.shtml">available online</a>. The information is available in the form of PDF documents. This data can be converted to a more user friendly format and perhaps superimposed over Google's satellite maps as well.</li> <li>Traffic information. I am certain that a LOT of people would really appreciate such a feature covering Bangalore's roads.</li> </ol> <br/> These are but a few. In addition to the above newspapers (startups?) could possibly think about collaborating with various agencies to make additional data available. It is worthwhile to note that one of the four members of the EB team, <a href="http://www.derivativeworks.com/">Daniel X. O'Neil</a>, is dedicated to working with local agencies to free up available data. There are a zillion use cases for such cooperation. A feature to track public buses in Bangalore alone would be hugely useful. Another, pet wish of mine is a listing of teachers of performing arts. <br/><br/> Why hasn't the idea gained popularity in India? In all fairness, it is still brand new. The very idea that programming and journalism can be combined in non-traditional ways only gained popularity after the success of Adrian's <a href="http://www.chicagocrime.org/">ChicagoCrime.org</a>, a site that overlays Chicago crime records on Google maps of the city. Startups which have traditionally been sources of innovation find the liaison work and non-profit nature of such ventures unappealing (EveryBlock is a non-profit site, as is ChicagoCrime). Also the Indian print media continues to enjoy a degree of success unlike their western counterparts whose dropping circulations have forced them to investigate new ideas. <br/><br/> Another, more cultural aspect is the vast difference between the programming and journalism professions. Even in the relatively boundary-less West there are but a handful of people who have successfully managed to fuse the domains. Many Indian programmers I know think of Journalism as a low-paying, low-opportunity profession while there is at least one journalist who views programming as the modern day equivalent of dull, regimented factory labor. There also seems to be a variation of the traditional art/science divide in play. Programming is deemed to be in the science camp while journalism combines creativity and artistry. <br/><br/> The idea that programming skills can be as useful to journalists as, say a flair for writing or good conversation skills is yet to gain traction. Adoption of technology among journalists seems to have progressed no further than personal laptops and digital cameras. <br/><br/> What can possibly change the situation? I think change will have to start with Newspapers, specifically their web sites. At present most Newspapers treat their web sites like red headed step children. I doubt if traditional journalists view working in the "web desk" (what are they called anyway?) as lucrative. Similarly aspiring programmers have to recognize the advantages of working with journalism. Newspapers can offer great opportunities to put a lot of data centric programming skills to good use.Manoj Govindanhttp://www.blogger.com/profile/12734036974316245850noreply@blogger.comtag:blogger.com,1999:blog-16889165.post-42560005228450899552008-01-17T22:14:00.000+05:302008-01-25T16:50:42.763+05:302008-01-25T16:50:42.763+05:30Browsing for used booksI recently realized that one of the things I like about Bangalore is its high per capita ratio of used books stores. A good many of them seem to be located in and around Church Street. Today I visited one of the more organized and well known of the Church Street bookstores, <a href="http://www.blossombookhouse.com/">Blossom</a>. Blossom is one of my favorite haunts for two reasons. First, they have a good collection of graphic novels and History books. Second, <a href="http://www.discoverbangalore.com/restreview14.htm">Koshy's</a> is almost next door. Nothing serves better to wrap up an evening spent searching for books than a hot pot of tea served at Koshy's in genuine silverware. But I digress. <br/><br/> Today I ventured unusually close to the software books section in the store. I found it interesting that compared to other sections this one contained mostly "toast of the season" kind of books. Books that people aspiring to quick-start (or quick-boost) their career in the Bangalore software industry would buy. I found a lot of "pour encourager les dummies" type of books and those that scratch the surface of complex topics like *Nix or relational databases. No <a href="http://www.amazon.com/Art-Computer-Programming-Volumes-Boxed/dp/0201485419">Knuth</a>, no <a href="http://www.amazon.com/Artificial-Intelligence-Modern-Approach-2nd/dp/0137903952/ref=pd_bbs_sr_2?ie=UTF8&s=books&qid=1200589454&sr=1-2">Norvig</a> to name just a few of the masters. Contrast this with the diverse, rich collection of books on sale in the say, History section. <br/><br/> What could be the reason? I think people who buy really fundamental books on computer science are a minority. Among these the fraction of readers who would *sell* their copies would be really small. Such books would anyway be snapped up as soon as they became available. This is also in part due to the contrasting nature of computer science and history. Very few readers would need history books for daily reference, thereby making selling books after reading more likely. <br/><br/> There were very few used graphic novels on sale as well. I suspect that the small number of people who actually pay to buy them would not part with them easily. I know I wouldn't sell my copy of <a href="http://www.amazon.com/Watchmen-Alan-Moore/dp/0930289234/ref=pd_bbs_2?ie=UTF8&s=books&qid=1200590604&sr=1-2">Watchmen</a> or <a href="http://www.amazon.com/Neil-Gaimans-Neverwhere-Mike-Carey/dp/1401210074/ref=pd_bbs_sr_2?ie=UTF8&s=books&qid=1200590637&sr=1-2">Neverwhere</a>. <br/><br/> Incidentally I came across a book in the History section that had the marking of a *Free Public Library* somewhere in the United States. Right on the first page was a notice from the library requesting members to take proper care of the book. Given that most people who travel overseas from Bangalore work for the IT industry there is a good chance that the book was liberated from the library by an IT "professional". Right here is another reason why Indian IT workers are labeled "cheap Indian techies". Literally and figuratively.Manoj Govindanhttp://www.blogger.com/profile/12734036974316245850noreply@blogger.comtag:blogger.com,1999:blog-16889165.post-15760666070806260732007-11-15T23:14:00.000+05:302008-01-25T16:50:00.196+05:302008-01-25T16:50:00.196+05:30Quick and dirty 'type' for Django's message modelIn an <a href="http://lawfulsamurai.blogspot.com/2007/02/moving-from-rails-to-django-replacing.html">earlier post</a> I had mentioned using a 'flash' variable passed to templates as a mechanism for passing messages to users. Following an anonymous tip I started using <code>user.message_set</code> instead to pass messages. This mechanism makes use of Django's message model and is easy to use. However it does have a limitation. Messages cannot be assigned types - say, 'Error' or 'Success' or 'Warning'. This has been <a href="http://code.djangoproject.com/ticket/3995">discussed</a> at some length at the Django site. A design decision is awaited as the suggested changes will not be backward compatible. <br/><br/> In the meantime I needed message types for a pet application and came up with a quick and dirty way of providing some. Changes were required in three places: the view, where messages are created; the template which displays the messages and the style sheet used for styling the rendered templates. <br/><br/> The solution (did I say it was dirty?) involved prefixing a digit and a separator to all messages. The digit would indicate the type of message. I chose 0 to indicate success, 1 for warnings, 2 for errors etc. Corresponding styles were then created to appropriately style the messages. <br/><br/> Here is a sample view: <textarea name="code" class="python" cols="60" rows="10"> def save_something(request): if saved: request.user.message_set.create(message = "0|Object was saved successfully") else: request.user.message_set.create(message = "2|Object could not be saved") </textarea> The template looks something like this: <textarea name="code" class="html" cols="60" rows="10"> {% if messages %} <div id="messages"> {% for message in messages %} <p class="m{{ message|slice:"0:1"}}">{{ message|slice:"2:" }}</p> {% endfor %} </div> {% endif %} </textarea> There is a corresponding style sheet as well: <textarea name="code" class="css" cols="60" rows="10"> #messages p { margin: 0; padding: 0; } #messages p.m0 { background: transparent url(success.gif) 0 100% no-repeat; color: green; } #messages p.m1 { background: transparent url(warning.gif) 0 100% no-repeat; color: yellow; } #messages p.m2 { background: transparent url(failure.gif) 0 100% no-repeat; color: red; } /* etc */ </textarea>Manoj Govindanhttp://www.blogger.com/profile/12734036974316245850noreply@blogger.comtag:blogger.com,1999:blog-16889165.post-88984013700482797792007-10-16T18:41:00.001+05:302007-10-17T11:15:30.636+05:302007-10-17T11:15:30.636+05:30An Unique ArrangementI visited Leh, Laddakh in mid 2001 for trekking and seeing the place. Four of us completed our trek along Laddakh's <a href="http://www.google.com/search?q=Markha+Valley&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a">Markha Valley</a> in about eight days and decided to travel south to Srinagar in the Kashmir valley. Although Laddakh and Srinagar are both part of the state of Jammu and Kashmir they have dissimilar cultures and political atmosphere. The predominantly Buddhist Leh has been spared most of the violence that has plagued the state while the predominantly Muslim Kashmir valley has been at the heart of incidents. <br/><br/> We hired a taxi to ferry us to from Leh to Srinagar. The road connecting the two passes through several towns including Kargil that bore witness to a <a href="http://en.wikipedia.org/wiki/Kargil_War">small scale war</a> as recently as 1999. We started at noon from Leh. In spite of the modest distance (~475 Km/300 miles) ahead of us we were obliged to stop in Kargil at nightfall for various reasons. Traffic through the narrow Zoji-La pass was regulated so that vehicles driving North-South could only travel through from sunrise to noon. For the rest of the day the pass would be used by vehicles traveling in the opposite direction. Moreover nighttime civilian travel was not common, even discouraged. <br/><br/> In Kargil we checked into a hotel for the night. During dinner the manager came over and enquired if we had hired the cab in Leh. After we answered he told us to expect the driver to come up with an excuse to end the journey in Kargil and go no further. We would be offered an identical vehicle with a new driver to take us to our destination at no extra cost. It happened exactly as he predicted. Early next day our driver informed us that the car wouldn't start but we could continue our journey in another vehicle that had miraculously appeared out of nowhere in the predawn cold. <br/><br/> The incident was puzzling until we discovered the reason behind it. Our first cab driver was a Buddhist from Laddakh. He didn't dare to venture into Kashmir valley for fear of his life. His replacement was a Muslim from Srinagar who stayed away from Leh. The desire to survive had prompted them to come to an arrangement through which they could still work and split fares. <br/><br/> The rest of our journey was uneventful save for the hair raising transit through the narrow paths of Zoji-La. We reached Srinagar safely and settled into a house boat in Nagin Lake. <br/><br/> I haven't been to Kashmir since. I wonder if things have changed sufficiently for the cabbies to drop their arrangement.Manoj Govindanhttp://www.blogger.com/profile/12734036974316245850noreply@blogger.comtag:blogger.com,1999:blog-16889165.post-82800942589435414122007-10-16T16:07:00.000+05:302007-10-16T17:29:06.746+05:302007-10-16T17:29:06.746+05:30Bank NotesI recently had to deposit money into a friend's account. He has an account with <a href="http://www.statebankofindia.com/">State Bank of India</a>, Trivandrum branch. For those of you not from around here, that branch is in a city in a different state. All I had to do was: <ol> <li>Locate the nearest SBI branch</li> <li>Make the deposit</li> </ol> I tried to locate the nearest branch using SBI's <a href="http://www.statebankofindia.com/branchlocator.jsp">Branch Locator</a>. After a few minutes of fiddling with the unwieldy search interface I located a branch using - what else - <a href="http://www.google.com/search?hl=en&amp;client=firefox-a&amp;rls=org.mozilla%3Aen-US%3Aofficial&amp;hs=Nsj&amp;q=SBI+koramangala+branch&amp;btnG=Search">Google</a>. According to the page the branch had the following "alternate channels" (facilities?) : Internet banking, Core banking, ATM(s). Great, that is all I needed. <br/><br/> Armed with this information I visited the bank and presented my request. I was promptly informed that this particular branch would only let me make deposits if the target account belonged to this branch. So much for "core banking". <br/><br/> All was not lost yet. I recalled another branch located in St. Marks road and asked if visiting that one would help. Unfortunately, no. That particular branch was for "specialized personal banking" whereas I needed a "general branch". The nearest one was a good 10 Km away. I later found that "general branch" is a vaguely defined concept; the "advanced options" section of SBI's <a href="http://www.statebankofindia.com/branchlocator.jsp">Branch Locator</a> does not include it among the more than a dozen 'branch type' options listed. <br/><br/> With that I gave up on SBI. Fortunately my friend had an account with <a href="http://www.indianbank.in/">Indian Bank</a>. IB was a little more forthcoming with information about their branches. I located the nearest one and went over. I found the printed pay-in slip a bit confusing in spite of instructions written in three languages. Luckily one of the employees hinted that what mattered was the inclusion of relevant information in the form; the "where" did not matter. So I filled up the form as best as I could and paid the money. <br/><br/> This episode left me with some questions. <ul> <li>What is "core banking"? Does it exclude paying in money to accounts established in other states/cities/branches, especially in this day and age when all banks are touting their internet facilities?</li> <li>Why does a national bank with vast outreach make depositing money to a non-local account so difficult? Particularly in cities like Bangalore where a significant percentage of inhabitants are from other states. </li> <li>Who designs the pay-in slips used in banks? I feel that at least some of them need to be redesigned to make them easier to use. Something akin to usability in software applied to banking. </li> </ul>Manoj Govindanhttp://www.blogger.com/profile/12734036974316245850noreply@blogger.comtag:blogger.com,1999:blog-16889165.post-75596888018401200932007-06-02T23:15:00.000+05:302008-01-25T16:50:00.196+05:302008-01-25T16:50:00.196+05:30Django Testing GotchasI recently started using <a href="http://www.djangoproject.com/">Django</a>'s newly introduced capability to make use of test <a href="http://www.djangoproject.com/documentation/testing/#fixture-loading">fixtures</a>. In order to do this all test classes that need fixtures have to be subclasses of Django's custom <span style="font-style: italic;">TestCase</span> class rather than the customary <span style="font-style: italic;">unittest.TestCase. </span>I had written about 17 or so test cases split across two test classes. One of these test classes used Django's fixtures. <br/><br/> Each Django test run (kicked off by running <span style="font-style: italic;">python manage.py test</span>) involves the following steps: <ol><li>Create test database</li><li>Create the necessary tables</li><li>Load "initial fixtures" if any. These have to be located in a file named <span style="font-style: italic;">initial_data</span> with suitable extension denoting fixture type (<span style="font-style: italic;">.xml</span>,<span style="font-style: italic;"> .json</span> etc.) </li><li>Load fixtures specified in each test case</li><li>Execute any one test </li><li>Remove fixtures loaded in step #4</li><li>Repeat steps 4 through 6 until all tests have been executed. </li></ol>Sounds nifty, doesn't it? That is what I thought too, until I ran into reality. All goes well until step 3. After that, the tests take an eternity to execute. OK, it took 159 seconds to execute 17 puny tests. I was surprised. My application was rather simple, involving less than a dozen tables and a few hundreds of rows. And I was only using a subset of the data to test. What was going on? I looked around and found that I was <a href="http://groups.google.com/group/django-developers/browse_thread/thread/8d0b6057d97da61c/894776b61d24f6e3?lnk=st&q=django+test+slow&amp;rnum=4#894776b61d24f6e3">not the only one</a> to face this problem. <br/><br/> After reading up more about the problem I figured that I could probably cut down on the time taken by "refactoring" my tests and moving unnecessary fixtures out to "initial fixtures" so that they would only be loaded once. Luckily this would work in my case as my app only used the data for reference; it did not modify any. I was therefore not constrained to load the data before each test. <br/><br/> I made the necessary changes and re-ran my test cases. The time taken to execute the test cases improved ever so slightly. It now took about ~140 seconds. <br/><br/> I was still unhappy with the results. Since I was not using any fixtures, I decided to substitute Django's TestCase with unittest.TestCase. And voilà! It was as I had engaged hyper drive. <span style="font-style: italic;">24 tests</span> now took a mere 0.2 seconds to run! <br/><br/> Naturally the question that came to my mind was that in the absence of fixtures, what on earth was taking up so much time? Django is known for its speed vis a vis Rails; I had come to expect the same kind of superior performance while running tests too. I don't have an answer right now. I hope to come up with one after I take a look at Django's innards. <br/><br/>Manoj Govindanhttp://www.blogger.com/profile/12734036974316245850noreply@blogger.comtag:blogger.com,1999:blog-16889165.post-69212933534081120292007-02-14T01:05:00.000+05:302008-01-25T16:50:00.197+05:302008-01-25T16:50:00.197+05:30Moving from Rails to Django: Replacing flash[:notice]One of the most common practices I came across while learning Rails is the <span style="font-family:courier new;">flash[:notice]</span> mechanism used to send (error) messages to the template. Consequently it was also one of my first targets to migrate when I started moving a pet application from Rails to Django. <br/><br/> I came up with a simple (and all too obvious) way to send error messages to the template. I am sure that there are better ways to do this. If you know of any, please take a minute to share them. <br/><br/> First, the Rails snippet. <textarea name="code" class="ruby" cols="60" rows="10"> def index ... begin army = Army.find(params[:army][:id]) rescue StandardError => se flash[:notice] = "Vare, legiones redde!" return end ... end</textarea> Next, the equivalent in Django. <textarea name="code" class="python" cols="60" rows="10"> from django.shortcuts import render_to_response def index(request): ... try: army = Army.objects.get(id = request.POST["army"]) except ( KeyError, Army.DoesNotExist ): return render_to_response( "some_template.html", { "flash" : "Vare, legiones redde!" } ) ... </textarea> The template in Rails ... <textarea name="code" class="xml" cols="60" rows="10"> ... <% if @flash[:notice] -%> <div id="flash"> <div><%= @flash[:notice] %></div> </div> <% end -%> ... </textarea> ... and the template in Django. <textarea name="code" class="xml" cols="60" rows="10"> ... {% if flash %} <div id="flash"> <div>{{ flash }}</div> </div> {% endif %} ... </textarea> While testing in Django, <span style="font-family:courier new;">flash</span> can be treated just like any other context variable.Manoj Govindanhttp://www.blogger.com/profile/12734036974316245850noreply@blogger.comtag:blogger.com,1999:blog-16889165.post-67510360592544752852007-02-14T00:51:00.000+05:302007-10-16T17:29:06.748+05:302007-10-16T17:29:06.748+05:30Request to BloggerPlease, please add a formatting tool/plug in/some other mechanism to highlight code syntax. It took me two frustrating hours of cutting and pasting to add code samples to <a href="http://lawfulsamurai.blogspot.com/2007/02/django-vs-rails-testing.html">this post</a>. Even now, I am not completely happy with the results. And as automatically inserted line breaks (BR tags) and highlighter <a href="http://jasonlangston.blogspot.com/2005/09/awesome-clientside-syntax-highlighter.html">do not go together</a>, I have to manually insert BR tags in all my posts :( Thankfully, I am not a prolific blogger ;) but even then it sucks. <br/><br/> I am not partial to any specific utility. In this case I followed the example set by <a href="http://rubyscube.blogspot.com/2005/02/syntaxhighlighter-pour-ruby.html">other</a> <a href="http://jasonlangston.blogspot.com/2005/09/awesome-clientside-syntax-highlighter.html">bloggers</a> and used <a href="http://www.dreamprojections.com/SyntaxHighlighter/">dp.SyntaxHighlighter</a>. But I will (and so will most others, I suspect) gladly use your tool if you were to provide one. <br/><br/> C'mon guys, after all you are Google :)Manoj Govindanhttp://www.blogger.com/profile/12734036974316245850noreply@blogger.comtag:blogger.com,1999:blog-16889165.post-33546959892143655422007-02-13T21:58:00.000+05:302008-01-25T16:50:00.198+05:302008-01-25T16:50:00.198+05:30Moving from Rails to Django: Migrating Tests<span style="font-weight: bold;font-size:130%;" >Context</span><br/> I am in the process of migrating one of my small "pet" applications developed in <a href="http://www.rubyonrails.org/">Ruby on Rails</a> to Python using <a href="http://www.djangoproject.com/">Django</a>. One of my first concerns was migrating tests, both unit (testing models) and functional (testing 'controllers' in Rails/'views' in Django) from one framework to the other. After looking around the documentation, asking questions and conducting some experiments I have some answers. Here is a listing of what I have found out so far. <br/><br/> <span style="font-weight: bold;" >Note</span><br/> These examples will only work with the latest <a href="http://www.djangoproject.com/download/">development version of Django</a>. <br/><br/> <span style="font-weight: bold;font-size:130%;" >Locating your tests</span> <br/><span style="font-weight: bold;" >Rails</span><br/> Usually located under the path <span style="font-family: courier new;">[path_to_app]/test/functional</span>/. There is usually one test source per controller, named as <span style="font-family: courier new;">[controller_source_without_extension]_test.rb</span>. For example if the source for a controller, say, 'Generator' is written in <span style="font-family: courier new;">[path_to_app]/app/controllers/generator_controller.rb</span>, then the corresponding test should be present in a file named <span style="font-family: courier new;">generator_controller_test.rb</span> <br/><br/> <span style="font-weight: bold;" >Django</span><br/> The easiest way (see the <a href="http://www.djangoproject.com/documentation/testing/">official documentation</a>) is to add all your tests to a file called <span style="font-family: courier new;">tests.py</span><span style="font-family: courier new;"> </span>and drop it in the application folder, at the same level as your models.py and views.py. <br/><br/> However I prefer to have a separate test source structure if I can help it. This has the added advantage of keeping I decided to adopt the convention used by Rails and came up with the following tree: <ul><li><span style="font-family: courier new;">[project]/[application]/test/functional/</span> for functional tests and</li><li><span style="font-family: courier new;">[project]/[application]/test/unit/</span> for model tests. </li></ul>Don't forget to add the <span style="font-family: courier new;">__init__.py</span> files to the tree as applicable to make these <a href="http://docs.python.org/tut/node8.html">accessible as python modules</a>. You will still need to retain the <span style="font-family: courier new;">tests.py</span> except that you will have to add a line to import your test case classes and nothing else. Test runner will automatically pick up the test classes and run them. <textarea name="code" class="py" cols="60" rows="10"> # GeneratorTests is a subclass of unittest.TestCase from django_iwg.btd.test.functional.generator_tests import GeneratorTests </textarea> <br/><span style="font-weight: bold;font-size:130%;" >Fixtures</span><br/> Fixtures are readily available in Rails. There are not quite there yet in Django and I am as righteously angry as the next ex-Rails user ;) But do not worry, they are on their way and will be available shortly. I am experimenting with a really dirty solution in the meantime. More on this in a subsequent post. <br/><br/> <span style="font-weight: bold;font-size:130%;" >Writing Tests - setup</span> <br/><span style="font-weight: bold;" >Rails</span><br/> A typical <span style="font-family:courier new;">setup()</span> method in Rails looks like this: <textarea name="code" class="ruby" cols="60" rows="10"> require File.dirname(__FILE__) + '/../test_helper' require 'generator_controller' class GeneratorControllerTest < Test::Unit::TestCase def setup @controller = GeneratorController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new end end </textarea> <span style="font-weight: bold;" >Django</span><br/> The framework provides a test client to simulate browser calls. The best place to create a test client object would be the setup method. <textarea name="code" class="py" cols="60" rows="10"> import unittest from django.test.client import Client class GeneratorTests(unittest.TestCase): def setUp(self): self.client = Client() </textarea> <br/> <span style="font-weight: bold;font-size:130%;" >Writing Tests - GET requests</span> <br/><span style="font-weight: bold;" >Rails</span><br/> My first objective was to test if a GET request to the controller/URL 'generator/index' was being handled properly. "Properly" in this case means three things: <ul><li>Ensure that the response came back with an HTTP status of 200 OK; </li><li>Ensure that the appropriate template was used; and </li><li>Ensure that instance variables were present and had expected values.</li></ul>The resulting test looked like this: <textarea name="code" class="ruby" cols="60" rows="10"> def test_GET_index_returns_200_OK get :index assert_template "generator/index" assert_response :success assert_equal assigns(:campaigns).length, 14 end </textarea> <br/><span style="font-weight: bold;" >Django</span><br/> While the objectives remain the same, the steps vary. The key differences I noticed were: <ul><li>There are no built-in wrapper methods for GET/POST. It should be noted that it is easy to enough to code wrappers should one so wish.</li><li>Likewise there are no equivalents for wrappers such as "assert_template" or "assert_response"</li><li>Django uses a different philosophy when it comes to passing variables to templates. Instance variables are not directly passed to templates; rather they have to be explicitly passed using a context object or a call to <span style="font-family:courier new;">locals()</span> </li></ul>The resultant code looks like this: <textarea name="code" class="py" cols="60" rows="10"> def test_GET_index_returns_200_OK(self): response = self.client.get("/generator/index/") self.failUnlessEqual(response.status_code, 200) self.failUnlessEqual(response.template.name, "generator/index.html") self.failUnlessEqual(len(response.context["campaigns"]), 14) </textarea> <br/> <span style="font-weight: bold;font-size:130%;" >Writing Tests - POST requests</span> <br/><span style="font-weight: bold;" >Rails</span><br/> A simple "happy path" POST request test looks like this in Rails: <textarea name="code" class="ruby" cols="60" rows="10"> def test_POST_index_saves_army_in_session_and_redirects post :index, :army => {:id => 1} assert_equal 1, get_session_variable(:army).id assert_redirected_to(:action => "number_of_units") end </textarea> Here, in addition to checking the response I am also verifying that a particular session variable was set properly. <br/><br/> <span style="font-weight: bold;" >Django</span><br/> Here again we find that there are no wrappers for session and that it is easy enough to add some. The session object itself is readily available and can be accessed using the test client. <textarea name="code" class="py" cols="60" rows="10"> def test_POST_index_saves_army_in_session_and_redirects(self): response = self.client.post("/generator/index", {"army" : 1}) self.failUnlessEqual(response.status_code, 302) self.failUnlessEqual(response.headers["Location"], "/generator/number_of_units/" ) self.assertEqual(self.client.session["army"].id, 1) </textarea> <br/> <span style="font-weight: bold;font-size:130%;" >Running Tests</span> <br/><span style="font-weight: bold;" >Rails</span><br/> The easiest way is to execute <span style="font-family:courier new;">./rake</span> from the command line. There are separate tasks available (such as test:functional, for instance) in case you wish to run the functional tests only. <br/><br/> <span style="font-weight: bold;" >Django</span><br/> The easiest way is to execute <span style="font-family:courier new;">./manage.py test</span> from the command line. This will run the tests for all applications in the project. If you wish to test only one application, feed its name as an additional parameter. <br/><br/> <span style="font-weight: bold;font-size:130%;" >Django Template Nuances</span><br/> Django provides <a href="http://www.djangobook.com/en/beta/chapter04/">simple inheritance mechanism</a> for templates. I personally like it :) What should be remembered is that using inheritance changes the testing process slightly. For instance, consider a view <span style="font-family:courier new;">index</span> that renders a template say, <span style="font-family:courier new;">index.html</span>. This template inherits from another, named <span style="font-family:courier new;">base.html</span>. A GET request test for the view would look like this: <textarea name="code" class="py" cols="60" rows="10"> def test_GET_index_returns_200_OK(self): response = self.client.get("/generator/index/") ... template_index = [template.name for template in response.template].index("generator/index.html") self.failUnlessEqual(len(response.context[template_index]["campaigns"]), 14) </textarea> Note the difference from the earlier test. When template inheritance comes into play, <span style="font-family:courier new;">response.template</span> will resolve into a list of all the templates involved in the hierarchy, listed parent first. Corresponding to each template, there will be a separate context object at available at the same index in <span style="font-family:courier new;">response.context</span> (which will also resolve into a list)<span style="font-family:courier new;"> </span>Manoj Govindanhttp://www.blogger.com/profile/12734036974316245850noreply@blogger.comtag:blogger.com,1999:blog-16889165.post-42492329904310687062007-02-13T21:28:00.000+05:302007-10-17T13:00:06.793+05:302007-10-17T13:00:06.793+05:30Testing Code Highlighting<textarea name="code" class="py" cols="60" rows="10">from project.app.test.functional.generator_tests import GeneratorTests</textarea>Manoj Govindanhttp://www.blogger.com/profile/12734036974316245850noreply@blogger.comtag:blogger.com,1999:blog-16889165.post-1158213099919124902006-09-14T11:20:00.000+05:302008-01-25T16:50:00.199+05:302008-01-25T16:50:00.199+05:30Advantages of working on Decent CodeI recently switched employers for the first time in my working career. After spending six and a half years with a huge (tens of thousands of employees) software services company I recently moved to a much smaller product company. After the initial few weeks getting acquainted, trained etcetera, I recently started hacking away at the code base. It came as a surprise to me that after three days spent adding enhancements to an existing (mostly Java) application I was no where near as stressed as I would have been in the past. I realised that this was mostly thanks to the decent code base that the application's developers had created in the first place. The code did nothing extraordinary; it was merely well structured, cleanly packaged and came with a good many automated tests. And boy, what a change it made. No need to spend days merely building the app; no more personal source code repositories (I have been forced to install CVS in my machine on several occasions in the past thanks to general ignorance about SCM tools). <br/><br/> The contrast with what I have been through while with my previous employer could not have been starker. I have worked in half a dozen 'legacy' applications for my previous employer and not once have I not been frustrated by poorly written code. Adding insult to injury were the indifferent "developers" who had created the monster in the first place. <br/><br/> The moral of the story is that good code goes a long way towards stress reduction and boosting employee happiness. Should I need to change jobs in the future, I will ask any potential employer to show me their existing code base. If the code sucks, I will politely bow out.Manoj Govindanhttp://www.blogger.com/profile/12734036974316245850noreply@blogger.comtag:blogger.com,1999:blog-16889165.post-1153213409709217802006-07-18T14:16:00.000+05:302007-02-14T01:49:02.756+05:302007-02-14T01:49:02.756+05:30SpeechlessFirst they <a href="http://www.business-standard.com/common/storypage_c.php?leftnm=11&bKeyFlag=IN&amp;autono=3095">ban Blogs</a>. If that wasn't bad enough, the bureaucrats - who get paid by taxes people like me pay at the rate of 33%, deducted at source - have the <a href="http://www.hindustantimes.com/news/181_1746690,000600010001.htm">temerity to say</a> "We would like those people to come forward who access these (the 12) radical websites and please explain to us what are they missing from their lives in the absence of these sites." <br/><br/> You f~!@#$% morons! Ever read the '<a href="http://en.wikipedia.org/wiki/Indian_constitution#History">Objectives Resolution</a>' of the Indian Constitution? The part where it says that "<span style="font-style: italic;">All people of India shall be guaranteed and secured social, economic and political justice; equality of status and opportunities before law; and </span><span style="font-weight: bold; font-style: italic;">fundamental freedoms - of talk, expression, belief, faith, worship, vocation, association and action</span><span style="font-style: italic;"> - subject to law and public morality</span>"? <br/><br/> What would you babus propose next? Filter search results like our neighbour? I agree with <a href="http://ravimohan.blogspot.com/2006/07/indians-cant-see-this-blog-entry.html">Ravi Mohan</a>. It is time to think about leaving.Manoj Govindanhttp://www.blogger.com/profile/12734036974316245850noreply@blogger.com