What is the size of my log file?
-
Yusuf wrote:
(long lLength)
No reference?
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
-
I was looking under a massive code base, and came across the following code. names changes to protect the innocent.:omg:
bool CLogFile::GetLength(long lLength)
{
bool bOk = false;ASSERT (m\_bOpened); if (m\_bOpened) { try { lLength = (long)m\_cFile.GetLength(); bOk = true; } catch (CFileException\* e) { e->Delete(); } } return bOk;
}
Notice what is returned, even worst is how the exception is handled.:mad:
i don't see the problem. the name of the function is "GetLength" - and that's exactly what it does. it Gets the length, and as a bonus, it tells you if the operation succeeded. if you want to learn the length of the file, you should call the "ReturnTheFileLengthToTheCaller" function! ;)
image processing toolkits | batch image processing | blogging
-
I was looking under a massive code base, and came across the following code. names changes to protect the innocent.:omg:
bool CLogFile::GetLength(long lLength)
{
bool bOk = false;ASSERT (m\_bOpened); if (m\_bOpened) { try { lLength = (long)m\_cFile.GetLength(); bOk = true; } catch (CFileException\* e) { e->Delete(); } } return bOk;
}
Notice what is returned, even worst is how the exception is handled.:mad:
Looks OK to me, given that CFile::GetLength has no way to indicate an error other than throw an exception. OK, the
lLength
parameter should be along&
, not along
. I haven't checked View/Source to see if you actually typed the "&".Stability. What an interesting concept. -- Chris Maunder
-
i don't see the problem. the name of the function is "GetLength" - and that's exactly what it does. it Gets the length, and as a bonus, it tells you if the operation succeeded. if you want to learn the length of the file, you should call the "ReturnTheFileLengthToTheCaller" function! ;)
image processing toolkits | batch image processing | blogging
-
Looks OK to me, given that CFile::GetLength has no way to indicate an error other than throw an exception. OK, the
lLength
parameter should be along&
, not along
. I haven't checked View/Source to see if you actually typed the "&".Stability. What an interesting concept. -- Chris Maunder
-
i don't see the problem. the name of the function is "GetLength" - and that's exactly what it does. it Gets the length, and as a bonus, it tells you if the operation succeeded. if you want to learn the length of the file, you should call the "ReturnTheFileLengthToTheCaller" function! ;)
image processing toolkits | batch image processing | blogging
Chris Losinger wrote:
and as a bonus, it tells you if the operation succeeded.
I'd prefer to get the length (or -1) returned.
-
It gets the length and then what? dump it. How does the caller know what the length was? what does returning bool tell the caller? The parameter should be a reference, don't you think so?
/* I can C */ // or !C Yusuf
it was a joke
image processing toolkits | batch image processing | blogging
-
exactly. this code was written way back and I just stumpled up on it. the parameter should have been a reference to long.
/* I can C */ // or !C Yusuf
-
It gets the length and then what? dump it. How does the caller know what the length was? what does returning bool tell the caller? The parameter should be a reference, don't you think so?
/* I can C */ // or !C Yusuf
Yusuf wrote:
what does returning bool tell the caller?
It tells the caller whether
GetLength()
was successful or not.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
I was looking under a massive code base, and came across the following code. names changes to protect the innocent.:omg:
bool CLogFile::GetLength(long lLength)
{
bool bOk = false;ASSERT (m\_bOpened); if (m\_bOpened) { try { lLength = (long)m\_cFile.GetLength(); bOk = true; } catch (CFileException\* e) { e->Delete(); } } return bOk;
}
Notice what is returned, even worst is how the exception is handled.:mad:
One year ago i've discovered the following diamond: Variable names are mine because original was meaningless.
void superPupelMegaRobustMethod() { Thread watchdog = new WatchdogThread().start(); ... watchdog.stop(); } .. void run() { // watchdog loop boolean timeElapsed = false; while(true) { if (timeElapsed) () { new Thread() { .... superPupelMegaRobustMethod(); ..... }.start(); } Thread.sleep(1000); timeElapsed = true; } }