On 27.12.2010 14:01, Jose Antonio Perez wrote:
We can classify _without_ the `class` keyword. And as I
mentioned, languages which are considered as class-based (Python,
CoffeeScript), in real, are the same delegation/prototype-based as
JavaScript and the `class` keyword is just a _syntactic sugar_.
All this is true in a world in which all properties have the same
level of accessibility, and consequently, the coupling between
instances and pseudo-methods may be weak, and simply run at the
syntactic level.
But when we leave that simple and symmetric world and enter in a new
world where we want to classify the properties of an object according
to its visibility, the coupling can't be weak and appears
necessarily the concept of authentic method . The coupling becomes
strong and must be described with more than a little "syntactic sugar
cube".
Please elaborate on this (it's interesting).
Visibility relates to a simple desire not to mess with (and not to
depend on) internal _implementation details_. This concept (an
_encapsulation_) brings the main concept of an abstraction: _abstraction
layers_ are stratified with _abstraction barriers_. In every abstraction
there is a level of _implementation_ and the level of _usage_ of this
abstraction. Thus, the later shouldn't/needn't know anything about the
first one. I.e. a communication with an object should be done via a set
of rules, which is called a _public interface_. If the second layer will
follow these rules, the first level (the level of implementation) may
easily change the internal helper state of an object still keeping the
public interface the same.
And how these internal state is implemented -- is already a derived
question. It can be a simple agreement that internal properties have a
special naming (for example, _data, or @data, or whatever you want --
just to separate them from the public stuff) or it can be a special
modifiers, e.g. `private`, etc.
Thus, again, if the layer of usage isn't dependent on these internal
`_names`, it won't have problems when the internal state will be changed
in the future.
Having all this, an ability to classify still can be achieved via the
"syntactic sugar cube". However, yes, I agree that more complex (and
strong) rules are required to create strong-encapsulated properties.
What exactly do you mean by "authentic method"?
Dmitry.
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]