backspaces/agentscript — pull request #46 by wybo (2014-05-28 23:39:12+00:00)
Title: Tests, models, some refactoring

Hi Owen, Benny & fellow modelers,

I've added tests for all functionality in the util.coffee file, using
the Jasmine toolset. I picked Jasmine because it is based on Spec,
which is a solid, elegant way of specifying tests; and when I worked
in SF I knew people at Pivotal Labs (the company behind it), and they
were at the top of their game.

Besided I've done some cleanups in the code as well (mostly in util
so far, but in other files as well), following the general good
practices of:

- Using descriptive variable names; full words instead of single
letters or things that are ambiguous (so patch or patches instead
of p, and neighbors instead of n, etc...).

- Using consistent indentation and spacing code over multiple lines
when it furthers legibility (such as if, then else, etc.).

- Using spacing between operators (variable = (1 + some) / 3 * more,
rather than variable=(1+some)/3*more); again for legibility.

- Generic cleanup of duplicate functions, such as aMax vs minOneOf,
and functions that were basically the same (such as setXY and
moveTo). Also removed some unused ones.

- Having each file hold a single class, so Agent in agent.coffee.
Also renamed AgentSet to BreedSet, because it is also used for
patches and links.

Finally I've also added the possibility of passing a different class
to the @agentBreeds, so a model's agent can inherit from ABM.Agent
and add functionality (see my movements model at
https://github.com/wybo/movements).

I will be adding more tests, and doing some more minor cleanups in the
other files, but I hope the tests and the current cleanups can already
be merged, so the fork does not diverge too much,

Sincerely,

Wybo

PS: I've also sent this message to the google group.