N
noone
Hi.
I've got a fella working for me who is trying to convince me to change our
coding standards to using separate .h and .cc files for definitions and
implementations. I know this is a perfectly valid way of doing things but
in my mind it is kind of quirky. Here's why.
The first reason I'd resist deals with the simplicity of makefiles. When
including most code from headers where classes are protected by #ifdef
blocks the makefile doesn't have to have a separate build rule for each
class.
Next, TTBOMK you need to do your classes in header files if you are going
to make them into generic templates...well, putting them into headers
isn't strictly a requirement but the other restrictions for (templatizable
code) would encourage only using headers.
I understand that there a a couple of reasons why you might want separate
definitions and implementation, such as when a class has a static data
member, or if you intend to create a shared object library of class code,
but it seems to me that putting the code into the header files is a bit
more elegant and the other way would be more of a holdover from the old
days before templates.
I'm wondering what comments the upper echelon lurkers might have. Do they
agree with my reasoning, or can they give me reasons why I should
reevaluate my assertions.
I've got a fella working for me who is trying to convince me to change our
coding standards to using separate .h and .cc files for definitions and
implementations. I know this is a perfectly valid way of doing things but
in my mind it is kind of quirky. Here's why.
The first reason I'd resist deals with the simplicity of makefiles. When
including most code from headers where classes are protected by #ifdef
blocks the makefile doesn't have to have a separate build rule for each
class.
Next, TTBOMK you need to do your classes in header files if you are going
to make them into generic templates...well, putting them into headers
isn't strictly a requirement but the other restrictions for (templatizable
code) would encourage only using headers.
I understand that there a a couple of reasons why you might want separate
definitions and implementation, such as when a class has a static data
member, or if you intend to create a shared object library of class code,
but it seems to me that putting the code into the header files is a bit
more elegant and the other way would be more of a holdover from the old
days before templates.
I'm wondering what comments the upper echelon lurkers might have. Do they
agree with my reasoning, or can they give me reasons why I should
reevaluate my assertions.