Scene management is a necessary component of programs with more than 1 scene, such as games. We will critique different design patterns to arrive at a good design pattern for scene management.

All of the codes use the same button object, and are for the same simple game.

Structureless Antipattern Edit

This antipattern just tries to code the game, conveniently changing the draw function and mouseClicked function when required to go to a new scene. Out of the three, this is the shortest, but the code is harder to understand, and is less intuitive.

The code is available here.

Khan Academy's Scene management pattern Edit

This pattern is not as bad, and eventually possible to wrap our head around. However, it doesn't highlight the importance of scenes and how mouseClicked, besides draw, should change with the scene.

The code is available here.

Scene object pattern Edit

This pattern highlights the scenes, and allow each scene to own their own buttons. The Scene object can be extended to incorporate more possibilities. This pattern becomes better when there are more buttons. Out of the three, this is the longest (but not significantly longer), but the code is the most intuitive.

The code is available here.
☀ All Khan Academy content is available for free at:

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.