Reusable code vs. Performant code


I just happened across this quote and it makes me want to rush out and buy that book…


“In the last ten years we have encountered quite a few C++ projects that fell far short of their required performance. At the heart of those performance failures was a design and an implementation geared for extreme flexibility and reusability. The obsession with reusable code has produced software that, due to the lack of efficiency, was not even usable, not to mention reusable. … The problem is that performance and flexibility are often enemies. It is not an artifact of poor design or of implementation. We are talking about a fundamental tension between two forces that are pushing in opposite directions.”
    —Dov Bulka, David Mayhew, Efficient C++: Performance Programming Techniques, p. 223.

Comments (3)

  1. Keith Patrick says:

    Heh…I fell into that trap. I’ve got an app I am writing where I started with the mantra: Design first, performance later. I’ve had to rethink it as I started to flesh bits of it out (although I hardly consider it unusable or even really that slow, but I took some principles to extremes). On issue that has had me come to a standstill, though, is that at the core of it is a grid computing framework. Once I heard that Indigo gears folks towards web services and away from remoting, it disenchanted me a bit, as I wanted to enable things such as running a 3d engine on one machine but sound on another (impractical, yes, but if someone chooses to configure it that way, so be it; typical usage follows a more optimized, local path) Where I’m getting at is that certain high-level architectural decisions can ultimately tie your hands with regards to performance.

  2. Vincent Dumas says:

    This mentioned that "tension between two forces that are pushing in opposite directions.”

    A balance is certainly to be maintained between reusability and performance.

    My rule of thumb is more this:

    Project requiring high level of reusability most of the time also require good performance. Said differently the more your code is to be invoked by some other component, the more it needs to be efficient and reusable.

    But projects requiring high level of performance do not always require the great reusability.

    Lower level programming require high performance and less reusability. Operations are to be called massively. So one need to concentrate on the critical sections of your processing and how is your environment coping with the chosen software architecture. Operations such as OS and media (speech, graphics, sound, drivers ) processing fall into that category.

    This is not the kind of projects most people everyone need to be involved in.

    Most of the time developpers want performance and less reusability. Most managers want reusability and performance.

    The result of this is it takes more time to acheive this equilibrium when high reusability when it is not a priority.

  3. OK here’s the respones to my highly non-scientific survey Your project is "In Trouble." The Big Boss