<br><font size=2 face="sans-serif">Hi Stéphane,</font>
<br>
<br><font size=2 face="sans-serif">Yes, I ***really*** do think that the Collection hierarchy is a &quot;toy&quot; example. &nbsp;Allow me to explain why:</font>
<br>
<br><font size=2 face="sans-serif">What was done with the Collection hierarchy was essentially a refactoring to use Traits. &nbsp;It wasn't a new design from requirements. &nbsp;And while the Collection hierachy is a fabulous and powerful invention, it is really just a bunch of generic components to be used in building more complex systems.</font>
<br>
<br><font size=2 face="sans-serif">My point was that I don't think that the capabilities Traits offers matches up with the way that commercial software is created in the &quot;real&quot; world.</font>
<br>
<br><font size=2 face="sans-serif">I work on a product that is built from over ten thousand source files and has hundreds of developers working on it. &nbsp;The system runs on at least 8 different target CPU's (obviously, not all of the code runs on all eight different CPU types), and includes code written in C, C++, Java, JavaScript, Pascal, various assembly languages, and includes over 300 megabytes of executable code. &nbsp;I am not commenting on the quality of code, only the quantity here. &nbsp;The quality level of the code by any objective standards varies widely, depending on the skill and experience of the people who worked on it and the other constraints placed on the development (i.e. if we can't demonstrate the new feature to an important customer by the end of the (pick some time interval - quarter, month, week, etc.) we will lose a sale worth millions to an evil competitor).</font>
<br>
<br><font size=2 face="sans-serif">I think what I am describing here is how a lot of software gets created in the real world, and in this kind of environment the code never gets past the &quot;make it work&quot; stage. &nbsp;&quot;It works - ship it, and get on to the next thing&quot; tends to be the approach. &nbsp;My point is that common behavior that COULD be reused and benefit from Traits is not usually identified until quite late in the game, after a lot of code has already been written, if it can be identified at all.</font>
<br>
<br><font size=2 face="sans-serif">The other idea that I was trying to get across is that code reuse is a double-edged sword. &nbsp;While it can reduce maintenance effort, and improve the overall quality of a code base, it also makes the codebase more brittle by introducing heavily loaded single points of failure.</font>
<br>
<br><font size=2 face="sans-serif">So I guess I am raising a largely philosophical issue. &nbsp;As I understand it, Traits facilitates code reuse in ways that would be difficult if at all possible with a single inheritance class hierarchy. &nbsp;This capability comes at the cost of an extra layer of complexity (or degree of freedom, if you prefer) and possibly a decrease in performance. &nbsp;The philosophical questions are how can I use it, and how will I benefit from having used it?</font>
<br>
<br><font size=2 face="sans-serif">The Collection hierarchy example shows that I can implement 27 classes with 48 Traits, saving about 10% in the number of methods. &nbsp;This says to me that there was only an average of 2 or 3 methods per class that were redundant or refactorable &nbsp;(Given that we end up with 567 methods, this implies 630 methods in the original implementation, so we eliminated about 63 methods). &nbsp;So, in this respect I don't think that the Collection hierachy is a very strong example for showing the benefits of Traits. &nbsp;You had my attention more with the RectangleMorph example. &nbsp;There you were going to save 70 methods with only 3 classes involved.</font>
<br>
<br><font size=2 face="sans-serif">Admittedly, the paper that is dedicated to the Traits based Collection class hierarchy goes into more detail and shows a greater savings in method count, but I am not sure if I agree that counting (m+h) is legitimate, so I will call it 17.7% instead of 28.2%.</font>
<br>
<br><font size=2 face="sans-serif">I did read the papers, but like many good papers they generate at least as many questions as answers. &nbsp;Traits is very &quot;blue plane&quot; stuff and therefore interesting, but we've had single inheritance for over thirty years, and most of the world still doesn't take advantage of the capability that it brings. &nbsp;I approach Traits with trepidation because it offers another way to do things and I do think there is such a thing as too much flexibility. &nbsp;That was/is one of the major problems with C++.</font>
<br>
<br><font size=2 face="sans-serif">So I guess I'm still looking for somebody to show me the &quot;good-ness&quot; of Traits, because so far it looks interesting, but like a lot of work for a small increase in code reuse and a (hopefully) small decrease in performance, and we've been seeing a &quot;small&quot; decrease in performance with each successive version of Squeak for way too long now. &nbsp;This is (of course), only my opinion. &nbsp;I could certainly be in the minority here.</font>
<br>
<br><font size=2 face="sans-serif">Traits shows clear value in refactoring, but refactoring is &quot;code cleaning&quot;, and it doesn't happen much in the real world. &nbsp;In fact, it is sometimes &quot;forbidden&quot; because it is seen as a high risk to touch code that is &quot;field proven&quot;.</font>
<br>
<br><font size=2 face="sans-serif">So for now I will sit back, watch, and try to learn something.</font>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -Dean</font>
<br>
<br>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td>
<td><font size=1 face="sans-serif"><b>stéphane ducasse &lt;ducasse@iam.unibe.ch&gt;</b></font>
<br><font size=1 face="sans-serif">Sent by: squeak-dev-bounces@lists.squeakfoundation.org</font>
<p><font size=1 face="sans-serif">08/30/2005 09:37 AM</font>
<br><font size=1 face="sans-serif">Please respond to The general-purpose Squeak developers list</font>
<br>
<td><font size=1 face="Arial">&nbsp; &nbsp; &nbsp; &nbsp; </font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; To: &nbsp; &nbsp; &nbsp; &nbsp;The general-purpose Squeak developers list &lt;squeak-dev@lists.squeakfoundation.org&gt;</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; cc: &nbsp; &nbsp; &nbsp; &nbsp;</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; Subject: &nbsp; &nbsp; &nbsp; &nbsp;Re: Traits approaching mainstream Squeak</font></table>
<br>
<br>
<br><font size=2 face="Courier New">Hi dean<br>
<br>
do you ***really*** think that the Collection hierarchy is a toy &nbsp;<br>
example....<br>
I'm not sure that we are talking about the same.<br>
<br>
On 30 août 05, at 02:28, Dean_Swan@Mitel.COM wrote:<br>
<br>
&gt;<br>
&gt; While I find all this discussion fascinating, I would like to share &nbsp;<br>
&gt; a few thoughts on the idea of including Traits in mainstream Squeak.<br>
&gt;<br>
&gt; My first concern is performance. &nbsp;Since Traits carry no state, they &nbsp;<br>
&gt; will need to use accessor methods and message sends are clearly &nbsp;<br>
&gt; much slower than direct instance variable access.<br>
&gt;<br>
&gt; My second concern is regarding how Traits should/could/would be &nbsp;<br>
&gt; used. &nbsp;All of the examples that I have seen so far, including the &nbsp;<br>
&gt; refactoring of the Collection hierarchy, seem to me to be &quot;toy&quot; &nbsp;<br>
&gt; problems. &nbsp;I would be interested to read about non-trivial cases &nbsp;<br>
&gt; where Traits would solve a significant real world problem.<br>
&gt;<br>
&gt; It would seem to me that the kind of reuse that Traits enables is &nbsp;<br>
&gt; the kind that isn't apparent at design time, since individual &nbsp;<br>
&gt; classes of object are usually designed separately and often by &nbsp;<br>
&gt; completely different people. &nbsp;The common behavior and opportunity &nbsp;<br>
&gt; for code reuse might only become apparent after the initial design &nbsp;<br>
&gt; is implemented. &nbsp;It has been my experience that once something is &nbsp;<br>
&gt; implemented and working, unless there is a compelling reason to &nbsp;<br>
&gt; justify it, the code is never revisited. &nbsp;Management is generally &nbsp;<br>
&gt; focused on allocating resources to things that will yield either an &nbsp;<br>
&gt; opportunity for increased revenues, or reduced costs, and code &nbsp;<br>
&gt; &quot;cleaning&quot; is rarely viewed as either. &nbsp;If it ever gets done (code &nbsp;<br>
&gt; cleaning), it is usually silently piggybacked on required bug fixes &nbsp;<br>
&gt; by individual developers who feel it is important. &nbsp;Am I in the &nbsp;<br>
&gt; minority here, or is this how commercial software development works &nbsp;<br>
&gt; in general?<br>
<br>
<br>
Cleaning your design does not solve the problem that traits solve.<br>
Read the papers. Sometimes we are forced to duplicate code or to &nbsp;<br>
write a lot of delegate methods just because we cannot simply reuse<br>
method dictionary. This is what traits are about.<br>
<br>
&gt; I would even suggest that single inheritance doesn't get used that &nbsp;<br>
&gt; much in practice. &nbsp;I see an awful lot of C++ where classes are root &nbsp;<br>
&gt; classes and implement a singleton object. &nbsp;I see poly-morphism used &nbsp;<br>
&gt; a lot, but not much inheritance. &nbsp;I also see STL used a lot to get &nbsp;<br>
&gt; common syntax container objects, that you get with the standard &nbsp;<br>
&gt; Smalltalk Collection hierarchy anyway.<br>
&gt;<br>
&gt; So I guess I don't see what Traits gets us that we can't already do &nbsp;<br>
&gt; in Squeak with some judicious use of proxies, DNU and separate &nbsp;<br>
&gt; &quot;behavior only&quot; and &quot;state only&quot; classes using accessors for all &nbsp;<br>
&gt; instance variable access. &nbsp;Is the real benefit in having tools that &nbsp;<br>
&gt; formalize this and make it easy?<br>
&gt;<br>
&gt; Is Traits implemented by just pointing a class's method dictionary &nbsp;<br>
&gt; entries to the approprate seemingly class-less compiled method &nbsp;<br>
&gt; defined in a Trait?<br>
&gt;<br>
&gt; I guess I don't fundamentally oppose including Traits in mainstream &nbsp;<br>
&gt; Squeak, as long as it's still possible to ignore it and it doesn't &nbsp;<br>
&gt; cause a decrease in performance for commonly used objects (i.e. the &nbsp;<br>
&gt; Collection hierarchy). &nbsp;From what I've read in the whitepapers, it &nbsp;<br>
&gt; seems it should be safe and easy to ignore, so the only question I &nbsp;<br>
&gt; guess would be performance.<br>
&gt;<br>
&gt; And lastly I will just say that as others (Andreas) have pointed &nbsp;<br>
&gt; out, maximising code reuse is not always desirable. &nbsp;I can see the &nbsp;<br>
&gt; argument in favor of code re-use to propagate common behavior &nbsp;<br>
&gt; without having to find every duplicated variation, but there is &nbsp;<br>
&gt; also the other side of the argument where a single bug in a common, &nbsp;<br>
&gt; highly reused method can cause a lot of things to break that might &nbsp;<br>
&gt; otherwise work properly.<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -Dean<br>
&gt;<br>
&gt;<br>
<br>
</font>
<br>
<br>
<br>