Object Technologies

This page is for students enrolled in the Fall 2009 C/C++/OO/Visual Studio Raytheon PEP course.

 Course Info

 Course Outline




 BlueJ New!

 OO terminology

 Class viewgraphs

 An OO quiz


 Homework exercise

Updated 26 September 2009.


To learn about Object Orientation (OO); Object Oriented Analysis (OOA), Object Oriented Design (OOD), and Object Oriented Programming Languages (OOPL).

Class Schedule:

Eight meetings, Wednesdays at noon starting 30 September. Building B1, Room S827. (Computer training room on North side of the building).


Recommended books:

Object-Oriented Analysis and Design with Applications. Grady Booch. ISBN 0805353402

This is still the best book to learn the classical OO approach, in my opinion. It is considered something of a classic. It's the basis for the first several sessions of the class, and I have shamelessly included Grady's OO cartoons in my slides. (this is called "fair use", it's not a copyright violation ;-) The book predates the UML, so the notation used is somewhat dated.

The Unified Modeling Language User Guide. Grady Booch, et al. ISBN 0-201-57168-4.

UML is de rigeur nowadays for OO designs. The melding of three major OO notational schemes, it has become the official OO notational scheme for the Object Management Group (OMG), an International consortium of companies and individuals interested in OO. UML is used to model and document the static and dynamic properties of an OO system. Software job requisitions on Raysearch now commonly require knowledge of the UML.

Design Patterns, Elements of Reusable Object-Oriented Software. Erich Gamma, et al. ISBN 0201633612

This text on design patterns, the "Gang of Four" design patterns book, is considered a classic. It is in its 24th printing, and is unrevised from its initial 1994 release! The text is not a tutorial on object technologies: rather, it's a catalog of re-usable object oriented software, as its title states.


Robert G. (Bob) Hayes, Senior Principal Software Engineer, Raytheon Vision Systems (RVS).

805.562.2336 (W)




None, though the class will be primarily oriented towards software developers. A willingness/ability to "free your mind" from being bound by legacy, non-OO programming languages and systems is required to truly benefit from the class. Reading and doing exercises outside of class will be required for anything except a very cursory understanding of the material.

It's necessary to program in some object-oriented language to truly learn the concepts. We're going to use Java in class, though you may wish to use some other language. A note: Visual Basic is not an object-oriented language, though you can certainly implement object-based designs with it.


A particularly appropriate Java environment for learning OO is the BlueJ IDE (Integrated Development Environment) offered for free from www.bluej.org. Developed originally by Australian and European academics, BlueJ runs on top of the Java SDK (Software Developer's Kit) which can be obtained, again for free, from Sun's Java website http://java.sun.com. BlueJ allows the student to quickly start creating classes and running programs, in a more benign environment than that offered by the Java SDK. BlueJ uses an interactive UML (Unified Modeling Language) class diagram to create class hierarchies, and can do some other very cool things, such as:

This is a very cool tool, especially when you consider that it's free.  There’s a version of NetBeans that can run BlueJ projects.


Here are some useful links. There is an immense amount of useful information on Object Technologies available on the web, though the topic has faded a bit as OO has become the mainstream.

http://en.wikipedia.org/wiki/Object-oriented_programming   Here’s a shocker – the Wikipedia entry on OO ;-)

http://stason.org/TULARC/software/object-oriented-programming/   OO FAQ list

http://www.cetus-links.org/ About 20,000 links to all things OO, though very many of these links are broken.

http://netbeans.org  Website for pouplar, very capable, free IDE.

http://ootips.org/ Another OO links page.

http://java.sun.com Home of all things Java.

http://www.microsoft.com/com/default.asp Learn all about COM.

http://www.eiffel.com/ Home of Bertrand Meyer and our neighbors across the street in Goleta.

http://www.rational.com/ Home of the "Three Amigos" and the Rational Unified Method.

http://www.industriallogic.com/papers/learning.html#NAVIGATION How to learn UML.

http://www.iconixsw.com/ UML info

http://www.gentleware.com/ OO IDE vendor. Offers Poseidon Community Edition IDE for free.

http://gamemaker.nl For those who don't want to do Java. They teach children OO with this.

http://www.bluej.org/ A really cool development environment for learning OO using Java.

http://www.cs.lmu.edu/~ray/classes/ot/   A web page on OO from a well regarded CompSci professor at a local university.


Back to top


An exercise:

Most all of us at Raytheon are domain experts to some extent. As such, we know some particular vocabulary of the domain, and are familiar with the various entities that exist in that domain. And even if we're not a domain expert in the area at which we work, we likely know or work with someone who is. For example, at RVS, we make infrared detectors in the form of focal plane arrays. These are usually named according to their most salient feature. Sometimes this is the fundamental chemistry involved (e.g. "Mer Cad" for HgCdTe) or the types of detectors incorporated (e.g. "two-color") or the temperature at which they operate ("uncooled" vs. "cooled"). By analyzing the vocabulary, and through understanding of the entities involved, we should be able to construct an "entity model" that is an abstraction of some aspect of the domain.

As an exercise, see if you can construct an entity model for something in your domain. Remember, in object orientation, abstraction is from the perspective of the viewer, according to his or her needs. So we want to try to construct an entity model of our domain from our personal perspective. For example, if you happen to work in the test department at the RIO, you might want to model some particular family of detectors so as to meet your requirements for testing them.

Each class meeting, I'll ask if anyone has an entity model they'd like to share. I'll start off by presenting one myself so we can get a feel for it.

Remember, getting properly formed abstractions is hard to do. Nobody gets it right the first time. And the abstractions are from your perspective: they need to make sense to you.


Back to top


Course Outline:

Here is an outline for the course. Take it with a grain of salt: we almost certainly won't cover all of these topics, and the ordering may get re-arranged to some extent. This course is attempting to cover in 12 one-hour informal sessions what is usually a graduate-level Computer Science course with prerequisites, 45 hours of class meetings, homework, and exams.








Back to top


OO Technologies Terminology

See how many of these you can define.














Use Case













Class Variable










Garbage Collection





Virtual Machine


Abstract Class

Abstract Data Type




Thread of control


Late (dynamic) binding

Strongly typed

Weakly typed




Static binding

Static Parametric Polymorphism

Instance Variable

Concrete Class



Information Hiding



Class Diagram

Interaction Diagram

Object Diagram


Virtual Function


Class method




Member Function




Deployment Diagram

Primitive Type

Sequence Diagram


Mutual Exclusion

Parent Class

Base Class



Back to top

An Object Quiz

How many of these can you answer?


1. The main elements of the Object Model are

  1. Abstraction, Encapsulation, Polymorphism, Typing
  2. Hierarchy, Modularity, Abstraction, Encapsulation
  3. Inheritance, Concurrency, Abstraction
  4. Abstraction, Encapsulation, Concurrency, Late-binding

2. UML stands for

  1. Universal Modeling Language
  2. Unified Modeling Language
  3. Uniform Modeling Language
  4. Unified Markup Language

3. COM stands for

  1. Complex Object Model
  2. Component Oriented Modeling
  3. Component Object Model
  4. Comprehensive Object Model

4. C is an Object-Oriented programming language.     T    F

5. Every Java program is Object Oriented. T F

6. It's possible to write top down, structured programs using C++. T    F

7. Objects are created in an OO programming language using a constructor.     T    F

8. An object is an instance of a class.    T    F

9. In Java, Interfaces can have a hierarchical relationship to other interfaces.   T    F

10. COM supports inheritance.     T    F

11. COM promotes binary reuse.    T    F

12. Abstraction is one of the fundamental ways humans cope with complexity.   T    F

13. Bob Hayes is a great instructor and the funniest and most intelligent person I have ever met. T F

14. Ada is a strongly typed language. T    F

15. Java and C# incorporate support for concurrency. T    F

16. C++ incorporates support for concurrency.   T    F

17. Every object is a monitor in C#.  T    F

18. Every object is a monitor in Java T    F

19. A method is a function defined by a class.  T    F

20. The concept of OO class is closely related to that of type.    T    F

21. Visual Basic is an object-oriented programming language.  T    F

22. Java allows multiple inheritance. T    F

23. Ada 83 is object based, and Ada 95 is object oriented.    T    F

24. In Java, Object is a class, and Class is an object.   T    F

25. CORBA stands for

    1. Common Object Request Broker Architecture
    2. Component Object Redaction By Analysis
    3. Comparison Of Raytheon's Business Associates
    4. Component Oriented Refactoring By Aggregation

26. Protected, Private, and Public are each visibility modifiers in Java.     T    F

27. Adapter and Observer are structural design patterns.  T    F

28. An object's members are its fields and methods.  T    F

29. A constructor is invoked just like any other method.  T    F

30. A method differs from a traditional function in that there is an implicit parameter that is a reference to the object.     T    F

31. The most powerful aspects of OO are generally considered to be:

  1. Encapsulation and Inheritance
  2. Abstraction and Polymorphism
  3. Message passing and collaboration
  4. Inheritance and dynamic binding

32. The three characteristic features of an object oriented programming language are:

  1. Abstract data types, inheritance, dynamic binding
  2. Encapsulation, strong typing, polymorphism
  3. Polymorphism, dynamic binding, strong typing
  4. Interfaces, encapsulation, polymorphism

33. An object can exhibit behavior that's not defined by its class. T    F.

34. A programming language that doesn't implement inheritance can be considered object-oriented.  T    F.

35. The terms method and member function are synonymous.  T    F.

36. Java supports the use of pointers for referencing methods. T    F.

37. In Java, the type of a method is part of its signature.   T    F.

38. In C++, all functions must be defined as part of some class.   T    F.

39. In Java, all methods must be defined as part of some class.    T    F.

40. C++ supports multiple programming paradigms.     T    F.

41. Java and C++ are both block structured programming languages.  T     F. 

Back to top

A Java Example


An abstract class Shape with two abstract methods, area() and circumference(). The classes Circle, Rectangle, and Square are subclasses of Shape. Each of the subclasses provides a concrete method for area() and circumference(). public and protected are visibility modifiers and are used with both data (i.e. instance variable) and methods.



public abstract class Shape {

// The existence of even one abstract method makes the class itself abstract: you
// cannot instantiate a Shape object: however, it is a true class. For example, you
// can declare an array of type Shape.

     public abstract double area(); // abstract method

     public abstract double circumference(); // abstract method



class Circle extends Shape {

     protected double r; // instance variable (field)

     protected static final double PI = 3.14159265358979323846;

     public Circle() { r = 1.0; } // constructor

     public Circle (double r) {this.r = r;} // constructor

     public double area() { return PI * r * r; } // concrete method

     public double circumference() { return 2*PI*r; } // concrete method

     public double getRadius() { return r; } // accessor method



class Rectangle extends Shape {

     protected double w, h; // instance variables

     public Rectangle() { w=0.0, h=0.0; } // constructor

     public Rectangle(double w, double h) {this.w = w; this.h = h;} // constructor

     public double area() { return w * h; } // concrete method

     public double circumference() { return 2 * (w + h); } // concrete method

     public double getWidth() { return w; } // accessor method

     public double getHeight() { return h; } // accessor method



class Square extends Shape {

     protected double s;

     public Square () { s = 0.0; }

     public Square (double s) { this.s = s; }

     public double area () { return s * s; }

     public double circumference () { return 4 * s; }

     public double getSide() { return s; }



We could write the following code to use the classes defined above. We declare an array of type "array of Shape objects" and fill it using constructors for the various shapes. We then see dynamic polymorphism as the array is iterated with each object having its area() method invoked to sum the areas of the shapes in the array. The Java runtime (i.e. the Java Virtual Machine, or JVM) dynamically binds the shapes[i].area() method invocation to the proper method for the object involved.


Shape[] shapes = new Shape[3]; // create an array to hold the shapes

shapes[0] = new Circle (2.0); // fill the array ...

shapes[1] = new Rectangle (1.0, 3.0);

shapes[2] = new Square (4.0);


double total_area = 0.0;

for (int i = 0; i < shapes.lenth; i++)

     total_area += shapes[i].area(); // compute the total area of the shapes in the array


A C Equivalent

// C program that is roughly equivalent to the Java Shape code above.

// We get some encapsulation with the shapeStruct structure, but no inheritance,
// limited abstraction, little modularity, limited heirarchy, no dynamic binding,
// limited data hiding, relatively weak typing, explicit memory management,
// no polymorphism, and lots of pointer use.

// Consider the following code in the scenario where you want to add another shape
// type, for example a triangle. What has to change?

// macros

#include <ansi_c.h>
#define PI 3.141592653

// typedefs

enum shapes {Circle, Square, Rectangle};

typedef struct {

int shapeType;
double param1;
double param2;
double (*getArea)();
double (*getCircumference)();

} shapeStruct;

// prototypes

double (*functionPointer) (shapeStruct *);
double circleCircumference (shapeStruct *);
double circleArea (shapeStruct *);
double squareArea (shapeStruct *);
double squareCircumference (shapeStruct *);
double rectangleArea (shapeStruct *);
double rectangleCircumference (shapeStruct *);
shapeStruct * newShape (int shapeType, double param1, double param2);
void destroyShape (shapeStruct * shape);

// functions

int main (int argc, char *argv[]) {

     char charBuffer[128];
     double totalArea = 0;
     double totalCircumference = 0;
     int i;
     int shapeCount = 0;
     shapeStruct * shapeArray[100];

     // Make some shapes

     shapeArray[0] = newShape (Circle, 1, 0);
     shapeArray[1] = newShape (Square, 3, 0);
     shapeArray[2] = newShape (Rectangle, 2, 4);

     // Calculate the total circumference

     for (i = 0; i < shapeCount; i++) {

      functionPointer = shapeArray[i]->getCircumference;
      totalCircumference += (*functionPointer) (shapeArray[i]);


     // Calculate the total area

     for (i = 0; i < shapeCount; i++) {

      functionPointer = shapeArray[i]->getArea;
      totalArea += (*functionPointer) (shapeArray[i]);


     printf ("total circumference is: %f\ntotal area is: %f", totalCircumference, totalArea);

     // Destroy the shapes

     for (i = 0; i < shapeCount; i++) destroyShape (shapeArray[i]);

     return 0;

} // end, shapes


shapeStruct * newShape (int shapeType, double param1, double param2) {

// Create a new shape of shapeType. This function serves as a kind of common
// constructor for a shape.

// Allocate memory for the new shape off the heap.

shapeStruct * shape = malloc (sizeof(shapeStruct));

// Determine the shape type that's being requested, and initialize it
// as required for that particular shape. A construct such as the
// switch statement used below is a sure sign that we're using a
// non-object oriented language.

switch (shapeType) {

case Circle:

shape->param1 = param1; // circle radius
shape->getArea = circleArea;
shape->getCircumference = circleCircumference;

case Square:

shape->param1 = param1; // square side
shape->getArea = squareArea;
shape->getCircumference = squareCircumference;

case Rectangle:

shape->param1 = param1; // rectangle length
shape->param2 = param2; // rectangle width
shape->getArea = rectangleArea;
shape->getCircumference = rectangleCircumference;


return shape;

} // end, newShape;


// The following function serves as a "destructor", freeing the memory
// used for a given shape. This function must be explicitly called to
// free up the object. Java does not need destructors, as objects are
// destroyed automatically when they are no longer needed.

void destroyShape (shapeStruct * shape) {

free (shape);

} // end, destroyShape


// The following functions serve as area and circumference calculators for
// each shape type. Note that a reference to the shape struct is passed as a
// parameter. Methods in Java have no need for this, as every method has an
// implicit "this" parameter that is a reference to its object.

double squareArea (shapeStruct * shape) {

return shape->param1 * shape->param1;

} // end, squareArea


double squareCircumference (shapeStruct * shape) {

return 4 * shape->param1;

} // end, squareCircumference


double circleArea (shapeStruct * shape) {

return PI * shape->param1 * shape->param1;

} // end, circleArea


double circleCircumference (shapeStruct * shape) {

return 2 * PI * shape->param1;

} // end, circleCircumference


double rectangleArea (shapeStruct * shape) {

return shape->param1 * shape->param2;

} // end, rectangleArea


double rectangleCircumference (shapeStruct * shape) {

return 2 * shape->param1 + 2 * shape->param2;

} // end, rectangleCircumference


Back to top

Last Revised: 26 Sept 2009
Ó 2002 - 2004 Robert G. Hayes.

Best viewed at 1024x768 16 bit color!
I'm not responsible for your poor resolution!
Pump it up!


You are visitor number http://counter.digits.com/wc/-d/4/-z/OTHits