<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><DIV>So, last night, having been fighting Morphic for about 5 hours (trying to write a really, really simple example for my first class), I was about to write a flame "why I hate Morphic and what we should do about it".  But I went to sleep instead.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>And now I notice this from Jerome:</DIV><BR><DIV><DIV>On 2 Jan 2007, at 6:33, Milan Zimmermann wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">On 2006 December 29 01:27, Jerome Peace wrote:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&lt;&lt;snip&gt;&gt;</DIV> <BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Many of the deep bugs I run into have the</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">TransformationMorph decorator as their root.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Lots of the gribble leaving problems come from a</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">mismatch of assumptions between TfMorph ( which</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">believes you can translate the origin into the 3rd</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">quadrant) while every body else believes that truncate</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">is the same as floor<SPAN class="Apple-converted-space">  </SPAN>because all points are in the</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">1st quadrant. Clipping boxes get calculated wrong and</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">are often of by one just when you need them not to be.</DIV> </BLOCKQUOTE><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Jerome,</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Could you point out a few concrete examples (class, method) of this behaviour?<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">I started work on a (exteremely limited) set of tests for etoys and morphic,<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">and perhaps it would make sense to document what you found in a test;<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">although documenting something that is (if I understand) considered broken<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">may not be as valuable,<SPAN class="Apple-converted-space">  </SPAN>it should be easy to convert the test code if/once<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">the code under test is refactored.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Thanks Milan</DIV></BLOCKQUOTE></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Transformations are indeed the core of the problem.  It has often seemed to me that all morphs should be able to take care of their own transformations, rather than having to be embedded in a TransformationMorph.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Last night, I was trying to do a Morphic version of Adele Goldberg's "Joe the Box" as presented in Mark Guzdial's book.  Because I have had students really confused by TransformationMorphs (which break the rule that every Morph is visible on the screen), I made a "BoxMorph" just a subclass of PolygonMorph with four vertices.  This worked pretty well, except that rounding errors accumulate as you rotate the box; I couldn't think of a simple solution to that.  Then I did NamedBoxMorph, which puts a text morph containing the Box's name (joe, jill, etc) in the center of the Polygon.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Well, as you rotate the Box, the text inside does _not_ rotate.  This is not what I expect from embedded submorphs.  It turns out that there is no code in PolygonMorph to rotate the submorphs.  I think that this is a bug, but writing the code involves more than I know.  (I did try.  Applying a MorphicTransformaiton to a point is easy, but applying it to a Morph --- that I couldn't figure out.)</DIV><DIV>Also, as you rotate the PolygonMorph, and morph at its center refuses to stay at the center.  It "precessses" towards the origin and back.  Try it.  (My code is in a publicly readable SqueakSource project at <A href="http://www.squeaksource.com/PSUCS520">http://www.squeaksource.com/PSUCS520</A> .  The package is called <FONT class="Apple-style-span" color="#0030EE"><SPAN class="Apple-style-span" style="text-decoration: underline; ">CS520-MorphicBoxes</SPAN></FONT>).</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>So I gave up, and tried a different approach, which I have used previously.   I made a BoxMorph2 a TransformationMorph, with a RectangleMorph inside it.  Both of them the same size.   Easy to set up, right?  Just give them the same bounds.  Wrong.  Even before they are in any world, the TransformationMorph has resized itself and has changed it's scale factor to 1.7  I'm reduced to trial and error to find an initialization sequence that works.  But when I find one, the BoxMorph2 can indeed be rotated.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Then I put a TextMorph in the center  (myBoxMorph2 addMorphCentered: aTextMorph).  All hell breaks loose.  The  label is a couple of inches down and to the right of the box.  blue-clicking on the box puts the halo around the label.  I spend a long time looking for this bug, and find somewhere in the re-computation of the bounds that fullbounds of the BoxMorph2 has grown by a factor of 2 to 3 (but different factors  in the x and y directions).   I'm supposed to explain this to studnets when I have no idea waht is going on myself.  What did Dan Ingalls write about "personal mastery?"</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I eventually get it working by embedding the TextMorph inside the RectangleMorph (which is inside the Transformation Morph).  Why does it work this way around and not the other way?  Beats me.  The code is ugly because I use findA: to get hold of the internal RectangleMorph.  (So, later I did see the comment that says: "TransformationMorphs are assumed to have only one submorph".  If that's true, maybe one should get an error when an attempt is made to add a second one?)</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I keep on thinking that Morphic is really elegant and that all of this will one day make sense if only I can learn to squint in the right way.  But I'm seriously beginning to wonder ... </DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>The good news is that the final code is really short and sweet, comparing well with the "draw on the raw screen" version that mark Guzdial puts in his book (Package "Boxes" in the same SqueakSource project, if you care to look).  The bad news is that it is extremely brittle.  I liek telling students to play with stuff an see what happens, and then to figure out why.  I get the feeling that changing the order of two statements in this code might just as well precipitate the next revolution as change the stacking order of two Morphs ... and I have _no idea_ why.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>OK, so now I'm just venting.   But I would really like to know if I'm the only one who feels this way.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>What to do about it?  I think that getting rid of TransformationMorphs as wrappers (they are not really decorators, because they are not inserted into the Morphic hierarchy until something needs to be transformed) would help, and instead giving each Morph the ability to transform itself.  This would involve a test, of course: myTransformation ifNotNi: [ ... ] which is a tad ugly.  This is similar to what was done with Alignment a while back --- giving every Morph the ability to align its submorphs.  (However, I think that that change may have been a mistake; adding a separate allignmentMorph to the hierarchy makes much more sense to me than adding a separate TransformationMorph.  Moreover, we know that any 2-D affine transformation can be represented as a 3 x 2 matrix, so there can be a single universal implementation of transformations</DIV><DIV><BR class="khtml-block-placeholder"></DIV><BR><DIV> <SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><DIV>Andrew P. Black</DIV><DIV>Department of Computer Science</DIV><DIV>Portland State University</DIV><DIV>+1 503 725 2411</DIV><DIV><BR class="khtml-block-placeholder"></DIV><BR class="Apple-interchange-newline"></SPAN> </DIV><BR></BODY></HTML>