© Thomas Mailund 2017

Thomas Mailund, Advanced Object-Oriented Programming in R, 10.1007/978-1-4842-2919-4_6

6. S4 Classes

Thomas Mailund

(1)Aarhus N, Denmark

The S3 class system is the wild west of object-oriented programming. Class hierarchies only exist implicitly through the class attributes, and generic methods can be implemented or not by any class whatsoever, with no check that interfaces and class hierarchy designs are implemented correctly. Everything depends on conventions and it is entirely up to the programmer to ensure anything resembling consistency.

The S3 system is popular because it is very easy to use and to write new classes. In most cases, we would prefer simplicity over elaborate design, and in those cases, S3 is perfect for ...

Get Advanced Object-Oriented Programming in R: Statistical Programming for Data Science, Analysis and Finance now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.