Skip to main content

Short note: Polymorphic signal

Short answer

A polymorphic signal combines UML signals (asynchronous messages) with polymorphism: the same signal sent to different objects invokes class-specific behavior. Signals can form a generalization hierarchy; a transition triggered by a parent signal also fires for child signals. This decouples sender from receiver types, allowing new signal subtypes or receiver classes without changing the sender.

Write a short note on Polymorphic signal.

(Interpreted as the polymorphism of signals/messages in UML: the same signal or message can be sent to different objects, and each reacts in its own way, depending on its class.)

A signal is an asynchronous message that one object sends to another to notify it that something has happened; the sender does not wait for a reply. It is shown as a class with the stereotype <<signal>>. Signals can be organised in a generalization hierarchy, just like classes.

Polymorphism means "many forms": the same message results in different behaviour according to the receiving object's class. A polymorphic signal combines the two ideas:

  • In a state machine, a transition triggered by a general signal is also triggered by any of its child signals. For example, a transition on Alarm also fires when FireAlarm or GasAlarm arrives.
  • A signal can be sent to a general receiver (a superclass or interface), and each subclass supplies its own handler, so the response differs.
        <<signal>>
        Alarm
           ^
     +-----+------+
  FireAlarm    GasAlarm       (signal hierarchy)

 Sender --alarm--> Device
   Device:HomeSystem -> rings bell
   Device:Factory    -> shuts valves

Example: draw() sent to a Shape reference executes Circle.draw() or Square.draw() depending on the actual object. This keeps the sender independent of the receivers' types, so new receivers (or new child signals) can be added without changing the sender.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Object Oriented Analysis and Design chapter 2 questions →