Most of my work is done for a specific customer, and if I am under NDA I am not supposed to contact another client saying “hey, I already have a perfect solution for you, I wrote it for XXX”. Since I am an ethical being, that’s what I do : only people involved in the project – administrative, technical, or any other level – have the information. They are free to use the knowledge according to their own ethics and NDAs.
But what happens if a client comes and asks for something I have already done? Either it’s because he has seen the thing in action, or just because he thinks I’m the right person to create his solution from scratch. In the first case, the question is easy : am I allowed to use my knowledge and my code to help him as well? And the answer is by default “yes”, unless it has been specified in the contract that this was not a possibility. In the second case, should I say I already have something? The default answer is “no”, but I am allowed to say I have some experience on the topic at hand.
Of course, “using my code” rarely means giving the exact same program, since every client has his own set of expectations, but 90% of the code has been written already. Besides, there might be bugs to fix, things to enhance, and whatnots.
The question is “what am I supposed to say when I give a budget/deadline?”. Technically, this is still a lot of work, and one can’t be 100% sure the solution is accurate. Therefore, giving the program back after 2h of work is not reasonable. Saying “10% of code-rewriting, 10% of the original budget” is also not a very good idea : your code is your creation, it’s worth more than just $XXX/line.
Of course, you also have to take the Sympathy Factor into account. All in all, I tend to have a common base fee, and then upgrade it according to the difficulties/short deadlines I happen to stack on top of what I already have. That way I ensure that my work (albeit cumulative) has some value, and I’m not lying to my customers about the time I spend on their projects : even if it takes less work the second time around, it’s still work. The “bonus” part on the fee is reduced to a minimum to make sure it’s not extortion.
And then, sometimes, you have someone who thinks that since you gave a good price on second-hand code, it means that all projects have the same value. That’s why the base fee has to be reasonably high to make a point : experience also has a price.