Classes: Stack Push Internal Data

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Classes

I'd like to show you some examples of the pattern. These methods and technologies are probably familiar,
but you may never have thought of them as examples of event-driven programming.
In the 1990's, object-oriented (OO) technology and methods gradually eclipsed the structured methods of
the 1970s and 1980s. Software methodologists began experimenting with new diagramming notations to
express object-oriented concepts. At that time, one of the popular diagramming notations (invented by
Grady Booch?) was object diagrams. Here is an example of an object diagram.
Stack
push
p op

internal
data

peek

Object diagram of a STACK object

I like object diagrams because they clearly show objects as examples of the Headless Handlers pattern. An
object diagram is basically the same as the Headless Handlers diagram, except that events arrive from the
left rather than the top of the diagram. The Stack class, for example, is clearly a collection of event
handlers (called methods in OO jargon) for handling push, pop, and peek events.
The lesson here is that if you're an object-oriented programmer you already know event-driven
programming. When you write object methods, you are - quite literally - writing event handlers.
As we've seen, in Structured Systems Analysis, a computer system was conceptualized as a factory. Raw
materials flow into the factory, travel along conveyor belts (data flows) through workstations (processes)
and eventually a finished product is pushed out the door.
The suppliers of the raw materials were called sources, and the consumers of the finished products were
called sinks. Sources and sinks were called the terminators of data flows - they were the places where data
flows began and ended.

You might also like