Skip to content
Prev 7713 / 21312 Next

[Bioc-devel] RangedSummarizedExperiment

Elena,
On 06/18/2015 10:48 AM, Elena Grassi wrote:
It requires some discipline but the S4 class system actually allows one
developer to extend a class owned by another developer in a way that
remains agnostic of the internals of the parent class. This is possible
thanks to the following features (let's say B extends A):

   (1) The developer of B only needs to specify B-specific slots in
       setClass("B", ...)

   (2) The developer of B can do:

         a <- A(...)  # high-level user-friendly A constructor
         new("B", a, Bslot1=stuff1, Bslot2=stuff2, etc)

       to create B objects (e.g. when implementing the high-level
       user-friendly B constructor).

   (3) The validity method for B only needs to take care of what's
       new in B with respect to A, that is, of the aspects of B
       objects that are not already covered by the validity method
       for A objects. This is because calling validObject() on a B
       object automatically validates B as an A object and then calls
       the validity method for B to validate what's new in B.
       In other words, validation works incrementally starting from
       the root of the class hierarchy and going in the parent-to-child
       direction.

   (4) Like any user of A objects, the developer of B should always
       use the accessors provided by the developer of A to access A
       objects and the A-specific components of his/her own B objects.

Proper use of these features by developer of B leads to a clean design
where the implementation of B is not affected by changes in the
internals of A.

I was actually pleased to find out that after the recent changes in
the internals of RangedSummarizedExperiment, most of the packages
that extend this class kept working as if nothing happened. Most
failures are actually due to serialized RangedSummarizedExperiment
or derived objects that need to be updated and re-serialized
(unfortunately, changes in the internal representation of class A
always break serialized A and B objects, no matter what).

Cheers,
H.