05.0 Java Notes‎ > ‎

Java: OOPs

Adapted with permission from Arnold Rosenbloom, University of Toronto
*added by MisterV

Object Oriented Programming Language: 

A programming language which allows the modelling of object interaction
  • Java is an OO programming language.
  • Typically an OO programming language supports:
    • Encapsulation (via the notion of class)
    • Inheritence: method for extending existing classes by adding methods and fields
    • Polymorphism: Behaviour varies depending on the actual type of an object
  • OO Programming Languages encourage code reuse, capturing of concepts

Programming the OO way...

  1. Problem solve: Understand a given problem (there is a LOT to this!!) Determine if a solution takes the form of a computer program (and if so)...
  2. Create Conceptual Solution: Describe the system to be modelled. That is, give an english description of the system
  3. Concepts mapped to OO Paradigm:
    • Think OO:  Analyze the problem/solution, view it as a collection of interacting objects, then identify the 
      • classes/objects: These are the concepts that need to be captured. Sometimes noun or noun phrases in the above description.
      • methods (RESPONDS-TO): for each class. These are the things that the class can do. Verbs usually identify these in the problem description.
      • attributes (HAS-A): for each class. These are things that each instance has, they define the state of the instance.
      • inheritence (IS-A): classes that this class extends
    • Think Algorithmically:  Write algorithms for each of the methods

  4. Java: Translate the above to something the computer can understand (Java) 

More about Java:

  • a=b calculated by computing the VALUE of the right side and placing it in the left 
  • Methods in Java pass parameters by VALUE
  • Java occasionally garbage collects instances that have no references to them.



Comments