I have a mysql function that takes a string as input and returns only the alphanumeric characters.
101-FFKS 99S-5
would output 101FFKS99S5
for instance.
It was called alphanum
which isn't very descriptive.
I was considering something along the lines of alphanum_filter
or punctuation_filter
.
What is the agreed convention? The thing you're filtering out, or the thing you're left with?
A few google searches didn't yield anything helpful.
I don't think there's any agreed convention in programming.
Note that there are three, not two options, as to the thing to put near "filter":
Indeed I think that in general when in English you see a word near "filter" you think that that word is what will be put into the filter.
Note that while "air filter", "water filter", "oil filter" and "fuel filter" might seem to refer to what is left after the filtering, I strongly believe that there's an implicit "unfiltered" before all of them.
However there also nouns that really include "what you're left with", such as "high-pass filter" or "red filter", and ones that include "what you're filtering out", such as "spam filter".
So it will probably be equivocal in any case.
Personally at first glance I'd think that the word would be what is being filtered out, so I'd be more comfortable with punctuation_filter
, but it's probably subjective.
So it would be better to find a less ambiguous name (although in some cases it's ok to use something ambiguous and let each programmer understand what it does by looking at it's source; what's much more important is to be consistent, you sure don't want a punctuation_filter
that filters out punctuation and a num_filter
that lets only numbers through in the same code).
An idea for a clearer name might be LeaveOnlyAlphanums
.
Yes, it's an assertion rather than a noun, but the only unambiguous noun phrases you could use are probably FilterThatLeavesOnlyAlphanums
, or ThingThatLeavesOnlyAlphanums
.
An additional idea is to use FilterOut
instead of simply Filter
. That's for sure unambiguous, although it's an assertion as well.
If you're looking for something with some sort of authority in the field of programming, I found an explicit mention that filter
is ambiguous in The Art of Readable Code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With