12.5 OOP in base R

  • S3
    • Paradigm: functional OOP
    • Noteworthy: R’s first OOP system
    • Use case: low-cost solution for common problems
    • Downsides: no guarantees
  • S4
    • Paradigm: functional OOP
    • Noteworthy: rewrite of S3, used by Bioconductor
    • Use case: “more guarantees and greater encapsulation” than S3
    • Downsides: higher setup cost than S3
  • RC
    • Paradigm: encapsulated OOP
    • Noteworthy: special type of S4 object is mutable–in other words, that can be modified in place (instead of R’s usual copy-on-modify behavior)
    • Use cases: problems that are hard to tackle with functional OOP (in S3 and S4)
    • Downsides: harder to reason about (because of modify-in-place logic)