coding-convention

How many lines of code is too many?

One thing that occasionally drives me crazy is reading another person's functions that span 5 vertical monitor lengths, or .cpp files that are over 2000 lines long. For readability, wouldn't it be better to break a 1000 line function into many smaller sub-functions called by one function? Shouldn't a class implementation not span an in...

C++ IDE that supports Scott Meyer's advice: Prefer non-member non-friend functions over members

Scott Meyer's argument that non-member functions increase encapsulation and allow for more elegant design (designwise) seems very valid to me. See here: Article Yet I have problems with this. (And seemingly others too, especially Library developers, who usually completely ignore this) Code usually looks better and more logical when I u...

Testing of coding and naming conventions of C/C++ code

I'm looking for a script/tool that can be customized to check and enforce coding/naming conventions on a C/C++ code. It should check for example: Code lines are wrapped at some length. Private variables have prefix _ Code is indented properly. All functions are documented. Many of the projects I'm working on are outsourced by custo...

Need for prefixing a function with (void)...

Hi All, I recently came across a rather unusual coding convention wherein the call for a function returning "void" is prefixed with (void). e.g. (void) MyFunction(); Is it any different from the function call like: MyFunction(); Has it got any advantage or is it yet another needless but there coding convention of some...

How wide should VB code get?

In times past, most people coded on a terminal that was 80 characters wide. In many languages this has become, if not holy then close to it. But now many people have 20"+ monitors (or dual monitors), so screen real estate isn't as prime as it once was. So my question is this: in Visual Basic code, should code be limited to 80 character...

jQuery Coding Conventions

I've been looking for some jQuery coding conventions, but really found a comprehensive list. For example, how should I name the id of my html tags, I like the first one because it confoms to my css convention, but would it give me inconvenience in some senarios? <div id="comment-list"></div> <div id="commentList"></div> <div id="Commen...

Java Coding Conventions: Getters & Setters

Why is it convention to place getters and setters after constructors within classes? I would rather see them placed immediately after class fields, before the constructors, in order to see which of the private fields are accessible via getter & setter methods. Especially if the methods' bodies are single return or assignment statements...

For locale-sensitive functions, is it more common to pass the std::locale or the needed facet object(s)?

Recently I wrote a family of functions for trimming leading and trailing whitespace off of an input string. As the concept of "whitespace" is locale-dependent, I realized that I would need to either pass in a const std::ctype<char_t> reference or a const std::locale reference and call std::use_facet<std::ctype<char_t> > on the const std:...