Campbell Ritchie wrote:But calling your String Regex tells the unwary reader two things
It contains a regular expression
It is the name of a class
And both are incorrect.
To expand on Campbell's point...
Traditionally, in Java, class names start with a capital letter, and variable start with a lower-case letter. Many people seeing "Regex" (note the capital 'R') would think this was a class name.
Second, the word 'regex' is a commonly used term for a 'regular expression'. If i was reading your code and saw a variable named that, I would expect it to contain a regular expression. If I saw it was an array of strings, I'd expect each element to contain a regular expression.
Your array contains the tokens after splitting up a string based on a single character. You don't even use a regex anywhere that I see.
A better name for the variable would be something like "tokens" or "myTokens" or something along those lines. The variable should be named for what it CONTAINS, not how you got the data you stick in it.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Joined: Oct 13, 2005
Maybe you were following the naming conventions in this article, which you should read when you have enough time