<br><br>
<div><span class="gmail_quote">On 5/1/06, <b class="gmail_sendername">SmallSqueak</b> <<a href="mailto:smallsqueak@rogers.com">smallsqueak@rogers.com</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">About adding methods to existing classes ....<br><br> Is this a rule, that I have to add methods to existing classes?
<br> Would you please explain why it is a good thing.</blockquote>
<div> </div>
<div>You don't have to, but you can. You can't do it in C++ or Java. It is a good thing because sometimes when you want to extend a system, you want old objects to interact well with new objects, and it is easier if you can add methods to old objects. And I really mean "old objects" and not just "old classes", though of course that is included.
</div>
<div> </div>
<div>Suppose you want to add a new kind of tool to the system, one that helps you debug objects. You want to be able to send a message "debug" to every object. You can add a default "debug" method to class Object and override that method in classes that need a different implementation.
</div><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"> What if the authors of the existing classes don't want<br> anything added to their classes?</blockquote>
<div> </div>
<div>When you publish the source code to something, it is a gift to the world. The world can do what it wants with it. If you think the world is better off without adding methods to a particular class, by all means write a comment to that effect. But you might be wrong, and the world will show you by adding methods anyway.
</div><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">> Just focus on Collection classes and numbers.<br><br> I like to ignore these as well.</blockquote>
<div> </div>
<div> </div>
<div>I think this is a mistake. The collection classes are very important. They are also great examples of well-designed Smalltalk classes.</div>
<div> </div>
<div>-Ralph Johnson</div><br> </div>