jeudi 10 juin 2021

How to Implement ”Bridge of Desing Patterns + Default Item“ [closed]

There are multiple renderedElementsrenderedElementsAbs's subclass),Each renderedElement can be rendered by multiple rendererrendererAbs's subclass). And Each renderedElement have a default renderer(The default renderer may be different for different renderedElements)

There are two thinking but they both have some weakness.

【1】

renderedElement.setRender(renderer = defaultRenderer)

there is a default parameter but the class of renderer will include renderedElements. This creates a circular dependency.

【2】

renderer.render(renderedElement)

it have not a circular dependency. but that doesn't seem to implement "default renderer"

(p.s. renderedElement and renderer could be extand,so you cannot use an "if-else" statement)

Hope to find a great solution!

Aucun commentaire:

Enregistrer un commentaire