Prev | Current Page 137 | Next

Carl Reynolds and Paul Tymann

"Schaum's Outline of Principles of Computer Science"


Making the software object the unit of modularity has some important advantages. First, OO programming
???encapsulates??? the state and behavior of objects. Programs wishing to use the code of an object can access that
code only through public instance variables and public instance methods. When a program invokes the
changeSpeed method of an automobile, the invoking program has no visibility of how the change is effected.
This prevents programmers from taking advantage of details of implementation.
It may sound like a disadvantage to prevent programmers from taking advantage of knowledge of implementation
details. However, over many years programmers have learned that ???things change.??? When one takes
advantage of some particular implementation detail, one risks having one??™s program fail when the class is
upgraded. So, in OO programming, the ???contract??? between the class and the user is entirely in the specification
CHAP. 4] SOFTWARE 51
of the interface, i.e., the method parameters and the return values. Even if the creator of the class decides to
make a change internally, the interface will remain effective. This encapsulation means reliable operation,
even as ???things change.???
Another very big idea supported by OO programming languages is inheritance.


Pages:
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
Titan Poker poker bonus kody teksty piosenek Paradise Poker Kwas hialuronowy