Lars Enderin said:
return can_the_CD_drive_be_opened && CD_drive_is_open;
The Java Code Conventions do not endorse such readable naming.
According to them, names should be written like
»canTheCdDriveBeOpenend«
Now, a human can not read it anymore, but still javac will
happily compile it.
I wrote a preprocessor for Java source code, so now
- in my precode - I might write this as
»'can the cd drive be opened'«
And the preprocessor will convert it to the above.
The preprocessor is written in Perl 5 and the code
actually is
while( $text =~ s{^([^"'\r\n]*(?

?:"(?:[^"\r\n]|\\")*"|'(?:[^'\r\n]|\\')*')[^"'\r\n]*)*)'([^'\\\r\n][^'\r\n]+)'}{ $1 . camel( $path, $2 ) }gem ){}
with the sub camel defined as follows.
sub camel($$)
{ my( $path, $text )= @_;
$text =~ s{^\043([a-zA-Z])}{uc($1)}ge;
{ my $sp = chr( 160 );
$text =~ s{,${sp}}{_${sp}}g;
$text =~ s{${sp}([a-zA-Z0-9_])}{uc($1)}ge; }
{ my $sp = chr( 32 );
$text =~ s{,${sp}}{_${sp}}g;
$text =~ s{${sp}([a-zA-Z0-9_])}{uc($1)}ge; }
if( $text eq 'class' ){ $text = 'class_'; }
return $text; }
This is intended to replace
»'abc def'« by »abcDef« and
»'#abc def'« or »'Abc def'« by »AbcDef« and
»'class'« by »class_« (as a special rule that might be
extended to all keywords).
It allows for ' ' to be either the normal space (32) or
the non-breaking space (160).
But it will not replace 'a' (because this is only a single
character within the single quotes) nor "...'a'..." (because
this is used in double quotes), so one can still use the
single quote as intended in Java most of the time.
I might even admit for a question mark as in
»'can the cd drive be opened?'«
which could be converted to
»canTheCdDriveBeOpenend$F3$« or so.