From sfalcon at fhcrc.org  Tue Sep 26 06:53:13 2006
From: sfalcon at fhcrc.org (Seth Falcon)
Date: Mon, 25 Sep 2006 21:53:13 -0700
Subject: [Rd] S4 accessors
In-Reply-To: <1159230049.7161.132.camel@iron.psg.net> (Ross Boylan's message
	of "Tue, 26 Sep 2006 00:20:49 +0000")
References: <1159230049.7161.132.camel@iron.psg.net>
Message-ID: <m2k63r2pqe.fsf@ziti.local>

Ross Boylan <ross at biostat.ucsf.edu> writes:
> The code has a couple of decisions for which I could imagine
> alternatives.  First, even simple get/set operations on class elements
> are wrapped in functions.  I suppose I could just use myinstance at slot to
> do some of these operations, though that is considered bad style in more
> traditional OO contexts.

I like the get/set approach as opposed to using '@'.  As long as users
don't use '@' you have a fair amount of flexibility to
redesign/refactor your code.

> Second, even though the functions are tied to the class, I've defined
> them as free functions rather than methods.  I suppose I could create a
> generic that would reject most arguments, and then make methods
> appropriately.

If anyone else is going to extend your classes, then you are doing
them a disservice by not making these proper methods.  It means that
you can control what happens when they are called on a subclass.  

> For the documentation, I've created a single page that groups many of
> the functions together.  This is a bit awkward, since the return values
> are necessarily the same.  Things are worse for replacement functions;
> as I understand it, they must use "value" for their final argument, but
> the value has different meanings and types in different contexts.
>
> Any suggestions or comments?

For accessors, I like to document them in the methods section of the
class documentation.

+ seth

--
Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center
http://bioconductor.org




[Rd] S4 accessors
Seth Falcon