GNOME-MouseTrap/mousetrap — pull request #14 by StoneyJackson (2014-06-19 23:54:09+00:00)
Title: Stoney2

New core architecture.

main.py had too many reasons to change. It was responsible
for instantiating all system components and passing messages
between compoents. So, anytime a new component was added or
a change in there interaction was desired, main.py had to
be changed in non-trivial ways.

main.py needs to provide a stable, predictable platform on
which to build new features.

New classes

mousetrap.main.App
mousetrap.main.Loop
mousetrap.main.Observable
mousetrap.main.parts.interface.Part

App - Provides shared state among Parts eliminating the need
for Main to pass messages between Parts.

Loop - Drives the application calling run() on each Part each
pass of the loop. It is the observable in an observer
pattern with Parts as observers. Use of the observer
pattern means that Loop does not need to know the
details of each specific Part.

Observable - Provides implementation of observable in the
observer pattern.

Part - The interface each part must implement.

To implement a new Part:

1. Implement the Part (e.g., see mosuetrap.parts.eyes).
2. Add part description to DEFAULT_PARTS in main.py.

This second step will go away when DEFAULT_PARTS is
converted to a configuration file in a future commit.