21 March 2014

Use unicode for better names

Let's say in a java application we have a few tabs and sometimes we hide some of them. So now we want to document a new requirement and of course we do it as a test:
public void should_hide_more_tab_when_no_additional_information_is_available() {
but wait... what does it exactly mean? Should our application hide more tabs then it usually does? Or is there a tab named 'more' that should be hidden? How can we clarify this? After a quick look at the unicode char table, we pick the ʻ char (or any other that makes you happy). It's a '02BB turned comma' and more information can be found for example here. There is a table with detailed information about that character and the interesting part is:
Character.isJavaIdentifierPart()  Yes
Cool! So let's write:
public void should_hide_ʻmoreʻ_tab_when_no_additional_information_is_available() {
Is this test more readable now?

For example in racket (a dialect of lisp) you can define lambdas using λ:
(λ(x) (+ x 1))

0 komentarze :

Post a Comment