Wednesday, January 13, 2010

Making the improvments - leaky abstractions

A while back I was reading a post by Jeff Atwood about abstractions in code. Jeff was in turn was picking on something that Joel Spolsky had written, but the gist of the post was pertaining to abstractions in code.

The gist of Jeff's post is I think summed up in the following:

It's our job as modern programmers not to abandon abstractions due to these deficiencies, but to embrace the useful elements of them, to adapt the working parts and construct ever so slightly less leaky and broken abstractions over time. Like desperate citizens manning a dike in a category 5 storm, we programmers keep piling up these leaky abstractions, shoring up as best we can, desperately attempting to stay ahead of the endlessly rising waters of complexity.

Leaky although abstractions may be, they do improve the code - readability, maintainability (other ilities) over time. As Jeff mentions - the question is:

Does this abstraction make our code at least a little easier to write? To understand? To troubleshoot? Are we better off with this abstraction than we were without it?

I think in a large majority of the cases that the answer is yes - the abstraction helps to improve the code in ways that allow it to be better understood by others, easier to maintain in some ways and sometimes hard to maintain in other ways. The abstractions can allow new code features to be easier to write and get into production. In essences code abstractions can help programmers to work to make things better all the time for the next person coming along.

Abstractions can also allow you to get to market quicker and then work to fix issues down the road. This is essentially how I think Microsoft works, get version one out the door and then work to plug the holes in the dike - fix the leaky abstractions that have caused issues. Overtime Microsoft builds better abstractions and better code until something solid that people will like or like better then version one comes out. Personal opinion here is that Windows did/does this, and so does c#/cli. (On a completely side note it is also interesting to note that this build, deploy - revise is something that java does not do very well at all. For all the touting that people make of the JCP, the whole thing seems to be lagging behind what the cli and C# have to offer programmers in terms of ease and simplicity.)

Abstractions are an important part of programming and of how people deal with the world around them... trying to fit ideas and thoughts into buckets of how things are and how they work. People use abstractions because it helps them think about things in ways that are comprehendable/understandable/manageable - this is no different... programming abstractions help us to understand the systems better and make it easier to do certain types of things. Are abstractions leaky? Yes - I think they all are, not a single one of them hits every nail like it was a hammer but they improve things enough to allow progress towards a goal.

No comments: