2

In the spirit of LiveCode's move towards open source, I have been working on writing some library stacks that would be very useful to the community. I have written libraries on game scoring systems, health metrics, credit card processing, and web-API endpoint access.

Before I release these libraries to the community, I wanted to try an follow some existing best practices to make the code more readable.

Here are some standards I am using for variable naming:

tVar - temp variable (functions, handlers)
gVar - global
uVar - custom prop
pVar - parameters in function or handler declerations

Are there similar best practices for handler or function naming? General advice on best practices for live code libraries is also appreciated.

Cœur
  • 37,241
  • 25
  • 195
  • 267
R Ghosh
  • 612
  • 1
  • 4
  • 9
  • Your second question, general advice, is too general and should be removed, because it doesn't belong on Stackoverflow, but if you change your question and be more specific, I'd be happy to try to answer. – Mark May 25 '13 at 09:11
  • Your library stacks will be very welcome! To use as is and as code examples. – z-- May 27 '13 at 04:59

3 Answers3

2

You might want to look at Richard Gaskin's canonical work on this:

Scripting Style Guide

mwieder
  • 231
  • 2
  • 6
1

If you create a library or external for distribution, you might want to use a code to start your function names with. I use "ext", which stands for 'E'conomy-'x'-'T'alk. Monte Goulding uses 'merg' (his initials). RunRev uses "rev", the first three letters of "Revolution".

Mark
  • 2,380
  • 11
  • 29
  • 49
1

The global variables should as well have a prefix referring to your library. And of course there should be as few as possible. For the custom properties I would say it depends on the type of objects they are used for.

z--
  • 2,186
  • 17
  • 33
  • 1
    I would try to avoid global variables. I'd rather use local variables, which can be returned by functions, and custom properties. – Mark May 27 '13 at 13:14