CS 4773 Object Oriented Systems Terminology and UML


Read: Core Java 1, Chapter 4

Terminology

Structured Programming:

Design procedures to solve a problem. (verbs)
Then decide on the data structures for storing the data.

After you identify the tasks to be performed you can use either top-down or bottom-up design (or a combination)
top down: stepwise refinement: break the problem in to subtasks.
bottom up: write procedures to solve simple tasks and then combine them.

Object Oriented Design:

Think in terms of objects: nouns
Each object is responsible for carrying out a set of related tasks.
An object should never directly manipulate the data of another object.
It should not expose data for other object to manipulate.

First isolate the classes. Only then do you think about methods.
Each method is associated with the class that is responsible for the operation.

Important characterists of an object:

Relationships between classes:

Introduction to UML class diagrams

UML class diagrams show relationships between classes.

UML Notation from Design Patterns Explained, page 38.

There are 2 types of has-a relations: composition and aggregation
Note that the distinction between aggregation and composition is subtle and often no distinction is made.

Composition: contained object is an intrinsic part of the containing object
    Usually, the contained object has the same lifetime as the containing object.
Aggregation: contained object is not part of the containing object
    Usually, the contained object has an existence independent of the containing object

Examples:

Class A has-a class B if there is a field of B in A.

This is different from uses-a.
Typically Class A uses-a class B if B is used in a method of A.
    May be a parameter
    May be a local variable of a method
    May be created with new

Figures 2-3 and 2-4 from Design Patterns Explained, pages 39 and 40.

Some classes diagrams for the TimeTest application.

These diagrams are from JBuilder Enterprise.




Programming in Java

Class Project Introduction

Design an editor to edit records of (so far) undisclosed type