I AM SO TIRED OF READING THE WHOLE SQL STATEMENT / STORED PROCEDURE IN FULL CAPS. WHAT THE HELL WERE THE INITIAL DEVELOPERS THINKING?
What's the best style (in terms of cap, indentation, lines breaks, etc) to write SQL in?
...
I have always used tabs for indentation when I do Python programming. But then I came across a question here on SO where someone pointed out that most Python programmers use spaces instead of tabs to minimize editor-to-editor mistakes.
How does that make a different? Are there other reasons why you would use spaces instead of tabs for P...
I'm processing, let's say a list of "Document" objects. Before I record the processing of the document successful I first want to check a couple of things. Let's say, the file referring to the document should be present and something in the document should be present. Just two simple checks for the example but think about 8 more checks b...
By favorite I mean the one that gets your goat the most, not the one you enjoy using the most.
I'm fairly new to the concept of anti patterns and I'd like a list of do not do's. An explanation of why it's an antipattern and what problems it causes would be good too.
...
I'm learning Haskell hope it could let me getting closer to functional programming, before learing it, I mostly use C-sytanx like languages, like C, Java or D Programming Language.
I followed the tutorial on Wikibook, it goes well so far, I could understand most of them before the chapter "Simple input and output"
But I do have a littl...
Last year I was troubleshooting a team member's code and it was lacking indents and comments. I was talking to him about it telling him it was not a good idea but he got offended. He was/is smarter than me or certainly more educated.
Since then I found out he applied to Microsoft and when they had him do a doubly linked list implementa...
PEP 08 states:
Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants.
However if the class/method/function that I am importing is only used in rare cases, surely it is more efficient to do the import when it is needed?
Isn't this:
class SomeClass(obje...
When coding, what in your experience is a better approach?
Break the problem down into small enough pieces and then implement each piece.
Break the problem down, but then implement using a top-down approach.
Any other?
...
When writing "library" type classes, is it better practice to always write markup documentation (i.e. javadoc) in java or assume that the code can be "self-documenting"? For example, given the following method stub:
/**
* Copies all readable bytes from the provided input stream to the provided output
* stream. The output stream will...
Everybody's screen size and font are different, so while my code fits on my screen, it might scroll off the right edge of your screen.
What should be the maximum length of a line of code?
...
And... we have another QAW (Quality Assurance War) on our hand.
After reading the more generic "What kind of prefix do you use for member variables?" question, I tried to argue with my QA department about the advantages to always add 'this' before instance (or member) variables in java code. They are not convinced.
I know there is a si...
This may be a matter of style, but there's a bit of a divide in our dev team and I wondered if anyone else had any ideas on the matter...
Basically, we have some debug print statements which we turn off during normal development. Personally I prefer to do the following:
\\---- SomeSourceFile.cpp ----
#define DEBUG_ENABLED (0)
...
So...
A colleague of mine states that booleans as method arguments are not acceptable. They shall be replaced by enumerations. At first I did not see any benefit, but he gave me an example.
What's easier to understand?
file.writeData( data, true );
Or
enum WriteMode {
Append,
Overwrite
};
file.writeData( data, Append );
Now I got i...
All throughout an application wherever error messages (or other user messages) are used I typically hard-code a string. Obviosly this can be really bad (especially when you may have to come back and localize an app). What is the best approach to centralize these strings? A static class? Constants? An XML File? Or a combination (like crea...
In C++ you can initialize a variable in an if statement, like so:
if (CThing* pThing = GetThing())
{
}
Why would one consider this bad or good style? What are the benefits and disadvantages?
Personally i like this style because it limits the scope of the pThing variable, so it can never be used accidentally when it is NULL. However, ...
Given a coding standard with a maximum line limit of X characters, minimising deep nesting can avoid exceeding that length. Sometimes this leads to a code that looks like:
if (fail test)
{
return(failed)
}
// continue
...
return(success)
In general, should a method only have a single return point, or are multiple ok?
Ideally, plea...
The most egregiously redundant code construct I often see involves using the code sequence
if (condition)
return true;
else
return false;
instead of simply writing
return (condition);
I've seen this beginner error in all sorts of languages: from Pascal and C to PHP and Java. What other such constructs would you flag in a c...
Should I stick with Sun's Java code conventions for PHP code?
...
I've been doing a massive code review and one pattern I notice all over the place is this:
public bool MethodName()
{
bool returnValue = false;
if (expression)
{
// do something
returnValue = MethodCall();
}
else
{
// do something else
returnValue = Expression;
}
return re...
We all know that commenting our code is an important part of coding style for making our code understandable to the next person who comes along, or even ourselves in 6 months or so.
However, sometimes a comment just doesn't cut the mustard. I'm not talking about obvious jokes or vented frustraton, I'm talking about comments that appear...