I love the feeling after having rewritten some code part with the results of having it much shorter, much clearer, more stable and even faster. :) In almost all cases, it was worth it.
The strange thing is, sometimes there are multiple iterations of this on the same code part (sometimes by different people, sometimes even by my own).
Then I am thinking, maybe I just have gotten wiser, have learned my lesson or whatever. Stupid me that I haven't implemented it in the first place like this.
Also, I am always wondering, how much more iterations are there until I get to some final, perfect, optimal solution.
Or will I really end up with one single line of code in the end? :)
All code can be made shorter. But all code also has at least one bug. So eventually your code will be just one byte - but it will be the wrong byte :-)
If you look at programming as a knowledge acquisition activity instead of a code production activity, then you couldn't possibly have implemented it that way in the first place.
Exactly. Usually I don't have (or give myself) the luxury, but when I'm working on something small and I don't really have time constraints for it, I will write it, then rewrite it, then look at it from a different angle, and rewrite it again. Only after about three rewrites will I get something that looks good.
I'd like to bring this down to writing something good looking earlier, but it's like you say - I only learned it then and there.
The strange thing is, sometimes there are multiple iterations of this on the same code part (sometimes by different people, sometimes even by my own).
Then I am thinking, maybe I just have gotten wiser, have learned my lesson or whatever. Stupid me that I haven't implemented it in the first place like this.
Also, I am always wondering, how much more iterations are there until I get to some final, perfect, optimal solution.
Or will I really end up with one single line of code in the end? :)