100 lines
2.8 KiB
Plaintext
100 lines
2.8 KiB
Plaintext
' ============================================================
|
||
' WALKGUIDE — DESIGN PATTERNS (GoF)
|
||
' Flutter × Spring Boot × In-Device AI
|
||
' Pattern 6 of 7: STRATEGY (Behavioral)
|
||
' ============================================================
|
||
|
||
@startuml WalkGuide_06_Strategy
|
||
|
||
skinparam monochrome false
|
||
skinparam shadowing false
|
||
skinparam defaultFontName Arial
|
||
skinparam defaultFontSize 12
|
||
skinparam roundCorner 10
|
||
skinparam ArrowColor #555555
|
||
skinparam ArrowThickness 1.2
|
||
|
||
skinparam class {
|
||
BackgroundColor #FAFAFA
|
||
BorderColor #AAAAAA
|
||
HeaderBackgroundColor #E8E8E8
|
||
FontColor #222222
|
||
StereotypeFontColor #666666
|
||
AttributeFontColor #333333
|
||
}
|
||
|
||
skinparam package {
|
||
BackgroundColor #F5F5F5
|
||
BorderColor #888888
|
||
FontColor #333333
|
||
FontStyle bold
|
||
}
|
||
|
||
skinparam note {
|
||
BackgroundColor #FFFDE7
|
||
BorderColor #F9A825
|
||
FontColor #444444
|
||
FontSize 11
|
||
}
|
||
|
||
' ============================================================
|
||
' PATTERN 6 — STRATEGY (Behavioral)
|
||
' ============================================================
|
||
|
||
package "⑥ Strategy Pattern [Behavioral]" #E8F5E9 {
|
||
|
||
interface "ObstacleAlertStrategy\n<<Strategy>>" as AlertStrategy {
|
||
+ alert(DetectionResult result) : void
|
||
}
|
||
|
||
class "TtsOnlyStrategy\n<<ConcreteStrategy>>" as TtsOnly {
|
||
- _ttsService : TtsService
|
||
+ alert(result) : void
|
||
' TTS: "Caution! {label} {direction}. {distance}."
|
||
}
|
||
|
||
class "TtsWithHapticStrategy\n<<ConcreteStrategy>>" as TtsHaptic {
|
||
- _ttsService : TtsService
|
||
- _hapticService : HapticService
|
||
+ alert(result) : void
|
||
' TTS + vibration pattern
|
||
}
|
||
|
||
class "HapticOnlyStrategy\n<<ConcreteStrategy>>" as HapticOnly {
|
||
- _hapticService : HapticService
|
||
+ alert(result) : void
|
||
' Vibration only (silent environment)
|
||
}
|
||
|
||
class "ObstacleAnalyzer\n<<Context>>" as ObstacleAnalyzerCtx {
|
||
- _strategy : ObstacleAlertStrategy
|
||
- _aiConfig : AiConfig
|
||
+ setStrategy(ObstacleAlertStrategy)
|
||
+ analyze(List<DetectionResult>) : void
|
||
+ prioritize(results) : DetectionResult
|
||
+ calculateDirection(bbox) : Direction
|
||
}
|
||
|
||
class "AiConfig\n<<Config>>" as AiConfigStrategy {
|
||
+ alertMode : AlertMode
|
||
+ confidenceThreshold : double
|
||
+ maxInferenceFps : int
|
||
+ enabledLabels : List<String>
|
||
}
|
||
|
||
AlertStrategy <|.. TtsOnly : implements
|
||
AlertStrategy <|.. TtsHaptic : implements
|
||
AlertStrategy <|.. HapticOnly : implements
|
||
ObstacleAnalyzerCtx --> AlertStrategy : uses
|
||
ObstacleAnalyzerCtx ..> AiConfigStrategy : reads alertMode\nto select strategy
|
||
}
|
||
|
||
note right of ObstacleAnalyzerCtx
|
||
Guardian dapat ganti strategy dari dashboard:
|
||
alertMode = TTS_ONLY | TTS_HAPTIC | HAPTIC_ONLY
|
||
PUT /api/v1/guardian/ai-config
|
||
Strategy dipilih runtime tanpa ubah kode utama.
|
||
end note
|
||
|
||
@enduml
|