Patterns for Scene Management

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 ===
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 ===
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 ===
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.
Category:Computing