1 / 6

Object Oriented Programming

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

lbooher
Télécharger la présentation

Object Oriented Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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

  2. 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.

  3. 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

  4. Accessibility of methods and variables in a class • Final • Ex: security manager • Public,private,protected,default • Absolute: public, private • Dependent on Packages: default, protected

  5. 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!

  6. 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

More Related