Wednesday, November 24, 2010

Flavors of optimization

I was thinking the other day about optimization. What does it mean to optimize code? Well it depends. What are you optimizing with respect to? It seems like everyone got their favorite type of optimization.

You can:
  • Optimize for the long-term speed of feature development and bug fixes
  • Optimize for performance (this is what people think of as optimization by default). 
  • Optimize for minimum time spent doing any work, which means
    • Offloading onto others
    • Making small features look more important
    • Making useless features look useful
    • Shoving off bugs for later (hopefully forever) or to others
  • Minimize the amount of wasted work
    • I don't want to do something now, which has to be redone later
    • I don't want to make a temporary fix now, because there might be a proper fix later
  • Maximize for maximum features per day
    • Short term speed of development above all
    • No time for design, refactoring, or performance optimizations 
    • Focus on appearance of progress, and the total volume of code produced, regardless of correctness, extensibility, and readability
    • Bug fixing is considered a completely separate process, which essentially gets in the way of progress, testers are annoying
    • Documentation is considered a nuisance
    • Other programmers who point out bugs are also annoying
  • Maximize for prettiness over functionality
What's funny is that in a large project, every one of these optimizations will be present, resulting in a mixture of crappy code, pretty code, buggy code, easily maintainable code, and performance-optimized code, all mish-mashed with parts trying to interact with each other. 

No comments:

Post a Comment