From sfalcon at fhcrc.org  Sun Apr 24 19:50:29 2005
From: sfalcon at fhcrc.org (Seth Falcon)
Date: Sun Apr 24 19:51:18 2005
Subject: [Rd] Objects in R
In-Reply-To: <426B42B4.3090306@stats.uwo.ca> (Duncan Murdoch's message of
	"Sun, 24 Apr 2005 07:54:44 +0100")
References: <20050421163730.20887.qmail@web30213.mail.mud.yahoo.com>
	<14d2d99f8f37278ebc8961c773758c27@stat.harvard.edu>
	<426B42B4.3090306@stats.uwo.ca>
Message-ID: <m27jisvzbu.fsf@macaroni.local>

Duncan Murdoch <murdoch@stats.uwo.ca> writes:
> What S4 is missing is "encapsulation". Wikipedia's article on 
> object-oriented programming gives a good definition:
>
> "Encapsulation - Ensures that users of an object cannot change the 
> internal state of the object in unexpected ways; only the object's own 
> internal methods are allowed to access its state. Each object exposes an 
> interface that specifies how other objects may interact with it."
>
> Neither of these properties holds in S4.

I don't like the definition of encapsulation in the Wikipedia.  If
nothing else, I think the second part about objects exposing an
interface specifying how to interact with them should come first ---
and S4 provides that.

In my experience, the ability to create "obvious" interfaces to
classes is the important part of encapsulation.  Python's object
system, for example, does not (easily) provide protections against
abuse, but other than some initial misgivings, I've not missed it.

+ seth


[Rd] Objects in R
Seth Falcon