Professional Documents
Culture Documents
Chapter 2: IMMUTABLE Objects: Programming 2 COMP 112
Chapter 2: IMMUTABLE Objects: Programming 2 COMP 112
OBJECTS
PROGRAMMING 2
COMP 112
Introduction
2
Design Process:
That allows the programmer to divide a program into
methods while coding. The process is called
"encapsulation and generalization". The essential steps
are:
1. Write a few lines of code in main or another method
and test them.
2. When they are working, wrap them in a new method
and test again.
3. If it's appropriate, replace literal values with variables
and parameters.
Design process:
A process for determining what methods a class or
program should have.
Encapsulate:
To wrap data inside of an object, or to wrap statements
inside of a method.
Generalize:
To replace something unnecessarily specific (like a
constant value) with something appropriately general
(like a variable or parameter).