1
vote
4answers
257 views

What's the most readable way of echoing from PHP?

Should I use <?php if(!$user->is_logged_in()){ echo '<p id="login">Click <a href="login">here</a> to log in</p>'; } ?> or <?php ...
5
votes
4answers
347 views

In which order should I do comparisons? [duplicate]

I'm a strong proponent of writing if statements like this: variable == constant Because to me it just makes sense, it is more readable than the inverted: constant == variable Which seems to be ...
17
votes
5answers
1k views

Descriptive naming vs. 80 character lines [closed]

I frequently hear these two valuable programming practices: (1) lines of code should be 80 characters or less and (2) use descriptive names for variables, methods, classes, etc. I understand the ...
19
votes
7answers
2k views

while(true) and loop-breaking - anti-pattern?

Consider the following code: public void doSomething(int input) { while(true) { TransformInSomeWay(input); if(ProcessingComplete(input)) break; ...
107
votes
20answers
10k views

How would you know if you've written readable and easily maintainable code?

How would one know if the code he has created is easily maintainable and readable? Of course in your point of view (the one who actually wrote the code) your code is readable and maintainable, but we ...
10
votes
12answers
1k views

Maintainability of Boolean logic - Is nesting if statements needed?

Which of these is better for maintainability? if (byteArrayVariable != null) if (byteArrayVariable .Length != 0) //Do something with byteArrayVariable OR if ((byteArrayVariable != ...