Sloppy Code - thoughts
-
About what?
-
Probably. :(
-
While we're on the subject of code reviews, what do you guys think about sloppy code that's not formatted well? I tend to not think I'm that anal retentive, but I admit the poindexter comes out when I see sloppy code that's not kept up to a proper margin, not indented decently, old commented code left in, etc. Oddly enough, the coders that write messy code tend to also have messy cars and homes. It's gross.
Jeremy Falcon
Jeremy Falcon wrote:
what do you guys think about sloppy code that's not formatted well?
I don't think much of it. IMHO code should be formatted so that its intent is clear. While I prefer the K&R style, I'm not picky as long as the style is readable. /ravi
My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
-
However awful my code might be, at least it's properly formatted... :-) I agree with you; it's the same when I interview a developer that turns up looking like a homeless person: if you can't be bothered to take care of yourself, why would I believe that you'd be any different with your attitude to coding?
Use a tool for codeformatting, make sure to run it before you commit your code, or make your editor format your code. Codeformatting "by hand" is waste and should be eliminated.
-
Use a tool for codeformatting, make sure to run it before you commit your code, or make your editor format your code. Codeformatting "by hand" is waste and should be eliminated.
I do that to other people's code. :-)
-
I do that to other people's code. :-)
When you do that: - It seems in the source control that you modified the source code - It looks insulting for the other developer (the one who originally wrote the code) If you can't agree in a friendly conversation on one style of code, then you have more important problems to tackle in the team.
Make it simple, as simple as possible, but not simpler.
-
It's so easy to format your code properly... Ctrl + K, Ctrl + D (in Visual Studio anyway). It doesn't delete white spaces, but it does quite a bit for you. I'm amazed at how much badly formatted code I still see! And in my experience if the code is poorly formatted it's poorly written. Comments are as bad, or worse...
// Create a new person
Person p = new Person();NO, REALLY!? Arghhh! And I actually see those kinds of comments... Another thing I can't stand is copy-paste programming. And much too often it's way too obvious. The following is some production code I've had the 'pleasure' of working with (it was an obvious comment that was copy-pasted, but not edited with the code).
// Save the customer
product.Save();I looked at it and screamed in disgust "OH LORD, WHY DO YOU HATE ME SO!? :(( "
public class SanderRossel : Lazy<Person>
{
public void DoWork()
{
throw new NotSupportedException();
}
} -
When you do that: - It seems in the source control that you modified the source code - It looks insulting for the other developer (the one who originally wrote the code) If you can't agree in a friendly conversation on one style of code, then you have more important problems to tackle in the team.
Make it simple, as simple as possible, but not simpler.
Adam Tibi wrote:
It seems in the source control that you modified the source code
Indeed.
Adam Tibi wrote:
It looks insulting for the other developer (the one who originally wrote the code)
Then they should have done it right the first time. Seriously, if you're insulted because I tell you to format the code according to our agreed upon standards, then you're working in the wrong place.
-
While we're on the subject of code reviews, what do you guys think about sloppy code that's not formatted well? I tend to not think I'm that anal retentive, but I admit the poindexter comes out when I see sloppy code that's not kept up to a proper margin, not indented decently, old commented code left in, etc. Oddly enough, the coders that write messy code tend to also have messy cars and homes. It's gross.
Jeremy Falcon
-
Have you ever seen pictures of Einstein's office?
If you think 'goto' is evil, try writing an Assembly program without JMP.
Touché!
Jeremy Falcon