MC2


MC2 and MPF31 Jul 2006 10:49 pm

In my first post on MC2, I said Morphtrons have

the ability to act as components and/or containers

But this deserves more attention as the Composite pattern it represents is one of the most important and pervasive patterns in practice because things in the “real” world are always contained and often contain other things. Back in the mid-1980’s the integrated software environment, Framework, written by Xerox PARC alum Robert Carr demonstrated to me that there were significant benefits to orgainizing everything into a hierarchy of objects. Carr won a Profile In Technical Excellence award in 1985 for Framework. One of the benefits of the Framework approach was that there was no notion of “applications” and the degree of interoperability was astounding and still some 20 years later unsurpassed in a number of respects. MC2 brings back the kind of easy interoperability seen in Framework but missing in Smalltalk. Sure if you are a knowledgeable Smalltalker, you can integrate any two solutions but each one tends to be a special case. Often you end up having to gain a deep understanding of an object just to do something relatively simple with it. In some cases you end up having to analyze whether to refactor the class or create a subclass. With Morphtron you can take existing objects and use them together quickly and easily. As a simple example take two tools that come with Squeak the MPEG movie player and Sound Recorder. Suppose you want objects that have movie players which have their own sound recorders:

myMediaRoom:=Object newNamed: ‘myMediaRoom’.
m_(MPEGMoviePlayerMorph newNamed: ‘Movie Player’) openInWorld.
myMediaRoom addComponent: m.
s:=( RecordingControlsMorph newNamed: ‘Sound Recorder’) openInWorld
m addComponent: s.

m fullName ‘/myMediaRoom/Movie Player’
s fullName ‘/myMediaRoom/Movie Player/Sound Recorder’

No refactoring, no new subclasses, just the capabilities you wanted to create from two classes you didn’t author.

Implementation and MC2 and MPF31 Jul 2006 12:27 am

o_Object new.
o getComponents an OrderedCollection()
o getComponentsNamed: ‘boo’ an OrderedCollection()

o componentName ‘an Object’
o componentName: ‘hello’
o componentName ‘hello’

oc_Object newNamed: ‘world’.
o addComponent: oc.
o getComponents an OrderedCollection(an Object)
oc container componentName ‘hello’
oc fullName ‘/hello/world’

props_Dictionary new.
props at: #mySpecialTrait put: ‘is flexibility - hooray Morphtrons!’
op_Object newNamed: ‘h2′ withProperties: props.
op fetchProperty: #mySpecialTrait ‘is flexibility - hooray Morphtrons!’

op_Object newNamed: ‘h2′ withProperties: {#mySpecialTrait. ‘is flexibility - hooray Morphtrons!’}
op fetchProperty: #mySpecialTrait

Implementation and MC2 and MPF31 Jul 2006 12:18 am

The latest version which includes Morphtron Component & Container support is 0.91.7. You can download it in the Squeak directory. Soon updates will be in changeset and/or Monticello packages.

MC2 and MOIST and MOPA and MPF25 Jul 2006 08:39 am

To facilitate implementation and extension, the Morphtron architecture has been modularized into the Morphtron Programming Framework(MPF). The MPF nucleus is known as the Morphtron Object Properties and Accessories(MOPA). A Morphtron object is a collection of named properties. There are two categories of Morphtron properties - Executable and Value, each having two sub-categories Native(as determined by the host language - typically by the class) and Accessory(unique to an instance). MOPA provides the means to create, store and retrieve an object’s properties. Surrounding the Morphtron nucleus is Morphtron Components and Containers(MC2) module which provides objects with the ability to exist in hierarchical relationship to other objects. Another module is called Morphtron Observation Interchange Storage & Transport(MOIST). This is actually a collection of four interrelated sub-modules whose names reflect their function. Each of these modules will be covered in more detail later.