::  Posts  ::  RSS  ::  ◂◂RSS  ::  Contact

Programming: Repurposeability

February 23rd, 2009
repurposeability, programming  [html]

How much needs to be changed when you find out the problem you thought you were solving differs substantially from the actual problem? Programmers complain about this all the time, generally when it's not their fault. A manager comes in telling you that some cost you thought was negligible isn't. A client finally sees a prototype and tells you you've conflated two similar but crucially distinct categories. It's easy to say "stupid non technical people -- can't they tell me what they really want from the start?", but its not always someone else's fault, and this fixes nothing.

Given that we are always constructing models of problems and nearly always must begin before our understanding is total, times when we must repurpose our code are unavoidable. Then this presents a metric for evaluating a programming style or language: repurposeability. That is, when one writes code in this fashion and finds out that one was solving the wrong problem, how much work is needed to repurpose it to solve the problem one should have been solving all along?

Repurposability is the driving force behind many aspects of good coding style. The avoidance of duplicate code, for example. Say you need to send some debugging output to a file instead of standard output. In java you might have a gui program with hundreds of calls to "System.out.writeln()" that really should be calls to some debug function. So this is a programming style issue. It is also a programming language issue, though. In common lisp one might deal with this problem with a statement equivalent to "in the code called from here, substitute this object for System.out". Similarly in java, you might have hundreds of reads and writes to the object attribute "Foo.bar". The standard arguments for java tell you to make them be to "Foo.setBar()" and "Foo.getBar()" instead, so if you later change your mind you don't have to change all those references to "Foo.bar". The advice is so to maximize repurposeability. But in python one would solve the same problem by using Foo.bar all along and taking advantage of the ability to wrap it in getters and seters later if needed.

I need to think more about what is needed for repurposeability, but it certainly sounds like a useful metric.

Comment via: facebook

Recent posts on blogs I like:

How Fast New York Regional Rail Could Be Part 3

In the third and last installment of my series posting sample commuter rail schedules for New York (part 1, part 2), let’s look at trains in New Jersey. This is going to be a longer post, covering six different lines, namely all New Jersey Transit lines t…

via Pedestrian Observations October 21, 2019

Strong stances

I. The question of confidence Should one hold strong opinions? Some say yes. Some say that while it’s hard to tell, it tentatively seems pretty bad (probably). There are many pragmatically great upsides, and a couple of arguably unconscionable downsides. …

via Meteuphoric October 15, 2019

What do executives do, anyway?

An executive with 8,000 indirect reports and 2000 hours of work in a year can afford to spend, at most, 15 minutes per year per person in their reporting hierarchy... even if they work on nothing else. That job seems impossible. How can anyone make any im…

via apenwarr September 29, 2019

more     (via openring)

More Posts:


  ::  Posts  ::  RSS  ::  ◂◂RSS  ::  Contact