Lots of things become unnecessary if you factor things correctly
I’m still reading someone else’s code and it just struck me that a lot of ‘strange’ coding practices become unnecessary if you factor your code ‘correctly’. Note that both ‘strange’ and ‘correctly’ live in the Len::Personal::ViewOfTheWorld
namespace…
Take this, for example:
// show line number info, NT5.0-method (SymGetLineFromAddr64())
if (this->m_sw->pSGLFA != NULL )
{ // yes, we have SymGetLineFromAddr64()
if (this->m_sw->pSGLFA(this->m_hProcess, s.AddrPC.Offset,
&(csEntry.offsetFromLine), &Line) != FALSE)
{
csEntry.lineNumber = Line.LineNumber;
strcpy_s(csEntry.lineFileName, Line.FileName);
}
else
{
this->OnDbgHelpErr("SymGetLineFromAddr64",
GetLastError(), s.AddrPC.Offset);
}
} // yes, we have SymGetLineFromAddr64()
The comments, which can rot, would be completely unnecessary if the whole block of code was moved into a function called, say, SymGetLineFromAddr64()
…