WTF : if and foreach on the same line? - Peter's Software House

WTF : if and foreach on the same line?

I’m sorry but I couldn’t resist.  Why the hell would you write your code like this?

WTF

Isn’t this a lot more readable?

Better

I don’t like the naming conventions, but at least its consistent.

Published Wednesday, June 17, 2009 11:51 AM by Pieter
Filed under:

Comments

# re: WTF : if and foreach on the same line?

Yeah, but I do prefer not having the curlies for single line statements. Just think it looks less busy.

Wednesday, June 17, 2009 7:09 AM by codingsanity

# re: WTF : if and foreach on the same line?

How do you create these nice torn paper screenshots?

Wednesday, June 17, 2009 8:04 AM by Pete

# re: WTF : if and foreach on the same line?

I'll keep the if curlies, but will drop the foreach curlies. Makes it cleaner and more readable.

Wednesday, June 17, 2009 8:37 AM by Agutator

# re: WTF : if and foreach on the same line?

My opinion is either do a full one-liner or format all with curlies. Both are just as easy to read on large screens.

Wednesday, June 17, 2009 3:10 PM by Ramon Smits

# re: WTF : if and foreach on the same line?

What about Array.ForEach()?

Wednesday, June 17, 2009 11:22 PM by Pieter

# re: WTF : if and foreach on the same line?

@Pete

I use SnagIt from TechSmith

Thursday, October 01, 2009 1:50 AM by Pieter

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above: