[Pmwiki-users] Re: Variable names

Robert P. J. Day rpjday
Mon Oct 18 10:51:17 CDT 2004


On Mon, 18 Oct 2004, Patrick R. Michaud wrote:

> If I were talking about someone's "address", my variables names
> would be $Street and $Number, not $Street and $Address (which would
> be confusing because the street is part of the address). To follow
> this analogy properly, since we're talking about "pages" the
> variable names should be $Group and $Name, and not $Group and $Page.

just to beat this to death, this is the sort of thing that is
addressed in a really cool book, "the pragmatic programmer", by andy
hunt and dave thomas (and i really do think it's a great book, even if
andy is a friend of mine :-).

he talks about a couple principles of coding: the evils of
duplication, and orthogonality, which both seem to apply here.

one of his cardinal rules is that "every piece of knowledge must have
a single, unambiguous, authoritative representation within a system."

now, say you have the two variables, Group and Page, but Page was in
fact the *fully-qualified* page name which included the group name.
in that case, you'd have the group name being stored in two different
places, which violates the above rule.

is that really that big a deal?  it depends on whether, at some point,
you end up with the value in the Group variable, and the group part of
the Page variable *differing*.  of course, that should never happen,
but some glitch in the programming might cause it, and then all sorts
of awful things might happen as two fundamental variables disagree on
a critical piece of information.

anyway, i'll get back to work now.

rday




More information about the pmwiki-users mailing list