Object Technologies

This page is for students enrolled in the Fall 2006 Object Technologies Raytheon PEP course.

 Course Info

 Course Outline

 Links 

 Instructor 

 Prerequisites

 BlueJ

 OO terminology

 Viewgraphs

 An OO quiz

 JavaExample

 Homework exercise

 Shapes Project Updated!


Updated 4 December 2006.

Goals:

To learn about Object Orientation (OO); Object Oriented Analysis (OOA), Object Oriented Design (OOD), and Object Oriented Programming Languages (OOPL).  The class is loosely based upon one of the same name as taught at the Loyola Marymount University Computer Science graduate school by Ray Toal, Ph.D.

Class Schedule:

Twelve meetings, Wednesdays at noon starting 21 April. Building B1, Room S827. (Computer training room on North side of the building).

Text:

Core Java Volume I - Fundamentals. Horstmann and Cornell, Prentice Hall. ISBN 0-13-089468-0. This book provides an introduction to the Java programming language. 

Expect to use the Web as a learning resource. I have included some good links below.

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.

Instructor:

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

805.562.2336 (W)

hayes"at"raytheon.com

http://home.earthlink.net/~object_technologies

Prerequisites:

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.

BlueJ:

A particularly appropriate Java environment for learning OO is the BlueJ IDE (Integrated Development Environment) offered for free from www.bluej.org. Developed by European academics, BlueJ runs on top of the Java JDK (Java 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 JDK. BlueJ uses a UML (Unified Modeling Language) class diagram to create class hierarchies, and can do some other very cool things, such as:

  • Create an instance of a class with a simple key-click.
  • Automatically create Java skeleton code for a class.
  • Execute methods without having to create public static void main().
  • Automatically create interface documentation in HTML using javadoc.
  • Simple text editor and debugger.
  • Migration path to NetBeans IDE with special BlueJ version of NetBeans

This is a very cool tool, especially when you consider that it's free.

I've posted up a BlueJ project Shapes.jar that you can download.  See the link at the top of the page and the discussion below.

Eclipse:

If you think you're ready to graduate from BlueJ, you might want to take a look at a more sophisticated, yet still free Java IDE, called Eclipse.  Originally developed by a consortium of "anybody but Microsoft" companies, this is a sophisticated tool.  You might like it better than NetBeans, Sun's freeware Java IDE. 

Java at Raytheon:

What is likely the largest software development underway at Raytheon?  Raytheon is systems integrator for the new DDG 1000 destroyer - and they're using Java!  The Real Time Specification for Java (RTSJ), to be exact.  Read about it here.  Here's an article about Java's movement into the embedded domain, including military systems such as those we design and create at Raytheon.

Links:

Here are some useful links. There is an immense amount of useful information on Object Technologies available on the web. In particular, I recommend reading through the OO Frequently Asked Question (FAQ) at the second link. 

http://www.cetus-links.org/ About 20,000 links to all things OO.

http://www.cyberdyne-object-sys.com/oofaq2/ Official OO FAQ list.

http://www.toa.com/pub/oobasics/oobasics.htm

http://ootips.org/

http://java.sun.com

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.togethersoft.com/ Now owned by Borland. Offers pro quality OO development IDE.

http://www.industriallogic.com/papers/learning.html#NAVIGATION

http://www.iconixsw.com/

http://www.gentleware.com/ Offers pro-quality OO IDE.

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.eclipse.org/  A popular free Java IDE

 

Back to top

 

An exercise:

I've created a BlueJ project to demonstrate a simple OO system that includes a class hierarchy and polymorphism.  The project is saved in the Java archive format ("jar" format).  I've setup the class structure completed several of the classes.  See if you can implement the subclasses of the abstract class Triangle. 

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.

  • The inherent complexity of software
  • Complexity in the natural world
  • Human limitations in dealing with complexity
  • Algorithmic vs Object Oriented Decomposition
  • Abstraction and Hierarchy
  • Object Oriented Analysis and Design
  • The Object Model
  • Abstraction
  • Encapsulation
  • Hierarchy
  • Typing
  • Concurrency
  • Persistence (Extent)
  • Classes and Objects
  • Objects/Instances
    • State
    • Behavior
    • Identity
    • Relationships among objects
  • Classes
    • Abstraction
    • Interface
    • Implementation
    • Visibility
    • Relationships among classes
  • Classes and Objects in Analysis and Design
  • Class and Object identification
  • Implementation mechanisms
  • Quality Abstractions
  • Choosing Operations
  • Choosing Relationships
  • Choosing Implementations
  • Classification
  • Difficulty of identifying classes
  • Classical Categorization, Conceptual Clustering, Prototype Theory
  • Object Oriented Analysis and Design
  • Classical approach
  • Behavior Analysis
  • Domain Analysis
  • Use Case Analysis
  • Finding and Refining Key Abstractions
  • Finding Mechanisms
  • Modeling
  • Why we model systems
  • Basic Principals of Modeling
  • Legacy modeling schemes
    • Procedural
    • OO
  • The Unified Modeling Language (UML)
  • The Method Wars
    • Booch method
    • Object Modeling Technique (OMT)
    • OOSE/Objectory
    • Fusion
    • Coad/Yourdon
  • The Three Amigos
  • Overview
    • UML is a language, not a process
    • Visualization
    • Specification
    • Construction
    • Documentation
  • UML Building Blocks
    • "Things" (key abstractions)
      • Structural things
      • Behavioral things
      • Grouping things
      • Annotational things
    • Relationships
      • Dependency
      • Association
      • Generalization
      • Realization
    • Diagrams
      • Class Diagram
      • Object Diagram
      • Use case Diagram
      • Sequence Diagram
      • Collaboration Diagram
      • Statechart Diagram
      • Activity Diagram
      • Component Diagram
      • Deployment Diagram
    • Common Mechanisms
  • Architecture modeling in UML
  • Examples

 

  • Modeling Tools
  • Rational Rose
  • Together

 

  • Programming Languages Overview
  • Origins of OOPL
  • Simula
  • Smalltalk
  • Abstract Data Types (ADT's)
  • Object Oriented vs. Object Based languages
  • OOPL design issues
  • Exclusivity of objects
  • Implementation and Interface Inheritance
  • Type checking and Polymorphism
  • Single and Multiple Inheritance
  • Allocation and Deallocation of Objects
  • Dynamic and Static binding
  • A survey of Object Oriented Programming Languages
  • Smalltalk
  • C++
  • Eiffel
  • Ada 95
  • C#
  • An in-depth look at Java
    • History of Java
    • Key features/getting past the hype
    • Simple
    • Object oriented
    • Distributed
    • Robust
    • Secure
    • Architecture Neutral
    • Portable
    • Interpreted
    • High Performance (!?)
    • Multithreaded
    • Dynamic
  • Fundamental Programming Structures in Java
  • Objects and Classes
  • Inheritance
  • Interfaces and Inner Classes
  • Applets/Java and the Web
  • Examples
  • The Java Virtual Machine
  • Stupid programming tricks: The KVM on a Palm OS PDA

 

  • Design Patterns
  • Overview
  • What is a design pattern
  • Christopher Alexander
  • Gang of Four
  • Design Patterns: Elements of Reusable OO Software
  • Describing Design Patterns
  • How design patterns solve design problems
  • Finding appropriate objects
  • Determining object granularity
  • Specifying object interfaces
  • Specifying object implementations
  • How to select a design pattern
  • How to use a design pattern
  • Some examples of patterns
  • Design Pattern Catalog
  • Creational patterns
  • Structural patterns
  • Behavioral patterns
  • Antipatterns

 

  • Frameworks and Toolkits
  • MFC
  • JFC

 

  • What are components
  • Binary re-use vs. Source re-use
  • The problem with DLL's
  • The Component Object Model COM / DCOM
  • Binary module (DLL or EXE)
    • Heterogeneous components seamlessly interoperate
    • Binary standard
  • Interfaces
    • Interface vs. Implementation
    • IUnknown
  • Dynamic linking
  • Common Object Request Broker Architecture (CORBA)
  • J2EE
  • .NET

 

  • OO Miscellany
  • Distributed Objects
  • Concurrency in OO
  • OO and real-time
  • OO and embedded systems

 

Back to top

 

OO Technologies Terminology

See how many of these you can define.

Class

Object

Polymorphism

Inheritance

Abstraction

Interface

Instance

Type

Scope

Extent

Persistence

Extention

Visibility

Use Case

Stereotype

Constraint

Aggregation

Composition

Association

Scenario

Framework

Component

Encapsulation

Message

Method

Member

Class Variable

Modularity

Generalization

Specialization

Refinement

Superclass

Subclass

Field

Constructor

Destructor

Garbage Collection

Identity

State

Behavior

Pattern

Virtual Machine

Package

Abstract Class

Abstract Data Type

Collaboration

Concurrency

Monitor

Thread of control

Process

Late (dynamic) binding

Strongly typed

Weakly typed

Protected

Public

Private

Static binding

Static Parametric Polymorphism

Instance Variable

Concrete Class

Friend

Implementation

Information Hiding

Instantiation

Metaclass

Class Diagram

Interaction Diagram

Object Diagram

Signature

Virtual Function

Finalization

Class method

Overloading

Coupling

Delegation

Member Function

Operation

Overriding

Toolkit

Deployment Diagram

Primitive Type

Sequence Diagram

View

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);
     shapeCount++;
     shapeArray[1] = newShape (Square, 3, 0);
     shapeCount++;
     shapeArray[2] = newShape (Rectangle, 2, 4);
     shapeCount++;

     // 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 < shapeCou