shoes/shoes4 — pull request #114 by wasnotrice (2012-08-27 16:12:31+00:00)
Title: Require app as a parameter

I have been running into lots of pain lately as I try to add/modify Art objects (Line, Oval, Arc, etc). Lots of this pain stems from the fact that there is too much coupling between objects. In particular, the Swt objects require a reference to the `Shoes::Swt::App` object. But this object is not passed as an explicit parameter. Rather, it is part of the options hash. This makes it difficult to be sure that it is always included. Plus, since it is **necessary**, passing it as part of an options hash seems somehow wrong.

Also, we have calls to `self.app.gui` sprinkled throughout the code. This call is necessary to pull out the `Shoes::Swt::App` and pass it along, but it is everywhere, which makes change difficult and confusing.

This commit shows how we might move to using an explicit `app` parameter. Changes include

* Requiring `app` as a parameter to `Shoes::Arc.new`, where `app` is a `Shoes::App`
* Requiring `app` as a parameter to `Shoes::Swt::Arc.new`, where `app` is a `Shoes::Swt::App`
* Confining the "reaching into" a `Shoes::App` to a single spot, in the backend generator, in `Shoes::Configuration`.
* Removing all "border-crossing" in `Shoes::Arc` and `Shoes::Swt::Arc` with respect to `app`. Now, there is no confusion about which "app" we are using. In `Shoes::Arc` it is always a `Shoes::App`; in `Shoes::Swt::Arc` it is always a `Shoes::Swt::Arc`
* Removing the `:app => app` key/value from the options hash generated in ElementMethods#arc. Note that this is included in **every** element method, so it is ripe for extraction.

I propose making this change on all of the art classes. I feel like, for consistency, we should also make the change on the "native" classes like Button, etc., and on the text classes, too.

Benefits:

* more decoupled code
* simpler tests
* explicit dependencies
* consistent interface
* tricky and highly coupled code is confined in a single location

Drawbacks:

* more complicated constructor signatures
* we pass around app objects **everywhere**

Please comment!