I, for one, think this is good advice for code in general. At least "at first, solve a problem, not a class of problems".
I have noticed that if I write my code too general at first, it ends up solving one class of problems kinda poorly, and ends up being re-written. If I write it for the specific problem I need to solve, and then generalize it to include another similar problem when I need to (and continue this process), I end up with very solid generalized code that solves a specific class of problems very (IMO) elegantly. It still gets re-written, but in a small-chunk iterative fashion.
This, of course, may be because of the way I think - or it may be due to me being relatively "young" as a developer. I am slowly generating more general purpose code that is getting reused for similar problems in different applications, however I write much more code for specific problems than I re-use.
Perhaps someone who's been doing serious coding work for more than a few years would like to weigh in on this?
I've always liked the rule of three; the first time, solve just your immediate the problem. The second time, notice that you solved the same problem twice. If the same situation occurs a third time, write a general solution.
I couldn't agree more. I call this ORYO: Only Repeat Yourself Once. Actually, I often put comments in my code marking places I've already repeated myself (saying 'ORYO' plus a reference, if needed).
I, for one, think this is good advice for code in general. At least "at first, solve a problem, not a class of problems".
I have noticed that if I write my code too general at first, it ends up solving one class of problems kinda poorly, and ends up being re-written. If I write it for the specific problem I need to solve, and then generalize it to include another similar problem when I need to (and continue this process), I end up with very solid generalized code that solves a specific class of problems very (IMO) elegantly. It still gets re-written, but in a small-chunk iterative fashion.
This, of course, may be because of the way I think - or it may be due to me being relatively "young" as a developer. I am slowly generating more general purpose code that is getting reused for similar problems in different applications, however I write much more code for specific problems than I re-use.
Perhaps someone who's been doing serious coding work for more than a few years would like to weigh in on this?