In this case it is better because the structure of the objects in the
environment reflects a real relationship between the roles of those
objects. Which is why I would insist that - member - must be suited to
being a member or Circle. If it is not is should not be associated with
the Circle object at all, and so may be more appropriate being a global
function.
Nothing makes it better as such. A sensible system of 1000 objects
would be expected to have, and so express, hierarchical relationships.
If no such relationships existed then there is no reason for there
being a hierarchical structure in the code.
I'm starting to think your reasons are programmer preference.
That is fine if it makes the code more maintainable for you.
My reasons are mostly that I like the structures used in javascript to
properly reflect the concepts being implemented. If being a method of a
constructor expresses the real relationship between the constructor
(the objects it constructs) and its method then it should be a property
of the constructor, else it should never be.
The namespace simulation idea proposed creating deep hierarchies of
object structures with no better reason for entire level existing in
that hierarchy than that namespaces are being simulated. That does not
strike me as a good reason for creating deep object structures, and the
justification that doing so avoids naming collisions is only convincing
to people who have seen the value of namespaces in languages with
enormous library/package collections and not seen that the issues
addressed there does not apply to a know, limited set of javascript
code intended to be downloaded to a web browser in its entirety.
Without a positive reason for simulating namespaces (no consequential
benefits) the performance degradation (no matter how small) only leaves
only a reason for not simulating namespaces.
However, not simulating namespaces because you only have a reason for
not doing so is not the same as not creating properties of constructors
because that suffers the same drawback as simulating namespaces. There
may be positive reasons for creating a property of a constructor that
outweigh the slight performance degradation of the extra lookup needed
to resolve the property accessor.
However if there is a perfomance bottleneck then I would
have no problem writing Circle_member rather than
Circle.member. I don't use underscore much in
JavaScript anyway so they both look the same to me.
It would be more of a performance degradation than a bottleneck. But
the best reason for deciding between Circle.member (or some other name)
and Circle.member when assigning a function is the relationship between
that function and Circle. The decision could go either way, depending
on the code.
Richard.