Meditation: Why Bother?

And just because of the simple fact that you are human, you find yourself heir to an inherent unsatisfactoriness in life which simply will not go away. You can suppress it from your awareness for a time. You can distract yourself for hours on end, but it always comes back–usually when you least expect it. All of a sudden, seemingly out of the blue, you sit up, take stock, and realize your actual situation in life.

There you are, and you suddenly realize that you are spending your whole life just barely getting by. You keep up a good front. You manage to make ends meet somehow and look OK from the outside. But those periods of desperation, those times when you feel everything caving in on you, you keep those to yourself. You are a mess. And you know it. But you hide it beautifully. Meanwhile, way down under all that you just know there has got be some other way to live, some better way to look at the world, some way to touch life more fully. You click into it by chance now and then. You get a good job. You fall in love. You win the game. and for a while, things are different. Life takes on a richness and clarity that makes all the bad times and humdrum fade away. The whole texture of your experience changes and you say to yourself, “OK, now I’ve made it; now I will be happy”. But then that fades, too, like smoke in the wind. You are left with just a memory. That and a vague awareness that something is wrong.

But there is really another whole realm of depth and sensitivity available in life, somehow, you are just not seeing it. You wind up feeling cut off. You feel insulated from the sweetness of experience by some sort of sensory cotton. You are not really touching life. You are not making it again. And then even that vague awareness fades away, and you are back to the same old reality. The world looks like the usual foul place, which is boring at best. It is an emotional roller coaster, and you spend a lot of your time down at the bottom of the ramp, yearning for the heights.

So what is wrong with you? Are you a freak? No. You are just human. And you suffer from the same malady that infects every human being. It is a monster inside all of us, and it has many arms: Chronic tension, lack of genuine compassion for others, including the people closest to you, feelings being blocked up, and emotional deadness. Many, many arms. None of us is entirely free from it. We may deny it. We try to suppress it. We build a whole culture around hiding from it, pretending it is not there, and distracting ourselves from it with goals and projects and status. But it never goes away. It is a constant undercurrent in every thought and every perception; a little wordless voice at the back of the head saying, “Not good enough yet. Got to have more. Got to make it better. Got to be better.” It is a monster, a monster that manifests everywhere in subtle forms.

Very nice article on Buddhist philosophy and the power of meditation.

Posted via email from Sijin Joseph

China is not the world’s biggest manufacturer

Wow, Talk about false perceptions. This was one of the things that I had taken for granted for so long that it was very surprising for me to ready today that China is not the world's largest manufacturer. I read this at Helen Wang's site http://helenhwang.net/2010/03/myth-of-manufacturing/ 

I quote

"The latest data shows, however, that the United States is still the largest manufacturer in the world. In 2008, U.S. manufacturing output was $1.8 trillion, compared to $1.4 trillion in China (UN data. China’s data do not separate manufacturing from mining and utilities. So the actual Chinese manufacturing number should be much smaller)."

Make sure to read the complete article, it has more interesting facts about how the manufacturing growth in China has not resulted in a rise in the middle class.

Posted via email from Sijin Joseph

soapUI – Web Service tool

