lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Dec 27, 2010 at 10:04 PM, Alexander Gladysh <agladysh@gmail.com> wrote:
> Note that we do not use Hungarian notation, mentioned by David, here,
> we use type validation instead where it is important:
> https://github.com/lua-aplicado/lua-aplicado/blob/master/lua-aplicado/filesystem.lua#L63-65

I think you do use some apps Hungarian notation.  For example, your
file names are typically postfixed by "filename" like this:

  local update_file = function(out_filename, new_data, force)
    arguments("string", out_filename, .....)
    .....

It's true that you do type check at runtime that the file names are
strings, but you do not explicitly have runtime checks nor code
comments indicating that the strings semantically encode a file name.
That semantic information is rather encoded in the variable name (as
well as the functions it is passed to--e.g. anything passed as the
first argument to io.open should be a file name).

Not using apps Hungarian notation would be like renaming this
"out_filename" variable to something less informative like "name",
"output" or (yes) "output_string".

In some of my code, I have the static analyzer (e.g. LuaInspect)
utilize the semantic information in the variable names.  For example,
`out_filename == ''` could conceivably be flagged with a warning since
'' is not a valid file name, causing the condition to always evaluate
to false.

[1] http://en.wikipedia.org/wiki/Hungarian_notation