Review of Object Orientation
Review of Object Orientation
Chapter 2:
Review of Object Orientation
What is Object Orientation?
•Procedural paradigm: pa·ruh·dime
– Software is organized around the notion of procedures
– Procedural abstraction
• Works as long as the data is simple
See in Umple
– Has properties
• Represent its state
– Has behaviour
• How it acts and reacts
• May simulate the behaviour of an object in the real world
– Attributes
• Simple data
• E.g. name, dateOfBirth
– Associations
• Relationships to other important classes
• E.g. supervisor, coursesTaken
• More on these in Chapter 5
•Type of a variable
– Determines what classes of objects it may contain
•Operation
– A higher-level procedural abstraction that specifies
a type of behaviour
•Method
– A procedural abstraction used to implement the
behaviour of a class
•Inheritance hierarchies
– Show the relationships among superclasses and
subclasses
– A triangle shows a generalization
•Inheritance
– The implicit possession by all subclasses of features
defined in its superclasses
See in Umple
•Inheritance
– The implicit possession by all subclasses of
features defined in its superclasses
Chapter 2: Review of Object Orientation 19
The Isa Rule
•Always check generalizations to ensure they
obey the isa rule
– “A checking account is an account”
– “A village is a municipality”
– For extension
• E.g. SavingsAccount might charge an extra fee following every
debit
– For optimization
• E.g. The getPerimeterLength method in Circle is much simpler
than the one in Ellipse
– For restriction (best to avoid)
• E.g. scale(x,y) would not work in Circle
References:
1. http://docs.oracle.com/javase/tutorial/index.html
2. http://www.java2s.com/
3. http://www.tutorialspoint.com/java/
4. http://www.javacodegeeks.com/2013/01/15-online-
learning-websites-that-you-should-check-out.html
•ArrayList is the most widely used class to hold a collection of other objects
– More powerful than arrays, but less efficient