[Cuis] Patterns

Dan Norton dnorton at mindspring.com
Tue Dec 8 15:20:12 CST 2015


Hello all,

Minimalist examples of GUI code which take advantage of Cuis are in:

	https://github.com/dhnorton/Cuis-Smalltalk-patterns

The purpose is to compare the Observer Pattern with Dependency Mechanism in a way 
which can aid the programmer. Please take a look and tell me how to make it better.

The Observer Pattern uses #triggerEvent: and #when:send:to: .
The Dependency Mechanism uses #changed: and #update: .

Both philosophies have view separate from model. The Observer Pattern example has two 
views for one model and the Dependency Mechanism example has one for one. These 
examples are referred to as "decoupled" and "coupled".

To emphasize differences in the models, both inherit from AbstractModel so that you can 
readily compare DecoupledModel and CoupledModel.

Run the example in AnotherView class #twoViews to see interactions in two views on one 
model.

Please let me know if this will help someone learning Cuis.

 - Dan

On 18 Nov 2015 at 13:54, Juan Vuletich wrote:

> On 18 Nov 2015 at 11:00, Juan Vuletich wrote:
> 
> > Hi Dan,
> > 
> > On 11/18/2015 12:01 AM, Dan Norton wrote:
> > > The repo now contains two pairs of classes: coupled and
> decoupled.
> > As it stands, the
> > > coupled example comes up the same, whether from the World->New
> > morph... menu or from
> > > a Browser or Workspace.
> > >
> > > The decoupled example does not do this and I don't know what
> to
> > have in the pattern to
> > > avoid the following pitfalls:
> > >
> > > follow the BrowserWindow class #openBrowser and get MNU: owner
> > > follow the ColorEditorPanel class #initializedInstance and get
> > wrong color subMorphs
> > >
> > >   - Dan
> > 
> > This is much nicer, thanks! To make the BrowserWindow style
> work,
> > all 
> > you have to do is to have #open answer the new instance (instead
> of
> > the 
> > class). 
> 
> Beautiful, Now #initializedInstance is just:
> 
> ^ self open
> 
>  - Dan






More information about the Cuis mailing list