home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 8 Other
/
08-Other.zip
/
SOMINF.ZIP
/
SOMOOPS.INF
(
.txt
)
< prev
next >
Wrap
OS/2 Help File
|
1992-07-24
|
13KB
|
250 lines
ΓòÉΓòÉΓòÉ 1. What is an Object? ΓòÉΓòÉΓòÉ
o The encapsulation of data and its methods.
o An item that can be manipulated as an independent unit, and that a user could
work with to perform a task (CUA)
o Objects communicate via messages
Real-life objects:
o printers
o mail in-baskets
o mail out-baskets
o file folders
o file cabinets
o desktops
o shredders
o a book
- can be read
- can be stored and retrieved
- can be discarded
ΓòÉΓòÉΓòÉ 2. Why Object Oriented Programming? ΓòÉΓòÉΓòÉ
Existing Software Problems Detail
Long Development Cycles most software developed from scratch -- lack
of re-usable code
Frequent Modifications changing existing software usually creates
other problems
Non-Intuitive Coding Techniques diverse ways to pass control, information --
severe learning curves
OOP Solutions Detail
Readily Re-usable Code libraries of objects can be used for multiple
projects
Easily Modified so long as the methods remain constant, the
internals are transparent
Real World Model (intuitive) the world is comprised of objects
ΓòÉΓòÉΓòÉ 3. What is a class? ΓòÉΓòÉΓòÉ
o A description of the underlying data interface
- includes both data and operations
- operations are implemented by methods
- thus, a class contains both data and methods
o Permanent template or model from which new objects are created
o An object is an instance of a class
- an object is a variable declared to be of some specific class
- several objects of a class can exist at once -- these are instances of the
class
o Objects exist only during run-time -- classes are static system elements
ΓòÉΓòÉΓòÉ 4. Inheritance ΓòÉΓòÉΓòÉ
o Properties of a class (data and/or methods) can be passed along (inherited
by) other classes
o A subclass has all the properties of its parent (the Superclass)
o Multiple Inheritance is where a subclass may inherit from multiple parents
(this is available in C++, but not in Smalltalk/V PM)
o There are three degrees of inheritance:
1. No redefinition of methods in a subclass
2. Redefinition allowed, but must give the same result (also known as
subtyping)
3. Redefinition can override the original definition, even if these now
contradict (this is the degree of inheritance used by Smalltalk)
ΓòÉΓòÉΓòÉ 5. Inheritance Hierarchies ΓòÉΓòÉΓòÉ
IS A --> Class relationship
ANIMAL
/ \
BIRD MAMMAL
/ \
SPARROW PRIMATE
/ \
MONKEY MAN
ΓòÉΓòÉΓòÉ 5.1. Inheritance Hierarchies (continued) ΓòÉΓòÉΓòÉ
PART OF --> Object relationship
HOUSE
/ \
ROOF WINDOW -------------------------
/ \ | | |
SHINGLES NAILS PANES GLASS LOCKS
ΓòÉΓòÉΓòÉ 5.2. Class Inheritance Example ΓòÉΓòÉΓòÉ
"IS A" for PM Windows
OBJECT
|
WINDOW
/ \
APPLICATION CONTROL
/ / \ \
TEXT GRAPHICS MENU FRAME
ΓòÉΓòÉΓòÉ 6. Polymorphism ΓòÉΓòÉΓòÉ
o Ability to send the same message to objects of different classes
o Allows generic operations to be performed in a global environment
o Example:
delete message may mean different things to different objects
The term operator overloading refers to the same operator (such as "ADD")
behaving differently when used to send a message to different object types.
ΓòÉΓòÉΓòÉ 7. Object-Oriented Programming Design Methods ΓòÉΓòÉΓòÉ
o object-based (not function OR data individually)
o the challenge is in defining the classes properly
o often more "art" than "science"
o brainstorming class definitions is helpful
o project leads architect classes, remainder of staff implement
o re-definition of classes is common
ΓòÉΓòÉΓòÉ 8. Definitions for Object-Based Languages ΓòÉΓòÉΓòÉ
An object-oriented language is:
o object-based
o class-based
o capable of class inheritance
ΓòÉΓòÉΓòÉ 9. Object-Oriented Languages ΓòÉΓòÉΓòÉ
Language Notes
C++ AT&T--Bjarne Stroustroup
Smalltalk/V PM Xerox-Digitalk
Simula67 1967
Objective-C Brad Cox
LOOPS LISP based
Eiffel Bertrand Meyer
Object PASCAL Apple
ΓòÉΓòÉΓòÉ 10. Class Exercise (OOPS) ΓòÉΓòÉΓòÉ
o Identify each of the following as an Object or Method:
- printer
- add
- date
- getdate
- delete
- 74
o Design an object called "Student"
ΓòÉΓòÉΓòÉ 11. Class Exercise (Application Scenario) ΓòÉΓòÉΓòÉ
A local bank wishes to allow merchants in a small shopping center on-line
verification of charge card purchases. Merchants who are bank customers should
have the ability to download a set of their most active customers (with account
information) to a local database for verification. A larger database will
serve the entire shopping center, and will contain account information for ALL
bank customers (note, the entire shopping center is on a local area network).
For customers who do NOT bank locally, the merchant can access a remote
verification center for credit card approvals. The merchant has no way of
knowing where information for any particular customer will reside.
o Set up the underlying program architecture for the merchant's credit-card
verification system -- assume the entire shopping center is on a token-ring
supported by an AS/400 as a database server
o What are some technical concerns relating to:
- maintainance of local customer information
- keeping the AS/400 database current
o Be sure to STATE YOUR ASSUMPTIONS!
ΓòÉΓòÉΓòÉ <hidden> Data Encapsulation ΓòÉΓòÉΓòÉ
A CheckingAccount object ...
ΓòÉΓòÉΓòÉ <hidden> ΓòÉΓòÉΓòÉ
An object is Data, and access to the Data
Note: Data is kept as the object's Instance Variables during run-time
Data access is accomplished via operations called Methods
ΓòÉΓòÉΓòÉ <hidden> ΓòÉΓòÉΓòÉ
Communication Between Objects
o Via messages
- access data
- modify data
o Methods send/receive (are invoked by) messages
o Messages to which an object responds form its protocol