Wednesday, February 17, 2010

Reminders about how much I have.

When I was growing up I didn't really "get" frugality. Money was either free or later, when I was working, it was easy to get. I've spent most of my life single, white, educated and well off so I've always had what seemed like a surplus of money. Jobs were easy to get, money was easy to come by.

When I found out, the hard way, while living in Chicago that, in fact, money is not always easy to get and bills are easy to fall behind on, I had family to help me get back on top of things.

But even after that I wasn't a big saver and my opinion in my early 20s was... hey, you can't take it with you! Why not buy food and toys? Being "cheap" for no reason had ever appealed to me, I was never seduced by thrift for thriftiness' sake.

In my mid-20s though, I read a book about ethics that changed the way I looked at the world and my place in it. This entry isn't about being preachy, so just suffice it to say that I started giving to charity and being more conscientious about how I spent money. (Though I still clearly have a long way to go on this.)

Despite this new disposition, for a while I was very skeptical of "panhandlers." That is, people who are homeless (or appear homeless) who ask for money as you pass them on the street. No one likes to be taken advantage of or even feel like they might have been taken advantage of. How do I know this person isn't just taking money and laughing? What if this is a scam? Plus it's just sort of uncomfortable to be confronted while you're doing something else and asked to make a decision on the spot.

About a year and a half ago, though, I was at a gas station and a couple of teenagers were there at a pump adjoining mine. Sheepishly, they asked me if I could spare any money for some gas. They'd borrowed their mom's minivan and didn't think they'd have enough to get home. My knee jerk reaction was to tell them I had "no cash on me, sorry." And I drove away.

But as soon as I'd gotten on the road, I thought... what? How cynical have I become that I can't spare $10 in gas to help someone out? So what if they were just scamming me. At worst, I'm out $10 to a couple of people who have resorted to begging to make money. But the flip side was if they weren't lying I could entirely relieve them of a stressful situation for a pittance. I turned around, drove back and filled their gas tank.

I decided then and there that the best case scenario for people asking for money from me was much more valuable than the worst case scenarios could outweigh. If someone's life was to the point where they thought their best option was to go out, usually in dirty clothes, and shamefully ask people for money then even if they were "taking advantage of me" the tiny amount I was giving them still didn't make up for the fact that my life is vastly more comfortable than theirs.

Once I'd taken this view, these encounters were suddenly not uncomfortable at all. I simply give whatever I have whenever someone who looks down on their luck asks. I rarely carry any large amount of cash, so we're only talking a few dollars, but I never debate it anymore.

Today, when I was getting Chipotle for Susie and I, a weather beaten guy with a white mustache in a sleeveless tee shirt sheepishly approached me and asked if I could spare some change. I took out the largest bill I had and gave it to him. It was just $10.

It was just $10 to me, but when he saw the dollar amount, his eyes welled up. He couldn't believe it. He tried to thank me, but he barely had words to give me, so he just hugged me. He tried to hold back his tears, but he had a lake in his eyes when he said "Thank you so much, bless you!"

I told him, "You're welcome, it's no big deal." He replied, stuttering, "It is... it's a big... it takes hours to get just a dollar sometimes... thank you."

Perhaps this man is the best actor in the world and he just stole my $10. Perhaps he laughed when I got in the car and drove away, but I don't think so. He was overjoyed to receive that little piece of money and he got more happiness out of it than anything I could have done with it.

I know that when I give money to aid agencies, they are helping children all over the world who die from diseases that take mere cents to cure. I know that they will put my money to good use, probably better use than that old man will.

But giving to a human energizes me and reminds me why I try to give as much as I "can" to charities who help those much less fortunate than I. It's a humbling, humiliating thing to remember that I'm just human and my dumb brain is wired to care more about things when I can see and experience them.

But that's why I'm glad this poor man ate his pride and asked, politely, for my money... it reminded me why I was ultimately seduced by thrift: to give to those who don't have anything.

Friday, February 5, 2010

APIs are more important than code

I have spent a lot of time in my career worried about clean code. Using patterns and good naming conventions (naming things is still one of the two hard things) to produce the simplest, most elegant code possible. But in the last six months or so I've learned that it doesn't matter.

Well, it does matter but clean code's importance is dwarfed by a few things. Two of those things are API design and scope of responsibility.

No matter how beautiful your code is, if it does too much stuff it's still bad. And no matter how bad the code is, if the API is well thought out, easy to use and doesn't try to have too much responsibility ... you're OK. You can always refactor bad code.

You would think that this would have been obvious to me after I started doing TDD seriously. It wasn't. I mean, I knew API design was important and that code shouldn't do too much, but for me to really grok that API design and scope of responsibility was more important than clean code, I had to see the mistakes being made.

I had to see the far reaching problems caused by modules that did too much or projects that dipped too deeply into the responsibilities of others. The effect of unreadable, bad code is immediately visible. The effect of bad API design or creeping outside the realm of your true responsibility is much, much more insidious and can poison projects and waste a lot of time. Many of the mistakes I've seen over my career could have been prevented by asking these questions, or questions like them:

  • "What does this feature I'm adding have to do with this module I'm adding it to? Does it belong here or is it orthogonal?"
  • "Does this module I'm reimplementing/moving really have responsibility for this feature?"
  • "What information will the caller have when they need my API to do stuff?"
  • "How will the caller want to use my API?" (This should be easy to answer if you're using TDD)
Very simple, obvious questions, but for the longest time I put less emphasis on them than I did on questions like "Should I refactor this decision logic to command pattern?" or "Is this more suited to builder or factory?"

Clean code is important, I still believe. Patterns can certainly make code more elegant. Naming methods and modules is still very hard and very important. But I have re-assigned the weight I'm going to give them. This is the kind of "mental shift" that has happened several times now in my career. They usually occur when I'm transitioning in or out of a job: you readjust what you know based on new evidence or use cases. It's humbling and exciting. It's also usually obvious. (This probably happens to me more than most other programmers since I have little formal training in computer science and I'm just not very good at it.)

So, my new adventure is going to be going back to Python (and using Django this time around) as as kind of a "clean up" consultant for the non-profit my brother works for. This will be an excellent area for flexing/building API design skills since Django has really neat ways to make pluggable, reusable apps. Hopefully, my bitbucket account will fill up with little, tiny, reusable pieces of Python or Django goodness. Wish me luck.