<div dir="ltr">Thank you SO MUCH for the tips! That worked perfectly.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jun 1, 2024 at 6:50 PM Hernán Wilkinson <<a href="mailto:hernan.wilkinson@10pines.com">hernan.wilkinson@10pines.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">Hi Mark,<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jun 1, 2024 at 8:23 PM Mark Volkmann via Cuis-dev <<a href="mailto:cuis-dev@lists.cuis.st" target="_blank">cuis-dev@lists.cuis.st</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Just getting started with Smalltalk ...<div><br></div><div>I defined the class <font face="monospace">VRectangle</font> as follows:</div><div><br></div><div><font face="monospace">Object subclass: #VRectangle<br> instanceVariableNames: 'height width'<br> classVariableNames: ''<br> poolDictionaries: ''<br> category: 'Playground'</font></div><div><br></div><div>Then I added the class method height:width: like this:</div><div><br></div><div><font face="monospace">height: aHeight width: aWidth<br> | r |<br> r := self basicNew.<br> r height: aHeight.<br> r width: aWidth</font></div></div></blockquote><div><br></div><div>Good! I would make some changes, instead of sending basicNew just send new. The message basicNew is there is case you override new, it is not common to use it.</div><div>I would also create an initialization message on the instance side, so you do not need to have setters and communicate the idea that a Rectangle is immutable </div><div>And the error you are having is because you are not returning r, and when there is no explicit return, self is returned that in this case is VRectable class (that is the class, not an instance of it).</div><div>Therefore, I would implement that message this way:</div><span style="font-family:monospace">height: aHeight width: aWidth</span><br style="font-family:monospace"><span style="font-family:monospace"> </span></div><div class="gmail_quote"><span style="font-family:monospace"> ^self new initializeHeight: aHeight width: aWidth</span></div><div class="gmail_quote"><span style="font-family:monospace"> </span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div>Then I added these instance methods:</div><div><br></div><div><font face="monospace">height: aNumber<br> height := aNumber</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">width: aNumber<br> width := aNumber</font></div></div></blockquote><div><br></div><div>No need for these with my suggestion, just:</div><div><span style="font-family:monospace">initializeHeight: aHeight width: aWidth</span></div><div> height := aHeight.</div><div> width := aWidth</div><div><br></div><div>Doing, as I said above, you are sending the message that instances of VRectangle are immutable. Of course they are not really because the initializeHeight:... can be sent and change the instance, but culturally you are suggesting is immutable and initialization messages should only be sent from the class side when instantiating a class (also a cultural heuristics).</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><font face="monospace"><br clear="all"></font><div><font face="monospace">area<br> ^ height * width</font><br></div><div><br></div><div>Then in a Workspace I did this:</div><div><br></div><div><font face="monospace">r := VRectangle height: 2 width: 3.<br>r area.</font><br></div><div><br></div><div>I get <font face="monospace">MessageNotUnderstood</font> from the last line, but I don't understand why.</div></div></div></blockquote><div><br></div><div>That is you forgot the ^r in the instance creation message.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div>I can inspect <font face="monospace">r</font> and it looks good.</div></div></div></blockquote><div><br></div><div>You should be seeing the class, not the instance... </div><div>Return r or implemente that message with my suggestion and it should work fine.</div><div><br></div><div>Cheers!</div><div>Hernan. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><font face="arial, helvetica, sans-serif">R. Mark Volkmann</font></div><div><span style="font-size:12.8px"><font face="arial, helvetica, sans-serif">Object Computing, Inc.</font></span></div></div></div></div></div></div></div></div></div></div>
-- <br>
Cuis-dev mailing list<br>
<a href="mailto:Cuis-dev@lists.cuis.st" target="_blank">Cuis-dev@lists.cuis.st</a><br>
<a href="https://lists.cuis.st/mailman/listinfo/cuis-dev" rel="noreferrer" target="_blank">https://lists.cuis.st/mailman/listinfo/cuis-dev</a><br>
</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div style="font-size:small"><div dir="ltr"><div dir="ltr"><div style="font-size:12.8px"><span style="font-family:tahoma,sans-serif;font-size:xx-small;border-collapse:collapse"><strong><span style="font-size:8pt"><span style="font-size:small"><font size="2"><span style="font-weight:normal"><span style="font-weight:bold">Hernán Wilkinson</span><br>Agile Software Development, Teaching & Coaching</span></font></span></span></strong></span></div><div style="font-size:12.8px"><span style="font-family:tahoma,sans-serif;font-size:xx-small;border-collapse:collapse"><strong><span style="font-size:8pt"><span style="font-size:small"><font size="2"><span style="font-weight:normal">Phone: +54-011</span></font></span></span></strong></span><font face="tahoma, sans-serif" size="2">-4893-2057</font></div><div style="font-size:12.8px"><strong style="font-family:tahoma,sans-serif;font-size:xx-small"><span style="font-size:8pt"><span style="font-size:small"><font size="2"><span style="font-weight:normal">Twitter: @HernanWilkinson</span></font></span></span></strong></div><div style="font-size:12.8px"><span style="font-family:tahoma,sans-serif;font-size:xx-small;border-collapse:collapse"><strong><span style="font-size:8pt"><span style="font-size:small"><font size="2"><span style="font-weight:normal">site: <a href="http://www.10pines.com/" style="color:rgb(17,65,112)" target="_blank">http://www.10Pines.com</a></span></font></span></span></strong></span></div><div style="font-size:12.8px"><font face="tahoma, sans-serif"><span style="border-collapse:collapse">Address: Alem 896</span></font>, Floor 6, Buenos Aires, Argentina</div></div></div></div></div></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><font face="arial, helvetica, sans-serif">R. Mark Volkmann</font></div><div><span style="font-size:12.8px"><font face="arial, helvetica, sans-serif">Object Computing, Inc.</font></span></div></div></div></div></div></div></div></div>