Sometimes a you come across a tool that just makes you think why you never used it before, I ran across one such tool last month, it’s called soapUI (http://www.soapui.org/ ).

This is an open source tool for testing web services, everything I wanted to do for testing some of the web services that we were developing including unit testing and load testing was provided out of the box by this awesome tool. Also I think the UI is quite well thought out and mature.

Here’s a list of the features at a high level,

soapUI is a free and open source desktop application for

It is mainly aimed at developers and testers providing or consuming WSDL or REST based Web Services (Java, .net, etc). Functional and Load Testing can be done both interactively in soapUI or within an automated build or integration process using the soapUI command line tools.

Mock Web Services can easily be created for any WSDL and hosted from within soapUI or using the command-line MockService runner. IDE-plugins are available for

soapUI requires Java 1.5 and is licensed under the LGPL license.

See their features page http://www.soapui.org/features.html for some screenshots of the cool stuff you can do using this.

Posted via email from Sijin Joseph

OutOfMemory/Heap space errors in Java

Recently I had to work on a Java based rule modeling tool that was built on Java/Eclipse. The tool was pushing both eclipse and the JVM to the limits in terms of memory and I was getting a lot of OutOfMemory exceptions and out of heap space errors, usually these can be fixed by increasing the default limits.

The important settings in question are arguments passed to the JVM on startup, http://java.sun.com/javase/6/docs/technotes/tools/windows/java.html

-Xmsn

Specify the initial size, in bytes, of the memory allocation pool. This value must be a multiple of 1024 greater than 1MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default value is chosen at runtime based on system configuration. For more information, see HotSpot Ergonomics 
Examples:

       -Xms6291456
       -Xms6144k
       -Xms6m
       

-Xmxn

Specify the maximum size, in bytes, of the memory allocation pool. This value must a multiple of 1024 greater than 2MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default value is chosen at runtime based on system configuration. For more information, see HotSpot Ergonomics 
Examples:

       -Xmx83886080
       -Xmx81920k
       -Xmx80m

Other advanced VM settings are documented here, http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp

1.       Eclipse IDE – If the IDE itself is running out of memory when compiling or editing code then you can increase the maximum memory pool using the Xmx option in eclipse.ini file present in the same folder as eclipse.exe.

2.       JVM from within eclipse – If the JVM is running out of memory when running an app from within eclipse, then you can adjust the memory settings from the JVM configuration tab within eclipse.

3.       JVM from Tomcat – On the Apache Tomcat configuration utility on the Java tab, you can specify the memory and heap settings.

Posted via email from Sijin Joseph

The Enlightened Newbie Syndrome

Recently I was reviewing some code written by a new programmer, this person had demonstrated good knowledge of his domain and was quite well regarded by everyone. However when I looked at his code I saw a familiar pattern that I had seen before which I like to call the “Enlightened Newbie Syndrome” (ENS).

You can detect ENS when you see code that is a mish-mash of good code intermingled with overkill on “best practices”. The Enlightened Newbie will focus on making sure that his code adheres to the latest naming conventions, follows TDD but doesn’t test the right things and applies design patterns too liberally :)

In this particular case the programmer had used different naming conventions for variables based on it’s usage, so for e.g. pascal case for params, all caps with underscroes for local variables etc. Another classic sympton was the elaborate comments about assignment statements complete with box decorations around the comment. Further the variables if named properly would have been enough to indicate their usage but instead the variable names were extremely generic and then had big comment boxes near them to describe what the variable was used for.

The saving grace of the code was that logically it was setup correctly, but it was clear that the programmer had not unit tested his code at all, my first invocation of the code gave me wrong results and upon further analysis it looked like a lot of the edge cases had been missed out.

I remember being an enlightened newbie once, I had read all the books on design patterns, refactoring, TDD etc. but had not yet written a lot of code. So when I worked on my real project it was very tough for me to find the style that worked for me and I ended up with a bit of everything at the start. However as I worked on that code for the next 3 years all the things that I had read started to make sense and I realized that the essence is to not follow a practice religiously but to make use of good judgement to see what applies where.

So in my mind there is only one cure for ENS and that is to just write a lot of software in a team environment. Note that I am not talking about just chruning out code but actual working software, and again not in isolation but in a team. Because

1. You can write a lot of code and only improve your typing and not learn a lot about programming, however when you build an actual product/service and then have users or other systems interacting with it, you get a lot of feedback on what works and what does not. Based on the feedback and other external requirements the software usually goes through a lot of changes and when you have to go back into your code and make changes then you really appreciate brevity, simplicty and the DRY principle.

2. Working in a team environment exposes you to code that is both better and worse than you, it gives you more exposure to the different ways something can be done and all the different ways you can use tools to make your work easier. Teams are just fantastic platforms for improving your skill, knowledge and productivity.

Weblog is a “log”

A few years ago before the whole weblogs revolution kicked off my daily hangout was “The Lounge” at codeproject.com, it was fun to participate in discussions with peers on a wide variety of topics. When I initially started my blog I thought that I could kick off a discussion by posting a blog and then having people respond to it so that I could track all my discussions via this site. In hindsight this seems like such a bad idea :) but the weblog thing was still in it’s infancy at that time. Currently I just use the weblog to “log” interesting things I find and my thoughts and opinions rather than as a discussion network. But I miss the discussion part, seeing the opinions of different people with different perspectives is something I’ve always enjoyed, so maybe there is a way to combine the best of both worlds? Maybe a blog platform that centralizes your comments/discussions?

The Economics of Success

A decade ago when I was still in high school I remember our economics teacher going over the economic issues plaguing India, at the top of the list was “population”, it seemed like all economic problems of India stemmed from it’s high population count and that lowering the population would in turn result in a solution to the economic issues.

