CS 4448 - Fall 1998
Object-Oriented Programming and Design
Lecture 4
Discuss Homework #2
- Inheritance
- Does number know how to become a Triple, yes and
no. Depends on your implementation.
- Don't need super with x and y method in Triple, why?
- Why did we need to implement storeOn: or did we?
- A Point is just a 2D Triple on the 0 plain.
- Reuse!!!! @, asTriple, Round, min: ...
Smalltalk
- instance variables, class variables
- io - aStream nextPut: $@ , printOn: aStream
- Does no type checking mean no Templates?
Chapter 4
C++
- member variables/attributes/data, static var/att/data
- Templates P.82 - used mainly to parameterize(generic) classes
- .hh versus .cc files
- Privileges(private) used with constructor and destructor can help in memory
management. You can not create object but other class can P.110
- io - Streams(istreams, ostreams) - cin >> , cout << P.89 or printf
- Macros - #define #ifndef #endif is used by the preprocessor
Discuss Homework #4
- Molecule check if it is water
- inheritance limited for some - duplicate code results in errors
and trouble for maintainability and future reusability.
- inheritance must be used correctly - wrong answers vs. no answer
- hard coded answers can be bad, # of legs
- Calling the parent constructor new or specialized with info
- OO - encapsulation, modularity, abstraction, design hierarchy
- Design is based on analysis which can change. One design does not
fit all situations.
- Design Hierarchy vs. real life hierarchy
Examination #1 next week
Adam Jonathan Griff,
computer@griffmonster.com
Copyright © University of Colorado. All rights reserved.
Revised: September 21, 1998