To keep classes decoupled I'm using the Mediator Pattern like so:
class Mediator {
constructor(canvas, selectionBox, undoManager) {
this.canvas = canvas
this.selectionBox = selectionBox
this.undoManager = undoManager
}
addText(text) {
this.canvas.addText(text)
this.undoManager.captureUndo()
this.selectionBox.update()
}
addImage(image) {
this.canvas.addImage(image)
this.undoManager.captureUndo()
this.selectionBox.update()
}
// ... etc
}
as more and more methods are added on the Mediator class, isn't it going to become a God Object?
If that's the case how do I resolve this? Perhaps create sub-mediators that group actions together and use a parent mediator to coordinate them?
(*) For the record I just started using this pattern and I'm not sure I'm doing this correctly.