Welcome to Shaun Luttin's public notebook. It contains rough, practical notes. The guiding idea is that, despite what marketing tells us, there are no experts at anything. Sharing our half-baked ideas helps everyone. We're all just muddling thru. Find out more about our work at bigfont.ca.

Object-oriented basics: inheritance, polymorphism, encapsulation, and abstraction

Tags: computer-programming, computer-science, object-oriented, basics, fundamentals, design-patterns


  • prototypal inheritance allows an object
  • to base itself on another object
  • class-based inheritance allows a class
  • to base itself on another class
  • both allow the child to access
  • the parent's capabilities
  • note: inheritance != subtyping
  • though often inheritance agrees with subtyping


  • allows a routine (function, method, constructor...)
  • to use variables of different types
  • at different times
  • there are three kinds of polymorphism
    • ad hoc polymorphism
    • parameteric polymorphism
    • subtype polymorphism


  • allows an object (or a closure)
  • to restrict outside access
  • to some of its components
  • and to bundle data with the routines
  • that operate on that data

Abstraction (in an OO context)

  • allows us to define objects which can...
  • perform work,
  • report on and change their state, and
  • communicate with other objects

Abstraction enables encapsulation, polymorphism, and inheritance.