Skip to content
Prev 1754 / 21312 Next

[Bioc-devel] implementing interfaces

Thanks all for the comments. I somehow never happened on  
showMethods(class="AffyBatch"). Comments below.
On Nov 25, 2008, at 1:08 PM, Robert Gentleman wrote:

            
Nothing is special about the set of generic functions that have  
AffyBatch methods except that the bg.correct.mas is defined to take an  
AffyBatch object and if I want to call this function I have to  
subclass AffyBatch or construct an AffyBatch. I don't have a CDF file,  
but I do have a notion of PM/MM probes. The real issue is that methods  
which are defined on classes are often unusable when you can't  
construct the object. The ideal way to do this would be (in my opinion)

setMethod("indexProbes", signature(object = "AffyInterface", which =  
"character"), function(object, which, ...) {
	stop("No suitable method defined.")
})

setMethod("bg.correct.mas", signature(object = "AffyInterface"),  
function(object, ...) {
	# current defintion goes through. 	
})

Where AffyInterface is a virtual class (also no member variables) but  
has a set of methods associated with it. This is a much more  
"developer" friendly way to do it because then I don't have to concern  
myself with the internals of AffyBatch, just the interface that I need  
to implement to call a particular generic that I am interested in. I  
then would subclass the AffyInterface class which would impose no  
stricture on how I represent my class members, it would only (although  
not explicitly) proclaim that I implement the set of methods in  
AffyInterface.
I agree that I basically need a class which is isometric to AffyBatch  
and that is what I believe the problem to be. I cannot get at some  
functionality because in a practical sense the generics have been tied  
to a class. There is only one way to use the functionality of  
bg.correct.mas and that is be an AffyBatch. I think that this is fine  
when it is strictly necessary or when you are designing end-user code,  
but if you want programmers to build on top of things then it is  
limiting.

So I know that affy is not part of Biobase and I can solve the problem  
without too much trouble in a number of ways and that the primary goal  
of the package is for the end user, but I guess I am advocating for a  
design by interface approach so that particular choice of  
representation is left to the programmer. Thanks for the feedback and  
please understand that I appreciate all of the hardwork even though i  
am complaining a bit.


jim