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.

Required fields*

8
  • 72
    You answered your own question, you cross the line when you need to cross the line Commented Jul 5, 2011 at 1:32
  • 6
    Also, your "dirty code" may work just as fast as "clean code" on hardware 6 months from now. Don't go overboard like Windows did, though. :) Commented Jul 5, 2011 at 6:32
  • 23
    There is a significant difference between a difficult-to-understand algorithm, and difficult-to-understand code. Sometimes the algorithm you need to implement is complicated, and the code will necessarily be confusing, simply because it's expressing a complex idea. But if the code itself is the difficult point, then the code should be fixed. Commented Jul 5, 2011 at 7:25
  • 8
    In a lot of cases a smart compiler / interpreter can optimise clean, readable code so it has the same performance as "ugly" code. So there's little excuse, unless profiling says otherwise. Commented Jul 5, 2011 at 8:27
  • 1
    When it comes to compilers these days, your ugly code will most likely be the same as your clean code (assuming you don't do any really weird stuff). Especially in .NET, it isn't like C++/MFC days where how you define your variables will have an impact on performance. Write maintainable code. some code will just end up being complex but that doesn't mean it's ugly. Commented Jul 7, 2011 at 14:37