3 ms·
Something else that can help is that once you've learned how to write clean, safe, reusable code, the next step is learning when not to. Clean code is an expens
by jerf 13y ago
Something else that can help is that once you've learned how to write clean, safe, reusable code, the next step is learning when not to. Clean code is an expense, and there's times to put in the extra effort, and there's times to not. Code's needs are not evenly distributed, in fact they are very unevenly distributed (power law distribution I suspect without proof)... carefully crafting to the n-th degree an end-user GUI page for a marginal feature is probably a waste of time, just make it work. On the other hand, adding a hack to a core routine used by huge swathes of the code may have much bigger negative effects than it even feels like now, and it sounds like it already feels pretty bad.
Consider working on the next level and using this as a chance to study when and where the effort is actually worth it. It may feel like you're handing yourself a license to be sloppier, but if done correctly this actually turns you into an even more capable developer than someone who finely engineers everything, because you'll have that much more time to finely engineer the things that matter once you clear away the time of fine engineering of the things that don't, and on the whole you'll be creating much more value in your code.
- jafaku 13y agoI wouldn't mind writing unclean code if I weren't the one who's going to have to maintain it and add new features to it in the near future or the years to come.
- jerf 13y agoThis is part of what I mean by learning when it is and is not appropriate; I tried to make it clear it was not a blanket permission slip to be sloppy (anticipating that obvious misunderstanding of my point). If you end up having to seriously maintain "unclean" code, you did it wrong. You will do it wrong before you get the hang of it, no sarcasm. Untrained gut intuitions are not very reliable here, and the only training available is practice. And on the other hand, "maintain" is a very ambiguous word. If you are frustrated because it took you ten minutes to add one field to a form, once in the course of 3 years (to put some concrete numbers on for example's sake), you still came out ahead not spending an additional 10 hours polishing the code to a fine sheen, so you could be happy adding that one field 3 years later and saving that ten minutes. If you're frustrated because you actually have to overhaul it significantly, and it's a mess, and now you've also dropped all your context and can't remember what is what at all, and you could have cleaned up up three years ago in three hours and now lose two weeks just to understanding what the hell, then you've lost, yes. And of course "maintain" can mean a lot more than either of those two cases, too. And as a final note, it's all gambling, and that is also something you must come to grips with. You don't really know where the changes are going to be in three years. However, you can learn to guess with a success rate much higher than mere random chance. (Don't forget to discount future time appropriately.)