OOP: Properties
Objects have class
- Class defines:
- Method (i.e., what can be done with object)
- Fields (i.e., data that defines an instance of the class)
- Objects are an instance of a class
Class is inherited
- Class is defined:
- By an object’s class (e.g., ordered factor)
- By the parent of the object’s class (e.g., factor)
- Inheritance matters for method dispatch
- If a method is defined for an object’s class, use that method
- If an object doesn’t have a method, use the method of the parent class
- The process of finding a method, is called dispatch