Code is a Liability 47

Posted by tottinger Tue, 17 Apr 2007 02:10:00 GMT

I have thought for a long time that code is liability, and that viewing code as a liability has the power to transform our art. I read articles about code-as-a-corporate-asset and most of them are pretty good articles about wringing the value from the code you have, but I still feel that there’s something essentially wrong about it.

Programs are a great means to an end. Don’t get me wrong, I’m in favor of having software and I’m greatly in favor of writing software. I think we would be in pretty poor shape without it. But I can’t call code an asset.

Functionality is clearly an asset. When we can inter-operate with various services (possibly even web services) our businesses produce more business results more quickly. We use software to control machines and to increase public safety in more ways than most of us know (talk to the guys who write the software that controls your car, the over-the-road trucks, forklifts, industrial robots, and aircraft). Software makes our life better and it’s a wonderful thing. I’m all in favor of software functionality and you have to write code to get it.

Our bosses and clients will pay good money to get the functionality they want, and they want it right now! If we could give them what they want without writing a line, it would be a tremendous win. If we could do it with one line or two lines of well-considered code, we would be heroes! Why is doing less so valuable if code is an asset? Clearly less code is better.

Sadly, most companies have to deal with heaping, shaggy mounds of code. Code takes up time and space. It has to be managed. It has to be versioned. It hast to be tracked, and planned. It has to be updated, and packaged, and revised. It needs backup to save us from having to reproduce it by hand. It has to be reviewed (hopefully in an efficient way like pairing). It often drives companies to expand staff and dedicate people to manage it (version control administrators, managers, build czars, consultants, contractors, metric-gathering tool specialists, etc).

Old code gets in the way of new code. Having more code will typically slow development, and will certainly reduce your ability to incorporate new programmers. Of course you’ll need more programmers because you have all this code to deal with. Size has a cost.

The problem doesn’t go away if you artificially reduce the code. Folding a lot of effects into few lines of code makes the code worse. Adding voluminous documentation makes the code worse. Moving it into metadata and models and other forms doesn’t make it any smaller, and often makes it worse. Hand-crafted code is almost always more readable, smaller, more optimal, more focused, more literary in its style than generated code or funky data tables. Since there has to be code, it might as well be the best code we can write. Coding well takes human beings who value minimalism.

It seems that the trick with the functionality/code game is in trying to maintain a positive balance.

We reach a point on some projects where we are producing a positive number of functions with a net loss in lines of code. That’s a wonderful time. We reduce the line count by simplifying the code and eliminating duplication. Sometimes we refactor our code into a more compact form and then only add a very few lines of code to produce a change. If code were an asset, then those moments would be failures instead of triumphs.

Code size reduction is a very good thing. I want the simplest, the smallest, the least code possible, with the least risk of breaking something else in the system. I don’t want big functions that touch everything in sight. I don’t want long complicated blocks of if/else statements. I don’t want monster functions which conglomerate dozens of operations in a single, fat interface. Shallow is good. Short is good. Less code is good. More code is a liability. This isn’t about typing less, it’s about owning less.

This is the point of view that makes test-first (TDD) so important. TDD/BDD has us encode the functionality (the asset) first, and then write minimal code to realize the specified feature. If code is a liability, and function is an asset, this is exactly the right way to do things.

And maybe, just maybe, it might explain why one might open-source less-important useful systems.

Comments

