There are some greate advice however its impractical in the real world. (I am not defending copy and paste, the DRY principle should be your number one rule.) Most (good) contractors work in this way however its impossible to lay out your solution to its entirety and build a beautiful solution. Without specs being changed on you or you realizing that what you are building is not something the clint wants.