On DRY and the cost of wrongful abstractions
I am firmly in the DRY camp with a very important caveats:<p>1- Do no generalize so you can factor out like code too early. The first time just write it. The second time write it again even if only minimally different. The third time is a judgement call. By the fourth time you see the proper abstraction, something that might have been much different if you were to have refactored early on.<p>Corollary to #1- Don&#x27;t run ahead of yourself making all these placeholder functions, interfaces, and abstract classes with the expectation that you would have had to refactor this way later. Unless you done versions of your project a dozen times (even then, sometimes I don&#x27;t even do it), you are most likely going to be wrong.<p>2- Don&#x27;t refactor out single lines unless there a lot going on on that line or you have the experience to know (don&#x27;t lie to yourself either) that this will be an important and growing line.<p>3- Sometimes performance can trump. And sometimes you do know this ahead of time, especially if performance is correctness as it is on some projects with very tight constraints.<p>Besides that. I freaking hate seeing similar code everywhere, blowing up my instruction cache, making changes difficult. Please stop it.