Tagged Questions
7
votes
3answers
162 views
When comparing a combination of String literals, is it convention to call .equals() on the literal? [closed]
There are benefits to each, and I understand the differences - but what is considered best / standard practice? Why?
"myString".equals(myStringVar)
Avoids a potential NPE and does not require a ...
41
votes
14answers
3k views
Why do most of us use 'i' as a loop counter variable?
Has anyone thought about why so many of us repeat this same pattern using the same variable names?
for (int i = 0; i < foo; i++) {
// ...
}
It seems most code I've ever looked at uses i, j, ...
79
votes
17answers
3k views
Can a function be too short?
Whenever I find myself writing the same logic more than once, I usually stick it in a function so there is only one place in my application I have to maintain that logic. A side effect is that I ...
12
votes
6answers
424 views
Can there be too much uniformity in coding standards?
Is there such a thing as too much uniformity? Where I work we of course have standards including naming conventions, architectures, frameworks to leverage etc. However lately there has been a lot of ...
12
votes
17answers
1k views
What should be the maximum length of function
In your opinion what should be the maximum length of function, and if there are cases which are exception to this. Also give reasoning (if any) behind the answer.
19
votes
5answers
1k views
Method vs Function vs Procedure
Simple question, but I often hear these three terms defined with such ferocity, but which have been known to me to mean different things over the years.
What are the "correct" definitions of ...
10
votes
12answers
637 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 != ...