Mediator: The Central Nexus
Define an object that encapsulates how a set of objects interact.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Mediator
ARCANUM SCHOOL: Divination // Telepathy
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// RPG PATTERN //
**FREE
Ctl-Opt NoMain;
Dcl-Proc UI_Mediator Export;
Dcl-Pi *N Ind;
EventSource Char(10) Const;
EventAction Char(10) Const;
End-Pi;
// Instead of subfiles knowing about each other, they speak through the Mediator
Select;
When EventSource = 'SUBFILE1' and EventAction = 'SELECT';
UpdateSubfile2();
ShowDetailsPanel();
When EventSource = 'BTN_SAVE' and EventAction = 'CLICK';
ValidateSubfiles();
CommitDB2Transaction();
EndSl;
Return *On;
End-Proc;
Mediator
In the tangled web of display files (DSPF) and complex interactive programs, the Mediator pattern untangles the direct coupling. All components report state changes to the Central Nexus, which then decides how the rest of the application must react.
Runic Tags:
#behavioral
#ibm-i
#runes
#mediator