Tuesday, October 20, 2009

software re-use is overrated

- Don't write your own web server.
- Eclipse is a good platform for UI applications, use it.
- Tons of languages are available, use them don't invent a new one

You might have reasons not to follow the advise above and I am sure in that case you know what you are doing. For most people this is good enough. This is reuse of the software and it is kind of must. Some people end up writing a Utils class and want everyone to use it. Actually everyone writes their own. It is alright... write your own.

I have started comparing speed of software development with the disk read/write speed. When you do lots of seeks here and there you can only do about 200-300 per second. But when you start writing continuously you can do may be 50MBPS. Software reuse also has a similar cost. It increases the number of "seeks" you have to do and the limit is tight. The more you need to think about when reusing the code, you end up introducing more complexity and next change needs more "seeks". When trying to reuse the code think about the size of reuse. If the code you are trying to reuse will save your say 10K lines of code, do it. It is worth it. May be change those 10K lines of code so that they are more reusable..but saving 100 or 500 lines of code will definitely cause more trouble than help. I have seen people trying to write something which is may be 1K lines of code in a single file into 20 files with 50 lines each. As the number of classes (concepts, terminology) increases, it becomes more reusable because each of these classes can be independently used but it increases the complexity of the code..so that it is hard to maintain, things which could be private are now public and instead of 1 file now we have 20 which is hard to understand. By decreasing the complexity of each file, we ended up introducing the complexity of 20 concepts. This is the kind of reuse which is uncalled for.

When thinking reuse..think substantial and think simple. If it is not substantial and it is not simple, chances are it is not going to be reused. So make your life easier by designing against reuse. By taking reuse out you have better control of the specification/requirements and code will be minimal and complete. By not reusing other peoples code and by doing nothing to make your code reusable you are doing a great service to people who will be maintaining this code. You are making it simple, to the point and will also do is fast, possibly less buggy and easier to test.

No comments:

Post a Comment