Object Oriented Programming Prototype based vs class based OOP Prototype based OOP - cloning, virtual and copied fields and methods SELF Problems: code is not shared, too dynamic
Class based OOP Classes vs instances Only classes have code Only classes inherit Instances have state variables Variations in instances implemented as values of state variables.
Inheritance Type vs Implementation inheritance Types: roles that an object can have -> INTERFACES Organized as a DAG i.e. multiple inheritance for types is relatively trouble free. Classes: implement code – single inheritance: controls complexity adds security
Accessibility of methods and variables in a class Final Ex: security manager Public,private,protected,default Absolute: public, private Dependent on Packages: default, protected
Class vs instance (Static vs. dynamic) fields/vars and methods Class variables: shared among all instance – visible to all instances Ex: instance counter Ex: security manager – final!
Inheriting Methods Virtual methods – all java instance methods are virtual Extra (hidden) parameter: this search for an absent method or field always starts from the class associated with “this” Ex: Circle extends Point -> hide(), show(), moveTo(x,y) – virtual, uses hide() and show() as defined based on the “this” parameter