Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

10
  • 11
    @Gulzar: From personal experience in writing both production-quality and single-use throwaway code: Yes, they do make you faster - initially. As you correctly point out, dirty coding can come back to haunt you much sooner than you'd expect. And, obviously, the long-term cost usually outweighs the short-term gains by a large factor. In fact, the only legitimate use case I see for these techniques would be small, time-critical emergency hotfixes (system is down and customer loses $$$ per hour), but even then I'd try to replace it with a clean solution as soon as possible. Commented Apr 9, 2022 at 11:19
  • 8
    1. But don't attempt to obtain 100% code coverage either. You won't get it. There is a sweet spot for testing; write enough tests to demonstrate that the code works, and no more than that. Commented Apr 9, 2022 at 12:02
  • 6
    2. Copy/pasting code and modifying it is absolutely the right thing to do in many cases. DRY can be taken to absurd extremes that waste time, make the code more complex and difficult to read, and do nothing to improve the overall architecture. Commented Apr 9, 2022 at 12:07
  • 2
    4. It depends. If you're in a small local scope, x, count or var are perfectly good names for variables, and if you are writing your code correctly, you should be in a small local scope much of the time. Commented Apr 9, 2022 at 12:11
  • 5
    5. Your code should be easy enough to read so that you don't need comments most of the time. Comments should be reserved for explaining why, not how, and should be used primarily to point out relationships between classes and methods (i.e. architectural considerations). Commented Apr 9, 2022 at 12:13