Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I just wish the variable was called "has_been_viewed_much".


Wouldn’t a view count with range filtering provide the best flexibility?


Absolutely, I was purely reacting to the "not". Every variable named not-something will lead to difficult-to-read code with double-negation like "if (!isNotSomething()) {...}".


why, though? the current version is the interesting property


There's a rule of thumb somewhere that booleans should always be named / represent something positive, so "enabled" instead of "disabled", "visible" instead of "hidden", and "has_been_viewed_much" instead of "has_not_been_viewed_much".

see e.g. https://codehealth.dev/prefer-positive-booleans/


They meant that a more ergonomic name would be "has_been_viewed_much", so you can filter by the inverse and still get the same result, but with a better name


I know what they meant, I was saying that imo the ergonomic name is has_not_been_viewed_much. it's directly expressing the property you are interested in, as opposed to expressing the negative property and comparing it to false.


How about rarely_viewed? Such expresses the property of interest, avoids the double negative issue, and is shorter?

Of course rarely might imply a frequency much lower than the cutoff and infrequently has a bit of the double negative issue. Tradeoffs.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: