Hi R lovers, I'm looking for more information about, and implementations of abstract classes. After reading "Head First Design Patterns" (O'Reilly). I want to know whether I could use this to build an interface, i.e. a placeholder for all possible methods in the underlying subclasses. The final goal is to end up with a more flexible/extensible design than could be achieved with inheritance and polymorphism. I installed the 'sp' package, because I read that the Spatial Class is an abstract class, but I don't know where to look for the file where that class lives. I tried, among others, the files in: R/i486-pc-linux-gnu-library/2.9/sp/R. Cheers!! Albert-Jan ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In the face of ambiguity, refuse the temptation to guess. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [[alternative HTML version deleted]]
Albert-Jan Roskam wrote:> > Hi R lovers, > > I'm looking for more information about, and implementations of abstract > classes. After reading "Head First Design Patterns" (O'Reilly). I want to > know whether I could use this to build an interface, i.e. a placeholder > for all possible methods in the underlying subclasses. The final goal is > to end up with a more flexible/extensible design than could be achieved > with inheritance and polymorphism. > > I installed the 'sp' package, because I read that the Spatial Class is an > abstract class, but I don't know where to look for the file where that > class lives. I tried, among others, the files in: > R/i486-pc-linux-gnu-library/2.9/sp/R. > > Cheers!! > > Albert-Jan >It looks like you were looking in the R library where R stores sp after installing it- the problem with this is that R converts all the code to a binary format and stores it in a single file. You want to download the source tarball from CRAN: http://cran.r-project.org/web/packages/sp/index.html Untar it and look in the R directory of the resulting folder. You will see a file called Class-Spatial.R that contains the S4 class definition. Another good study in S4 inheritance is the Matrix package which is now included in the R core. You can download it's source from: http://cran.r-project.org/web/packages/Matrix/index.html Look at the file called AllClass.R Hope this helps! -Charlie ----- Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Abstract-classes-tp1690866p1690879.html Sent from the R help mailing list archive at Nabble.com.