Tuesday, 12 March 2013
OCD and programming
I never really thought of myself as somebody with OCD. If you read the Wikipedia article you'll see it's a pretty serious mental state. I'm not calling it a disease. It's as bad as it could be and much as it's neglected. In my case I always thought it's just the massive time I'm having privately with my brain. Like two bohemian lovers.
I guess the first signs appeared the very first time I have memories from. I remember as a 5 - 6 year old kid was watching the door and tiles for long times - and I was thinking what would be the best angle to turn the door in order to make the perfect angle with the tiles. There were good and bad doors. Bad doors couldn't make it right. The worst doors could almost make it right, but their shadow ruined everything. Just to give one more hint - it's also important to check if the ratio of the tile edges - the part under the bottom of the door and the rest - they make a fifty fifty or even better a golden ratio.
You may ask why all the fuzz? It's about the environment and justice. You want everything to have an equal share of the global transformation. It took me ages to accept you can build unsymmetrical constructions from Lego. I had quite a lot, and all had the unsymmetrical way of creation - I was so mad. It feels like it wouldn't survive the first night in my room.
Many of you probably heard about OCD from Rain Man. It's a brilliant masterpiece. However Raymond's story is a bit more serious. I've heard about other families from friends where child custody was revoked due to the mental state of a parent.
I also have many friends presenting light symptoms of OCD. And I think in general that's a nice little habit. In general it doesn't harm you. You feel a bit frustrated when a layout is messed up - or even worse, "almost" perfect. I have huge problems with art. I can be stressed out by the tiniest detail on a painting. I guess that's why it's so outstanding when a piece of art seems to be complete and great. Usually OCD people highly appreciate balance over.
All right, it's not that romantic all the time. I remember when I was using Adobe Reader on Windows. The app had a pointing hand icon where the bottom part wasn't closed. So I was trying to fit that on all the circular fonts, like U, O, H or R - just to make it stable. I guess on OS-X it's even worse. It has a really handy zoom feature. Since I'm on a mac I use it to make all artificial alignments pixel perfect. Trust me it's a magical relief when 2 floating windows are on the same height, or some lines from different panels can be connected perfectly. I even have problem with the world famous OS-X font pixel hinting algorithm. You know, black is not black, it's a bit red, it's a black and a bit blue. And seeing those extra edge pixels can make life so hard.
If you don't have OCD then this might give you a little view on what's happening in some folks' head. And the best - these issues we see are everywhere and every time. Mixing it with a little ADD and years are running by so quickly you won't even notice.
But then I realized I can use it in my work. That tendency to aim balance let's you to find deviation much sooner. I'm quite sensitive to code quality and coding conventions. Typos and bad naming conventions are also really easy to spot. I started following a special naming convention - an important rule is to prioritize the grouping elements in the name. You know in function and variable names you have prefixes, subjects, objects, verbs and nouns and many semantical items. When you're using a IDE or Vim or grep - and you're doing file lookup you'll find things faster - simply because it's better sorted.
It might be only me, but I guess OCD helps when you refactor code as well. Keeping the balance also plays an important role in transformation. So eventually you accomplish a complete change and more likely you won't leave anything out.
I think it's also pretty obvious that OCD doesn't let you to miss any function header comment block, right separation of logical elements through files and many many useful coding practices.
I'm wondering what other mental issues could affect on your code quality. Probably depression could help you in your singleton skills or memory problems supporting you in using talkative code.
I'm super interested if you know you have strange habits and would share some stories.