Chapter 6

Modelling Small Programs

The simplest Codecharts represent individual classes and methods, their properties, and the relations between them. This chapter introduces the reader to these symbols, depicted in Legend 2 (page 48), and demonstrates how they are used.

We begin with the example of the classes LinkedList and LinkedListItr and some of their interfaces in package java.util,1 extracts from which are depicted in Program 1.

Program 1. Extracts from java.util

public interface Collection { …
   public Iterator newItr(); …
public interface Iterator { …
   public Object next(); …
public interface List
   extends Collection { …
public interface ListIterator
   extends Iterator { …
public class LinkedList
   implements List … {
   public Iterator newItr() { …
   // produce a (new) instance
   // of LinkedListItr
class LinkedListItr
   implements ListIterator { …
   public Object next() { …
   // iterate over a LinkedList
   // return Object

Note: Identifiers were slightly altered for pedagogical purposes. For example, to prevent confusion with class Iterator, the signature of the various iterator() methods was changed (consistently) to newItr().

image

Legend 2. Symbols introduced in this chapter

Codecharts were tailored to overcome many of the limitations of existing modelling notations. By the principle of abstraction, Codecharts do not distinguish between classes and interfaces ...

Get Codecharts: Roadmaps and blueprints for object-oriented programs now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.