August 31, 2005

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()...


Share this entry: Email it! | bookmark it! | digg it! | reddit!

Posted by Len at August 31, 2005 07:06 PM | Comments (0) | Categories : Geek Speak
Comments
Post a comment









Remember personal info?




Enter this code in the box below to prove that you're not some kind of automated spam robot...