[Bioc-devel] S4 overwrite inspector of virtual class
In principle, there should be no need to override a validator, since the constraints specified by the super class should not be violated. Subclasses should only add constraints. But you can abstract the constraints, e.g., make a generic for checking the chromosome ID format, and have version-specific methods for that. Moreover, it's not clear whether inheritance makes sense in this case, i.e., you are using as a tool where there is no logical inheritance relationship. You can always define separate methods for each format version class and factor the common implementation into an underlying function. Michael
On Mon, Aug 15, 2016 at 9:56 AM, Zach Skidmore <zskidmor at wustl.edu> wrote:
maybe validator is the proper term in R? i've highlighted what I refer to as the inspector below as an example:
setClass("file",
contains="file_virtual",
validity=function(object){
# Check that object is as expected
}
)
On 8/15/16 11:46 AM, Gabe Becker wrote:
Zach,
Is an inspector a method you define on your classes? I'm not quite
following what you mean by your question. AFAIK inspectors are not
generally a thing in R (at least that go by that name).
~G
On Mon, Aug 15, 2016 at 9:42 AM, Zach Skidmore <zskidmor at wustl.edu><mailto:zskidmor at wustl.edu> wrote:
Hi All,
I'm currently transforming the GenVisR package into an Object Oriented
system. Currently I have a virtual class and several child-classes. I am
wondering if there is a way to tell R to use the inspector of the virtual
class only if the inspector of a child class in not defined.
For example say I had a class to store versions of a file-type and I have
a slot in the class to store the position. Between different versions of
the file-type there may be small differences (for example Chromosome may be
capitalized in version 2,3,4 but not version 1). Ideally the child classes
for 2,3,4 would be able to inherit the inspector from the virtual class to
check the chromosome name and I would define a separate inspector for
version 1 which is different.
Any thoughts? Currently both inspectors are called (virtual and the
appropriate sub-class), meaning if i added more versions in the future I
would have to re-write the virtual and child class. Whereas if I could say
ignore the virtual (i.e. default) inspector if another is defined I would
only have to write the child class inspector in the future.
Hopefully this makes sense, let me know if it doesn't or if i'm violating
a core OO principle, i'm relatively new to object oriented programming.
Thanks, Zach!
________________________________
The materials in this message are private and may contain Protected
Healthcare Information or other information of a sensitive nature. If you
are not the intended recipient, be advised that any unauthorized use,
disclosure, copying or the taking of any action in reliance on the contents
of this information is strictly prohibited. If you have received this email
in error, please immediately notify the sender via telephone or return mail.
[[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
________________________________
The materials in this message are private and may contain Protected Healthcare Information or other information of a sensitive nature. If you are not the intended recipient, be advised that any unauthorized use, disclosure, copying or the taking of any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error, please immediately notify the sender via telephone or return mail.
[[alternative HTML version deleted]]
_______________________________________________
Bioc-devel at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/bioc-devel