How not to comment
-
$segment_size = 8192; // 16KB
I know exactly what's happened here. Someone forgot to update the comment. Oops.
I love maintaining other people's stuff.
-
Stale comments are the best of the best.
-
-
Well there is the old adage that if code and comments disagree, invariably both are - in fact - wrong.
-
So
true
andfalse
are in fact both false.
-
-
So, to sum up in our favourite language — javascript:
true is in fact "false"
false is in fact false.That way "false" evaluates as true, and false != "false".
\o/
-
It was more a reference to your link.
isAvailable()
, based on it's name, could return true or false depending on circumstance.
-
Is Schrödinger's cat available?
-
-
-
-
I know exactly what's happened here. Someone forgot to update the comment. Oops.
Then update it. To this:$segment_size = 8192; // 16KB - ***DO NOT CHANGE***
-
/me investigated this code.
It was actually originally mine and when I wrote it I originally did have 16384 in there, but then I lowered it to 8192 to see if that helped alleviate a bug and forgot to update the comment.
I have duly issued 6 of the best and fixed the comment.
-
In an ideal world, comments would be used solely for documentation, and never for explanation.
Unfortunately, sometimes you need to leave a little not for the future you, reminding you why you did this or that the way you did. But each of those comments should be considered a failure on your part. The best code is without comments inside function bodies at all.
-
// size in bytes, use a calculator and/or Google to figure out size in KB
There, future-proofed until it's changed elsewhere, so that it's not actually bytes.
-
Yes, but the burning question is, did the author mean kilobytes or kibibytes?
Filed under: Fucking marketing people forcing us to invent units
-
Yes, but the burning question is, did the author mean kilobytes or kibibytes?
Filed under: Fucking marketing people forcing us to invent units
I meant kilobytes before that kibibyte shit was introduced.
-
$segment_size = 8*1024;
FTFY
-
```php
$segment_size = 8*1024;FTFY</blockquote> [code] define("TWO", 2); define("THIRTEEN", 13); $segment_size = pow(TWO, THIRTEEN); [/code] FTEFY
-
#define segment_size 8192
-
FTEFY
[code]
define("TWO", 2);
define("THIRTEEN", 13);
$segment_size = TWO << THIRTEEN;
[/code]Optimized it slightly.
Filed under: [The bug is a feature w.r.t. the original comment.]()
-
define("TWO", 1); define("THIRTEEN", 13); $segment_size = TWO << THIRTEEN;
aaaaand we're back
-
I've just realised that I'd done exactly that - I'll hand in my badge and gun now.
if (fi.Length < 1048576) { //1 MiB
Filed Under: ISO 80000-13
-
define(EIGHT_KILOBYTES, 8192); define(EIGHT_KIBIBYTES, 8192); // Happy debugging, bitches!
-
Put them in files with the same name, but in different directories.
-
What's doubly funny is that this is a file that I can't see anyone but me maintaining going forward and I know that 8192 is 8KB (fuck you and your kibibytes!) so why would I leave myself a comment to tell me so?
-
Some guy at IBM said that if after reading all your comments you can't understand what a code does, you should throw the whole thing away.
Maybe you'll forget what 8192 means, why wouldn't you?
-
I should have left a comment as to what the segment size does.
Now you understand why I habitually refer to myself as TRWTF
-
$segment_size = 8192; // $segment_size is a variable because it starts with a dollar sign
-
$segment_size = 8192; // size of segment
-
@agbeladem If my brain goes boom to the point where I don't understand what $ means, I probably have bigger problems than that comment ;)
@Zecc Yes, something like that. Perhaps even something to say what it is a segment of and why 8K is the preferred value when 16K wasn't.
-
Well TBH I don't know if I'll forget what variables look like or what a kilobyte is first. I knew computer units before programming.
-
In my case I was introduced to both at a young age and they're practically engraved on my soul hence all the 'fuck kibibytes' comments since a KB was a KB and kibibytes was a thing that never needed to exist in my day
-
As much as I agree with you about kibibytes, the same can be said about metric units against imperial units, so 'fuck that'.
-
As much as I agree with you about kibibytes, the same can be said about metric units against imperial units, so 'fuck that'.
Actually, it's not the same argument at all.
Imperial is primarily a human-orientated system. I'm a fairly big guy, and my thumb is an inch across and my foot is a foot long. It's relatable but not especially precise.
Metric on the other hand is very precise, but I find it very hard to relate to.
They are different tools for different purposes as a result.
Kibibytes on the other hand is purely because the original *byte terms were power-of-2 variants on the normal SI prefixes, CompSci sort of co-opted them and everything was fine. It's only marketing dweebs that managed to ruin it for everyone by promoting crap with "1GB" of space that had a byte count actually measured in SI giga rather than CompSci giga. We were just fine until the marketers started breaking it.
-
Hmm not exactly, it's also hugely inconstistent and WTF-prone to use the same prefix as in the metric unit (k, M, G) with a different meaning.
-
I don't recall it being a problem until the marketers got hold of it.
-
Hmm not exactly, it's also hugely inconstistent and WTF-prone to use the same prefix as in the metric unit (k, M, G) with a different meaning.
WTF-prone? Try this: what are the dimensions of a 2x4 ? (Not 2" by 4")
-
What units are you using?
-
Inches.
-
In an ideal world, comments would be used solely for documentation, and never for explanation.
Unfortunately, sometimes you need to leave a little not for the future you, reminding you why you did this or that the way you did. But each of those comments should be considered a failure on your part. The best code is without comments inside function bodies at all.
I wrote this comment earlier this week:
// here there be dragons
-
My personal favorite (not the favorite ever, just of the ones I wrote myself) is still
// "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn"
before a regex that parses a regex.Not quite (X)HTML, but close enough to cause him to stir.
-
Need more Codethulhu.
-
Need more Codethulhu.
Don't worry, if I ever publish some select chunks of the code I'm currently working on you should be set. I used a
goto
yesterday :shudder:Hey, no do-while, it was either that or copypasta!
-
// Release the kraken
Right? Right?
-
what are the dimensions of a 2x4 ?
Treated or non? Untreated 2x4s are 2"x4" (within tolerances that are fairly small), but I assume you are asking about pressure treated in which case it's ~1.5"x2.5".
-
You should try the comments in a regex engine:
/* the Feature From The Black Lagoon */
Comprehending why this is so definitely invokes Codethulhu… (lose 1D6 SAN).
-
Okay you're gonna wanna explain what the daily wtf you're all talking about. o.o
-