|
Domain |
Components |
Remarks |
|
Object |
- Programming capsule, smallest unit of OOP
- Syntax: (class name) name;
- name = new method(…);
|
Reusable
Modular
Structured
|
|
Object-Oriented Programming |
- Based fundamentally on objects as building blocks for entire software
|
Develop by creation, manipulation & interactions of objects
|
|
Class |
- A class in OOP is a container of data & functions
- Data: field variables
- Functions: methods
|
Structure & modularity by encapsulating field variables & methods within class(es)
|
|
Types of class |
- 3 types: public, private & protected
- Public: available for use to all classes
- Private: used only within class
- Protected: secure
- 2 forms: superclass & subclass
- Superclass: parent class, the basis, abstraction
- Subclass: child class, inherits & adds new data &/or methods
|
- Within a class:
- Import:
- java.applet.Applet
- java.awt.*
- Within an application:
- Main() method
|
|
Variables |
- Used for representation of different types, lengths & uses of data
|
Common: int, real, double, boolean, char
|
|
Methods |
- Functions for processing available field variables
- Header syntax:
- (return type) name (arguments) {.. }
|
A class can have many variables & methods
Name of class may or may not be same as name of method
|
|
Constructor |
- A type of method with 1) same name as its class, 2) no return (void)
- Used for initializing object instances (method=class) & overlapping functions
|
If >1 constructors, termed overloading
The class & constructors must differ in the 1) number of arguments, 2) arg. type
|
|
Passing of arguments |
- Pass by value: method(int d)
- Pass by reference: method(object D)
|
Integer d is constant throughout the method
Object D is variable in its data from the method
|
|
Inheritance |
- Embedding & using existing modular unit(s) in new modules, thereby inheriting existing ones
- All data & methods
of the old can be used & expanded by the new |
Import;
class (new child) extends (existing parent)
|
|
Applet |
- Java web-application
- Encapsulation & inheritance apply
- Note: applets have no main() method
|
Import;
class (new child) extends (existing parent)
HTML: <applet code=".class"> </applet>
|
|
References |
- OOP concepts
- Programming trends
- Future of software development
|
O'Leary
NUS
http://www.well.com/user/ritchie/oo.html
OOD success criteria
|