Requirements
Design
Implementation
Test
Problems with Traditional Systems
Limited reuse
Modeling
An OO model is easier to understand than a traditional model. It
also has a better correspondence with both the reality it models
and the code produced
Modularization
In a function-oriented system all functions are operations on
common data. An OO system consists of a number of objects,
each of which is a module of its own. Each object has its own data
and operations to process it
Productivity
By reusing code and creating class libraries, productivity can be
increased
Key Features of OO Software
Development listed:
OO focuses on objects as the unit of computation and
abstraction
Attributes
Store the data in an object
E.g. Id, Name, Description
Methods
Represent the functionality
Perform operations on the object’s attribute and call other objects
methods
Methods represents the object’s behavior
e.g. Create, Modify, Remove, GetAmount
Objects Perform Operations
You can ignore the low level details of how things works
internally and think at a higher level of abstraction. This means
you can comprehend more objects, and thus understand more
complex systems.
...
Exercise: Spot the operations and
Attributes of the objects
My Pencil
My Cd Writer
My car
How objects Interact - Messages
getAddress getAge()
setAddress setBirthday
Person Object
Objects Associate with Each Other
For on object to send a message to another, it must have
”visibility” to that object.
An ATM may have a key board, a card reader and a case drawer,
all of which may be objects.
More on composition
Analogous to real world objects
”part-of ” hierarchy.
Where Objects come from - Classes
Analogy
My House
Me
Classification and inheritance
Example
Account
Bank Account
InterestCheckingAccount
More on Inheritance
Each operation has the same meaning but carries out the
operation is its own unique way.
The client (sender) object does not need to know what type of
object he is sending ”speak” to.
Each class can carry out the operation is its own unique way
“Load Passengers”
Example of Polymorphism
- SavingsAccount
- DepositAccount
- CheckingAccount
In java:
Account.calculateInterest();
No need to test for a ”type” field, create a case statement, and so on.