Day home Documentation
Day development details

Conventions

These have evolved over many years the two key ones are initial capitalisation of functions/methods and function arguments. As most other identifiers are initially lowercase it makes them stand-out.

Naming conventions

Function namesInitially Capital, camel case. eg. SomeFunction
Function argumentsInitially Capital, camel case. eg. ArgumentOne
Local variablesInitially lower-case, camel case. eg. aLocalVar
Class namesAll uppercase. eg. ACTIONS
ConstantsUppercase with two parts split by underscore. eg. BOOL_ONE
So for example if you were to see foo = BAR.Buz(Fox); you'd know foo was local, Buz was a class-method (not a class variable) and that Fox had come from the surounding function call. If you saw if(bar.buz == FOO_FOX) you'd know that bar was a local instance of a class (ie an object) with buz being a value (not a method) and that FOO_FOX is a constant.

I often use a variable rv to build a return value with a final return rv; at the end.

When passing arguments to a .map() or .forEach() etc. I name the variables V,I,A as in myArray.forEach(function(V,I){number+=V*I;});

Leading underscores

You will see quite a few methods with a leading underscore such as ._FooMeInPrivate() this is a hint to programmers that this is really an internal method, and what it might perform will either be surfaced in a more practical routine, or of a rather specialist nature. For example DAYo.To32Bits() is a method you'd call on a DAYo quite normally, but DAYo._Read32Bits() is a helper method for the DAYo constructor. There's nothing stopping you using these methods, they're properly documented, but stop and have a think first.

Coding conventions

Development environment

This is a collection of javascript source files, test files, documents, distributables and tools. The documentation should be enough for a unzip of the core to be runnable, but the automation relies on node and gulp which will probably need installing etc.

What goes where

Source code documentor

See Coding conventions above. This is a PHP program called genAPI.php. It's heritage goes back to 2003 but it works. An obvious wet-afternoon project is rewriting from scratch in js/node.

gulp task-runner

gulp runs in the background (using node.js) to watch for changes to sources or tests. When it spots such a change it 'compiles' everything. That's about it. Look at gulpfile.js for what the current actual and anticipated scope of automated building is. Typically you'd start gulp in its own terminal window.
$ cd /Servers/htdocs/test/2013/js/day/tools/node cd /Servers/htdocs/test/2013/js/day/tools/node $ gulp
This process doesn't normally terminate as it's always watching. Ctrl-z works to kill it in Linux. Don't ask me technical gulp or node questions as I'm very much a poke-n-hope then leave alone with getting them working.

node bulk testing

All the test scripts can be run on the server (rather than in-browser) using node. This is ideal for regression testing and only takes a couple of seconds.
$ cd /Servers/htdocs/test/2013/js/day/tools/node cd /Servers/htdocs/test/2013/js/day/tools/node $ node dt.js
You can add the name of a script file on the command line and optionally from and to lines.
The console gives a quick indication of progress, but unless you're doing console.log(...) it's just a progress log. The place to look at the results is tests/results/index.htm