The Department of Computer Science & Engineering

CSE 115
Introduction To Computer Science for Majors I
Lecture C
Lecture Notes
Stuart C. Shapiro
Spring, 2001

Programming as Modeling

Brown U. Notes, Chapter 1

In Object-Oriented programming, we view a program as a model.
"a model is a simplified representation of something else." [p. 2]

Divide and conquer: A model is composed of models of the components of the thing being modeled.

Waterfall process for building models:
   Definition in English
      Analysis in detail of definition
         Specification precise contract with user
            Design of model to be implemented
               Implementation of design (in Java)
                  Testing implementation thouroughly

Object-Oriented Programming
Model objects, their components, and their behaviors.

Encapsulation: hiding details that are not important to users.

Hierarchies: put common details higher up.
E.g.: animals, mammals, predators, cats
   Java says mammal extends animal, ...
Instances: Tom, Sylvester, Fluffy
   Java says Tom = new cat();

is a programming language
has a syntax (grammar)
and a semantics (meaning)

Java compiler

translates source code into bytecode
complains about syntax errors
See UB on-line catalogue for a lesson in inadequate error messages.

Correctly compiled program may still have logical errors.
It may crash,
or it may do something, but not the correct thing---only you can tell.

Implementation cycle:

     Repeat {

       Code more of the model;

       Repeat {

         Repeat {


           debug syntax;

         } until compiles;


         debug a logic error;

       } until correct;

     } until complete;

First Previous Next

Copyright © 2001 by Stuart C. Shapiro. All rights reserved.

Stuart C. Shapiro <>