GoF Patterns

Object Design Seams — Strategy · Template Method · Composite

Strategy Pattern
<<interface>>
StatisticStrategy
+ compute(tick)
+ getType()
+ getWindowSize()
Avg
Min
StdDev
<<interface>>
TradingDecisionStrategy
+ decide(snapshot, state)
+ getAction()
Trend
Volat
Range
statistics/ & strategy/
Why

New statistics and trading behaviors are added without changing the core framework.

Template Method
AbstractRollingStatisticStrategy
+ compute(tick) ← Template
1. Update rolling window (Deque)
2. Check if window is full
3. call calculate(window) ← hook
4. Emit StatisticEvent
# calculate(window) ← ABSTRACT
AverageStatisticStrategy MovingAverageStatisticStrategy StandardDeviationStatisticStrategy MinStatisticStrategy MaxStatisticStrategy
Why

All rolling statistics share an identical lifecycle — only the final computation differs.

Composite Pattern
PortfolioComponent interface
+ totalValue()
+ report()
Portfolio
branch
StockHolding
leaf
Portfolios contain multiple holdings; the reporting engine sees every node through one interface.
portfolio/ package
Why

Composite enables uniform traversal during reporting across portfolios and holdings.