I realize that this is largely up to personal preference, but I'm curious whether there are some clear drawbacks to the following;
I find myself constantly dividing source code into logical groups (via "comments") within the same file. For example:
//----------------------------------------------------------------------------
#include "..."
//----------------------------------------------------------------------------
#include <...>
//----------------------------------------------------------------------------
#include <boost/...>
//----------------------------------------------------------------------------
#include <os-specific/...>
//----------------------------------------------------------------------------
namespace
{
void Foo()
{
}
}
//----------------------------------------------------------------------------
namespace
{
void Bar()
{
}
}
//----------------------------------------------------------------------------
namespace
{
void Baz()
{
}
}
//----------------------------------------------------------------------------
int main()
{
}
//----------------------------------------------------------------------------
//This file ends with a new-line.
Or:
//----------------------------------------------------------------------------
#ifndef FOO_HEADER_INCLUDED
#define FOO_HEADER_INCLUDED
//----------------------------------------------------------------------------
#include "..."
//----------------------------------------------------------------------------
namespace Foo
{
void Bar();
}
//----------------------------------------------------------------------------
#endif
//----------------------------------------------------------------------------
//This file ends with a new-line.
I've been reading through some alien source lately and I've noticed that virtually no one does this.
The only argument that I could come up with against this sort of "division" is when you physically print source code in portrait-mode where your divisors (if longer than ~80 characters) will get line-wrapped. This is a non-issue in landscape-mode, though.
To be honest, I don't even know why or when I started doing this. Are there any other cons to this OCD of mine?
In addition, for me, this sort of behavior is language agnostic; I was writing a shell script the other day and noticed the exact same behavior pattern.