views:

107

answers:

2

I'm ending my first internship and my boss has shown me a few of his own programming techniques, but one bothers me some. When I write a class header, I like the corresponding source file to linearly list the functions in order that they were declared in the header file. Every time I add a function to the source file, I put it in the order it was declared in the header. Now my boss has a different approach. He organizes the header file according the data and the functions that work with the data. The corresponding source file has the functions defined in it, but he adds them to the bottom of the file in a stack like fashion. This bothers me a bit, Its most likely because of my obsession with clean and readable code, but what are some opinions on this?

+1  A: 

I use the Google C++ style guide with some personal modifications when I write my work code, I think it's a very good way to organize code.

jbernadas
Do take the Google style guide with a large pinch of salt. It's more concerned with working with a large legacy of dysfunctional C-style code, than with developing good C++ code.
Mike Seymour
Of course, buy I'm refering to the code organization and naming conventions.
jbernadas
A: 

I am with your boss. Ordering the function definitions to match the declarations will do little in the way of improving readability but will take more time to do. In general keeping two independent things consistent without automated checking is a pain.

Also there are practical considerations that may dictate the order of the functions regardless of your preference. For example, if you want the compiler to inline a function, the definition of that function generally must precede the definition of the functions that call it.

Bowie Owens