Yesterday I was listening to a nerd TV podcast with Bill Joy and he was talking about how the distribution of smart people is uniform and if India and China has that many more people then statistically the distribution of smart people in those countries would be higher as well. This got me thinking about how the perception of India has changes because of the IT boom that has happened in India, today everyone talks about how the populations of India and China give them an edge over all other countries in terms of manpower available for both manufacturing as well as services.

In the early 1990s when India was a closed economy, it was not apparent how India’s population could be leveraged as an advantage, but with the opening of the economy to foreign investments and more importantly I feel with the Internet making global communication ubiquitous all of a sudden India was at the center of the IT revolution, earning and growing like crazy. Of course it’ll take a long time for the wealth to trickle down to the masses but once the money is there and consumerist culture is in place the distribution of wealth happens naturally.

I would love to talk to my teacher some time and see if they still teach the same theory in school now :)

How to leak memory in .Net – Statics and Event Handlers

For the past few days I’ve been investigating some memory leak issues in our desktop application. The problem started showing up when we saw that opening new documents and then closing them didn’t have any negative impact on the memory usage. Initial tests using vadump and process explorer confirmed that there was an issue and so we the developers started looking into it.

Initially it looked like the problem was that certain event handlers were causing references to closed documents to hang on a couple of ones that I remember are Application.Idle and SystemEvents.PowerModeChanged. Next there were some references via event handlers that were being held by Singleton objects and some service objects and those were easily handled as well.

After this we could see that the references were still hanging around, btw we were using a combination of ANTS profiler, WinDBG (dumpheap + gcroot) and the VS.Net debugger all this while to investigate the issue. After fixing the obvious issues we struggled to find the root cause of the memory leaks. Then I looked around for alternate profilers and came across .Net Memory Profiler from SciTec, using this gave a much clearer picture into the issue, you see the new profiler gave you allocation stacks for all references and the ability to reflect over the instance fields, using this I started seeing that two third-party components that we were using were causing the issue.

Basically both third-party components, one a very well known UI toolkit and another one that provides skinning support to controls were storing references to controls in static hashtables. In one toolkit a bug in the code caused the reference from the hashtable to remain even after it was not required and in the second case I think those guys just didn’t know how to remove an entry from a hashtable, they were simply setting the value of the key to be null causing a reference to the key to be held by the static hashtable.

We now need to hack around these issues either by using Reflection or getting an updated build from the vendors.

Some of the lessons I’ve learnt from this

  • Always, Always have source code for any third-party component that you are using in your application. For any non-trivial usage you’ll always end up fixing bugs in the component.
  • When putting any data in static fields, double check to make sure that it’s really required and keep in mind the memory impact of the decision also provide a clean API to clean up the static data.
  • If your’re hooking onto an event then make sure to unhook when it’s no longer required.

.Net framework hotfix wreaks havoc

Last week all of us were baffled when suddenly one part of our application that uploads files to a FTP server stopped working. The strange thing was that the same build has been working without any issues for the past one week. We looked at everything that could have gone wrong, server, configuration, code but everything was setup fine and hadn’t been changed. Also interestingly it stopped working for everyone except the developer who was responsible for the feature.

The first thing we did was to enable detailed logging to see what was happening, the logs showed two problems

  1. We were incorrectly formatting the path of file to upload
  2. The .Net framework code was changing folders after login to the root folder of the ftp where it didn’t have permissions to upload the file

Further investigation showed that the second issue was not coming on the developer’s machine. Most puzzling indeed.

Then I remembered that last week .Net had issued a critical hotfix for .Net 2.0, could this be the issue. We verified that the developer didn’t have the hotfix and all machines which were failing did have, Strike 1! Next we uninstalled the hotfix from one of the machines and the FTP uploads started working, Strike 2!! Finally we fixed the incorrect formatting of the ftp url and the issue got resolved on all machines with or without the hotfix, Strike 3! Issue resolved!

The problem was that the hotfix changed the implementation of the FTP code inside the .Net framework so that it behaved differently when passed an incorrectly formatted url.

This was the first time I saw a working app fail because of the way an incorrect argument was handled by a newer version of the framework. It was a good learning experience though :) Also this strengthens my belief in asserting all assumptions in code because if we had asserted that the url was infact of the format that we were expecting, this issue would never have happened in the first place.