[Bioc-devel] metadata() in BiocGenerics?

Hervé Pagès hpages at fhcrc.org
Wed Apr 23 00:08:38 CEST 2014


Hi Vince,

On 04/17/2014 04:19 AM, Vincent Carey wrote:
>
>
>
> On Thu, Apr 17, 2014 at 2:37 AM, Hervé Pagès <hpages at fhcrc.org
> <mailto:hpages at fhcrc.org>> wrote:
>
>     Hi Vince,
>
>
>     On 04/10/2014 08:16 AM, Vincent Carey wrote:
>
>         seems like something we should use more routinely, and it was not
>         straightforward for me to find it in IRanges
>
>
>     I could do that but...
>
>     Good object design would be that if a developer wants its class to
>     support the metadata() getter and setter, s/he should extend the
>     Annotated class defined in IRanges. This class has only 1 slot, the
>     metadata slot, and a very simple API: just metadata(). So by extending
>     it, metadata() will work out-of-the-box on his/her objects. This avoids
>     code duplication and ensures that the metadata() getter and setter
>     behave consistently on all objects.
>
>     I can see that a developer could be reluctant to depend on IRanges just
>     to inherit the Annotated class though. But maybe this means that the
>     Annotated class and the metadata() generic are in the wrong package?
>
>
>   thanks for the comment; i can deal with the situation as is.

An update on this: the Annotated class and metadata() accessor are now
in S4Vectors. Note that, as Michael pointed out, the Annotated class
is only an implementation for metadata(). It's really straightforward
(and very convenient) to have your class extend it. However if, for
whatever reason, you cannot or don't want to do this, you still need
to depend on S4Vectors to get the metadata() generic getter and setter,
which is not as light as BiocGenerics but is lower-level and lighter
than IRanges. The hope is that developers will be less reluctant to
depend on S4Vectors than on IRanges.

Cheers,
H.

>
>     Cheers,
>     H.
>
>
>                  [[alternative HTML version deleted]]
>
>         _________________________________________________
>         Bioc-devel at r-project.org <mailto:Bioc-devel at r-project.org>
>         mailing list
>         https://stat.ethz.ch/mailman/__listinfo/bioc-devel
>         <https://stat.ethz.ch/mailman/listinfo/bioc-devel>
>
>
>     --
>     Hervé Pagès
>
>     Program in Computational Biology
>     Division of Public Health Sciences
>     Fred Hutchinson Cancer Research Center
>     1100 Fairview Ave. N, M1-B514
>     P.O. Box 19024
>     Seattle, WA 98109-1024
>
>     E-mail: hpages at fhcrc.org <mailto:hpages at fhcrc.org>
>     Phone: (206) 667-5791 <tel:%28206%29%20667-5791>
>     Fax: (206) 667-1319 <tel:%28206%29%20667-1319>
>
>

-- 
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpages at fhcrc.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319



More information about the Bioc-devel mailing list