[erlang-questions] A style question

Masklinn <>
Mon Feb 15 12:34:15 CET 2010


On 15 Feb 2010, at 12:05 , Joe Armstrong wrote:
> 
> I hate long variable name because they clutter up the code.
> So I use "abbreviated camel variables + comments"
> 
>  %% UTF = UpdateTheFebblerokker
>   UTF = fun() -> ...
>   Mnesia:transaction(UTF)
> 
>  "UpdateTheFebblerokker" has 21 characters. So the first version uses
> 2*21 (42) characters to communicate the
> name.
> 
>  The second version uses 21 + 3 * 3 (30) characters to communicate the name.
>  So my version is 12/42 (29%) more abstract).
> 
> The amount of work my brain has to do to understand this is 29% less.
> If you reused the name
> twice then the gain would be 3*21 :: 21 + 4*3 = 63::33 (48% more abstract)

Except in that case my brain would very likely understand the wrong thing. What "UTF" tells me is "Unicode Transformation Format", not "UpdateTheFeeblerokker". And I'd be left wondering what the hell the lambda has to do with unicode.

Yeah unreadable names don't matter when you already know what they mean. In fact you should use the first 3 hex characters of the sha1 of the corresponding source code, it would be almost as unclear and wouldn't even require the effort of looking for 3 meaningless characters.

C7D? Perfectly cromulent variable name, and just as abstract as your version.


More information about the erlang-questions mailing list