Leave a response

  1. Avatar
    benrady@gmail.com about 3 hours later:

    I fully agree. I have long espoused the same idea, and have used the following metaphor to explain it…

    Here is the ideal program (written in Python):

    doTheThing()
    
    It does that thing…you know…that thing that your business can’t survive without? That’s what it does. This program is great because it’s easy to read, easy to maintain, and easy to change (while still being closed). For example, lets say that your business gets some venture captial and branches out into a new area, and you have to do a new thing. Well, then, we need to make some changes:
    doTheThing()
    doTheOtherThing()
    
    But wait, you say! Where are my SQL statements? My input/output routines? My GUI? I need that stuff!

    Well, no you don’t. You need the functionality those things provide, but the actual code? No, you don’t need that.

    Which is why, despite what you may have heard, lines of code can, in fact, be a useful metric for productivity. That is; Given the same level functionality (and all other things being equal), less lines of code generally indicates higher levels of productivity, because code == cost.

  2. Avatar
    www.EdmundKirwan.com about 9 hours later:

    I have thought for a long time that legs are liability, and that viewing legs as a liability has the power to transform our gait. I read articles about legs-as-a-corporate-asset and most of them are pretty good articles about wringing the value from the legs you have, but I still feel that there’s something essentially wrong about it.

    Walks are a great means to an end. Don’t get me wrong, I’m in favor of having walks and I’m greatly in favor of doing walks. I think we would be in pretty poor shape without them. But I can’t call legs an asset.

    Wakling is clearly an asset. When we walk our businesses produce more business results more quickly. We use walks to reach machines and to increase public safety in more ways than most of us know (talk to the guys who do the walks to your car, the over-the-road trucks, forklifts, industrial robots, and aircraft). Walks makes our life better and that’s a wonderful thing. I’m all in favor of walking and you have to have legs to do it.

    Our bosses and clients will pay good money to do the walking they want, and they want it right now! If we could give them what they want without moving a leg, it would be a tremendous win. If we could do it with one or two movements of well-considered legs, we would be heroes! Why is doing less so valuable if legs are an asset? Clearly less legs are better.

    Sadly, most companies have to deal with heaping, shaggy mounds of legs. Legs takes up time and space. Legs have to be managed. They have to be versioned. They have to be tracked, and planned. They have to be updated, and packaged, and revised. They need backups to save us from having to walk on our hands. They have to be reviewed (hopefully in an efficient way like pairing). They often drive companies to expand staff and dedicate people to manage them (version control administrators, managers, build czars, consultants, contractors, metric-gathering tool specialists, etc).

    Old legs get in the way of new legs. Having more legs will typically slow development, and will certainly reduce your ability to walk. Of course you’ll need more walkers because you have all these legs to deal with. Size has a cost.

    The problem doesn’t go away if you artificially reduce the legs. Folding a lot of effects into fewer legs makes the legs worse. Adding voluminous documentation makes the legs worse. Moving them into metadata and models and other forms doesn’t make them any smaller, and often makes them worse. Hand-crafted legs are almost always more readable, smaller, more optimal, more focused, more literary in their style than generated legs or funky data tables. Since there have to be legs, they might as well be the best legs we can get. Walking well takes human beings who value minimalism.

    It seems that the trick with the walking/legs game is in trying to maintain a positive balance.

    We reach a point on some projects where we are making a positive number of walks with a net loss in legs. That’s a wonderful time. We reduce the leg count by simplifying the legs and eliminating duplication. Sometimes we refactor our legs into a more compact form and then only add a very few legs to produce a change. If legs were an asset, then those moments would be failures instead of triumphs.

    Leg-size reduction is a very good thing. I want the simplest, the smallest, the least legs possible, with the least risk of breaking something else in the system. I don’t want big legs that touch everything in sight. I don’t want long complicated legs. I don’t want monster legs which conglomerate dozens of legs a single, fat leg. Shallow is good. Short is good. Less legs are good. More legs are a liability. This isn’t about walking less, it’s about owning less.

    This is the point of view that makes sit-first (SDD) so important. SDD/BDD has us consider the walk (the asset) first, and then do minimal legs movement to realize the specified goal. If legs are a liability, and walking is an asset, this is exactly the right way to do things.

    And maybe, just maybe, it might explain why one might open-source less-important useful legs.

    (I know, I know, but I slightly disagreed with the post and couldn’t think of a better way to phrase it.)

  3. Avatar
    Tim Can't Stop Laughing about 10 hours later:

    I can’t stop laughing about “heaping, shaggy mounds of legs” (a need for nair perhaps?), “leg size reduction” (which I could probably use a little), folding effects into legs, and of course the bit about trying to maintain positive balance (perhaps after the third beer?). I’ll read it again later and try to vector in on your slight disagreement, but for now you’ve positively brightened my morning.

  4. Avatar
    Kevin S. about 11 hours later:

    I totally agree with this post, and find developers on my teams naturally discover this on their own constantly.

    As for the legs post… quite a laugh. To seriously consider that metaphor… centipedes are quite fast little bugs and millipedes are typically much slower. It seems that evolution has already proven the right balance of legs….

    So in code and legs we should be thinking that hundreds of lines of code are much better than thousands.

  5. Avatar
    Stan about 12 hours later:

    Maybe all code is an asset, but one chunk is a ton of tin and another is a few ounces of gold. Prefer gold because it’s easier to drop in your pocket and smuggle out of the building. No, wait, that can’t be right.

  6. Avatar
    flipdoubt about 15 hours later:

    In my opinion, this article is based on an over-simplification. All code is not a liability. Bad code is a liability; whereas, good code is an asset.

    It is just like honest to goodness plumbing. Surely, I am interested in the effect (the removal of waste) more than I am with the number of pipes in the ground. Good plumbing is an asset. Bad plumbing is a mess.

  7. Avatar
    Tim 1 day later:

    I didn’t say code was bad. I said it is a liability. By that I mean that it costs, and that the costs recur, and that the costs are proportionate to the volume of the code.

    Update: I found some good stuff from wikipedia:

    In financial accounting, a liability is defined as an obligation of an entity arising from past transactions or events, the settlement of which may result in the transfer or use of assets, provision of services or other yielding of economic benefits in the future. Liabilities have three essential characteristics: * They embody a duty or responsibility to others that entails settlement by future transfer or use of assets, provision of services or other yielding of economic benefits, at a specified or determinable date, on occurrence of a specified event, or on demand; * The duty or responsibility obligates the entity leaving it little or no discretion to avoid it; and, * The transaction or event obligating the entity has already occurred.

    There you go.

  8. Avatar
    Carfield Yim about 1 month later:

    Most developer agree writing less code with same functionality is good. However, one common way is to move logic from code to config. Essentially the LOC is reduced, but the system getting more comlex than it should be.

  9. Avatar
    Kelly Yancey 8 months later:

    Carfield: That is because most people don’t recognize that config files are just another form of code (albeit written in a limited and often non-standard programming language). All these developers are doing is shifting the responsibility for writing the code from themselves to the users—and giving them terrible tools to do it with. No wonder the overall system gets more complex!

  10. Avatar
    Max Guernsey, III 11 months later:

    Yes, code is a liability because it is inventory. All of the attributes you’ve noted about lines of code which make them a problem are facets of inventory. Code is inventory. Inventory that is not being turned over is a liability. Inventory that is being turned over (in this case, enabling functionality) is still a liabiltiy, but the fact that it is delivering value makes it worth more than it is costing. Driving toward zero inventory is always a good thing.

  11. Avatar
    Tim 11 months later:

    @Max: Excellent.

    That is exactly what I want to say and didn’t know to say. Code is inventory. Thank you very much.

    Tim

  12. Avatar
    Max Guernsey, III 12 months later:

    ...so that makes two of us. :)

  13. Avatar
    Andrew about 1 year later:

    What are you guys on about? Code is a massive asset. If it was as simple as typing: DoThatThing(Val As who_cares_because_the_compiler’s_so_clever_it_will_do_whatever_you_intended_anyway) then everyone from the director to the cleaner could do my job! Code is an asset because it scares people. I’m sure you all know of someone who would actually be good at it but they just won’t look at it because they’re intimidated.

    My first piece of advice is to make the functional parts of your code follow the principles discussed in most of the prior posts(i.e. less is more), and add to that heaps of mean, scary looking non-functional code to make sure that when they want something changed, they’ll come crawling back to you!

    Here’s a link to an article called “How To Write Unmaintainable Code”, which will help you to that end.

    http://www.afralisp.net/vbaa/unmain.htm

    My second piece of advice is not to take this post too seriously, but read that article for a good laugh, and even a lvaluable lesson in how not to do things…

  14. Avatar
    Pandora over 4 years later:

    However RSpec uses an alternative syntax that reads more like a specification than like a test. Let me show you what I mean.

  15. Avatar
    Rodrigo over 4 years later:

    I wrote a blog post around your comment that “The problem doesn’t go away if you artificially reduce the code.”

    Would love to have your feedback on it!

    http://blog.outsystems.com/aboutagility/2011/02/code-liability---how-to-reduce-your-risk.html
  16. Avatar
    Criminal Records over 4 years later:

    I’m sure you all know of someone who would actually be good at it but they just won’t look at it because they’re intimidated.

  17. Avatar
    Tenant Screening over 4 years later:

    My first piece of advice is to make the functional parts of your code follow the principles discussed in most of the prior posts(i.e. less is more), and add to that heaps of mean, scary looking non-functional code to make sure that when they want something changed, they’ll come crawling back to you!

  18. Avatar
    dswehfhh over 4 years later:

    We are the professional clothes manufacturer and clothes supplier, so we manufacture kinds of custom clothes manufacturer. welcome you to come to our china clothes manufacturer and clothes factory.

  19. Avatar
    Sunglass over 4 years later:

    Buy Sunglasses with 3-day FREE SHIPPING

  20. Avatar
    clothing manufacturer over 4 years later:

    So in code and legs we should be thinking that hundreds of lines of code are much better than thousands.

  21. Avatar
    Nelson over 4 years later:

    As for your “the British people want to be governed by one parliament not two or three”, the simple reply is No, the people of Scotland and Wales have shown in repeated referenda and elections

  22. Avatar
    sexy dress for sale over 4 years later:

    As for your “the British people want to be governed by one parliament not two or three”, the simple reply is No, the people of Scotland and Wales have shown in repeated referenda and elections

  23. Avatar
    ipad bag over 4 years later:

    TopCombine Follow ipad bag the detail tips below, you can increase the laptop battery life of a year or more. Game Controllers first thing you should care about the USB Gadgets END!XDXDXDXDXXDXDXDXD

  24. Avatar
    SEO Firm India over 4 years later:

    It looks like you have really placed a lot of effort into your blog and I require more of these on the web these days. My husband actually loved your article. I don’t have a great deal to say in retort, I only this minute wanted to comment to say well done.

  25. Avatar
    okey oyunu oyna over 4 years later:

    Okey oynamak hiç bu kadar zevkli olmadi. Online ve 3 boyutlu okey oyunu oyna ve turnuvalara sende katil.

  26. Avatar
    pandora style beads over 4 years later:

    You have a very nice and motivating posting style, it makes me read your articles with great interest.

  27. Avatar
    discounted Pandora Bangles over 4 years later:

    discounted Pandora Bangles

  28. Avatar
    cheap Juicy Couture handbags over 4 years later:

    It’s great when you find relevant content .I can’t stay without admiring your post its really awesome thanks for sharing such a nice content.

  29. Avatar
    bagsupplyer over 4 years later:

    It is nice of you to post this.I will pay more attention on it. Discount new Men sweater vests from China at on line store

  30. Avatar
    balmain dresses over 4 years later:

    thanks for share with us

  31. Avatar
    pandora bracelets over 4 years later:

    see previous spirit elim younger sister that injustice shape. http://www.beadsonsale.net pandora bracelets

  32. Avatar
    renlewei over 4 years later:

    Gucci Shoulder Bags Gucci Clutches http://www.saleguccinewbags.com/gucci-boston-bags-c-58.html">Gucci Boston Bags Gucci Messenger Bags authentic discount gucci bags authentic discounted gucci bags

  33. Avatar
    shanewatson404@gmail.com over 4 years later:

    You guys are really Legal Assistant Job Description wonderful technology is visible in this blog that to searching the nice info is visible in this blog. I am searching the different services in this Director of Operations Job Description blog and the interesting services in this blog Accounting Job Description This is really inspired the Graphic Designer Job Description great technology that to using the amazing the info is visible in this blog

  34. Avatar
    ysbearing over 5 years later:

    Slewing ring is also called slewing bearing, some people called: rotary support, swing support. English Name: slewing bearing or slewing ring bearing or turn table bearing, slewing ring in the real industrial applications is very wide.

  35. Avatar
    careful fraud over 5 years later:

    Plz be careful for this fraud ?she can use credit CARDS and PAYPAL for fraud, buy a lot of products after say that no received, and then ask for

    a refund, or receive fakes, give you return the empty package. Please be careful the fraud?This is paypal account: sarah cockle 6b School Road Kingswood Bristol, Avon BS15 8BJ United Kingdom 07943148074

  36. Avatar
    careful fraud over 5 years later:

    Plz be careful for this fraud ?she can use credit CARDS and PAYPAL for fraud, buy a lot of products after say that no received, and then ask for

    a refund, or receive fakes, give you return the empty package. Please be careful the fraud?This is paypal account: sarah cockle 6b School Road Kingswood Bristol, Avon BS15 8BJ United Kingdom 07943148074

  37. Avatar
    iPhone contacts backup over 5 years later:

    It is true.Well. Though I am not a good application developer. And I need do more hard work to improve myself. When I come to here. I know that I have come to the right place to learn something I need. Thanks for your good advice. And I will do the practice as possible as I can. Thanks.

  38. Avatar
    china crafts over 5 years later:

    Maybe all code is an asset, but one chunk is a ton of tin and another is a few ounces of gold. Prefer gold because it’s easier to drop in your pocket and smuggle out of the building. No, wait, that can’t be right.

  39. Avatar
    rental genset over 5 years later:

    Been reading this site for awhile now, always has really good posts and topics please keep it up! loads of blogs are going under lately from lack of new posts etc dehumidifier | sewa genset

  40. Avatar
    M2TS Converter over 5 years later:

    When I originally commented I clicked the Notify me when new comments are added checkbox and now each time a comment is added I get four emails with the same comment. Is there any way you can remove me from that service? Thanks! , convert m2ts video to avi, mpeg, wmv, flv, mp4, mov, dvd, vob

  41. Avatar
    Christian Louboutin Stroe over 5 years later:

    Thank you for bringing more information to this topic for me.After reading you site, Your site is very useful for me . [url=hhttp://www.christianlouboutin-onlineshop.com/]Christian Louboutin Online Shop[/url] Thank you for providing this information.I hope we can learn from each other.0Y366YJ

  42. Avatar
    business templates over 5 years later:

    Great Work. Recently i am seeking for a dofollow blog list. Thanks for sharing.

  43. Avatar
    louboutin sales over 5 years later:

    Code is a Liability 42 hoo,good article!!I like the post!19

  44. Avatar
    Car Rental Gatwick over 5 years later:

    excellent information keep up your good work thanks.

  45. Avatar
    corporate catering philadelphia over 5 years later:

    code can also be hidden within tags. this is best for corporations

  46. Avatar
    Car Rental Gatwick over 5 years later:

    Well I definitely enjoyed reading it. This article provided by you is very helpful for accurate planning.

  47. Avatar
    car hire heathrow over 5 years later:

    Great post. I was checking continuously this blog and I’m impressed! Extremely helpful info specially the last part I care for such information a lot. I was seeking this certain information for a very long time. Thank you and best of luck.

Comments