Find us on GitHub

Teaching basic lab skills
for research computing

Classes and Objects

At their simplest, classes and objects are a way to make programs more manageable by combining data with the operations allowed on that data. Object-oriented programming also allows programmers to separate interface from implementation, which in turn helps them create reusable components that can be substituted for one another. Finally, inheritance allows them to define common behaviors once, in one place, and override those definitions only when needed.

  • Objects combine functions with data to make both easier to manage.
  • A class defines the behaviors of a new kind of thing, while an object is a particular thing.
  • Classes have constructors, which describe how to create a new object of a particular kind.
  • An interface describes what something can do; an implementation describes how a particular thing performs those operations.
  • One class can inherit from another, then override just those things that it wants to change.
  1. Introduction
  2. Basics
  3. Interfaces
  4. Inheritance