zircon icon indicating copy to clipboard operation
zircon copied to clipboard

The Screen implementation violates the Liskov Substitution Principle

Open adam-arold opened this issue 3 years ago • 2 comments

If a Screen instance is passed to a View's constructor it won't be displayed correctly because the underlying Screen implementation doesn't handle delegation to its underlying TileGrid properly. The display will be garbled.

adam-arold avatar Aug 14 '20 08:08 adam-arold

I've noticed that we're creating a new Screen for the TileGrid in BaseView: final override val screen = Screen.create(tileGrid)

Testing for the type of TileGrid passed to the View fixes the bug:

final override val screen =
            if (tileGrid is Screen) {
                tileGrid
            } else {
                Screen.create(tileGrid)
            }

but I'm not sure if I'm not simply masking an underlying problem in the Screen implementation

Seveen avatar Oct 04 '20 14:10 Seveen

I think this is masking, because outside of these Views the problem still persists. I'm not sure that there is a simple solution for this problem unfortunately. 😢

adam-arold avatar Oct 04 '20 22:10 adam-arold