<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> beginners-bounces@lists.squeakfoundation.org [mailto:beginners-bounces@lists.squeakfoundation.org] <b>On Behalf Of </b>Joseph Alotta<br><b>Sent:</b> Wednesday, May 25, 2016 7:47 PM<br><b>To:</b> beginners@lists.squeakfoundation.org<br><b>Subject:</b> [Newbies] Re: FileDirectory<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'>Hi Ron, <br><br>&gt; Excellent. &nbsp;Remember that you should also look at the super classes for methods. &nbsp;UnixFileDirectory is the instance of “FileDirectory default” but it’s also a subclass of FileDirectory so the methods you can call include UnixFileDirectory and all the methods on the class hierarchy including the methods on FileDirectory. &nbsp;Please see the method categories on FileDirectory that I mentioned. <br><br>Okay, thanks. &nbsp;I tried to do something with that, but I got an error. &nbsp;I think I was trying to use a class method on the instance. <br><br><br>&gt; The question I asked was a bit different. &nbsp;When you ask for the #entries of the instance “FileDirectory default” what class is each file? <br><br>It is an Array of DirectoryEntry objects. <br><br>&gt; By the way, based on the question you asked there is a method on FileDirectory to determine if the file exists before you read it (it’s in the method categories I pointed out to you). &nbsp;What is that method? <br><br>fileExists: <br><br>I see what is happening. &nbsp;I thought the on: method changes the path, like cding a directory. &nbsp;But it gives a new instance. <br><br>&nbsp; &nbsp; &nbsp; &nbsp; <br>dir := FileDirectory default. <br>dir on: '/Users/jja/Desktop’ ==&gt; UnixFileDirectory on '/Users/jja/Desktop' <br>dir fileExists: 'categories.CSV’ ==&gt;false <br>dir pathName ==&gt;'/Users/jja/Desktop/Squeak-4.3-All-in-One.app/Contents/Resources' <br><br>dir := FileDirectory on: '/Users/jja/Desktop’ ==&gt; UnixFileDirectory on '/Users/jja/Desktop' <br>dir pathName ==&gt; '/Users/jja/Desktop' <br>dir fileExists: 'categories.CSV’ ==&gt; true <br><br><br>So on: is the equivalent of new, in that it gives a new instance. <span style='color:#1F497D'><o:p></o:p></span></p><p class=MsoNormal style='margin-bottom:12.0pt'><b><i><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>[Ron Teitelbaum] <o:p></o:p></span></i></b></p><p class=MsoNormal style='margin-bottom:12.0pt'><b><i><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Exactly right.  Notice the on: method on the class side, then look at #on: on the instance side.  This is one of those “ah ha” moments.  Classes create instances so when you see something like: “Class on:” you should automatically notice that the method is being sent to the class side since you are sending the message to the class directly.  This can get confusing if there is a method that results in something like myClass := Class, or when a method calls “self class on:”.  But again when it’s done the variable holds the class itself and you are still sending messages to a class when you use “myClass on:”.  So when you are talking directly to a class the method is on the class side.  Class side method (unless they are like the method above returning a class) usually return instances of the class, so method are now instance side methods.  Returning instances is one of the main uses of class side methods.  Lookup factory methods, abstract factory, and prototype, for a good example of software patterns that creates instances from the class side. Understanding polymorphism is now very important since all methods on the hierarchy are callable (on both the class and instance side).  Even methods that are overridden on a subclass can still be called using “super method”.<o:p></o:p></span></i></b></p><p class=MsoNormal style='margin-bottom:12.0pt'><b><i><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>This is a fundamental piece of learning Smalltalk and not simple to understand, but it is also one of those things that is really easy to learn, and once you do you really don’t think about it anymore.  It just seems natural.  (and when it’s missing in other languages you go yuck!  Why is this so difficult!).  It also means that people that understand it think that it’s simple and natural and may not spend enough time talking about it. </span></i></b><b><i><span style='font-size:11.0pt;font-family:Wingdings;color:#1F497D'>J</span></i></b><b><i><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> <o:p></o:p></span></i></b></p><p class=MsoNormal style='margin-bottom:12.0pt'><b><i><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>One more question for you.  I mentioned returning a newly created instance or a specific class from a class side method.  Can you name another reason why you would write a method on the class side?  Why would it be a good idea to put a method on the class side instead of the instance side?  (a hint for you, I’m thinking of something where nothing is returned. (of course in Smalltalk if nothing is returned you get back self, what I mean is that nothing useful is returned)) Bonus points for 2 or more answers with or without returning something </span></i></b><b><i><span style='font-size:11.0pt;font-family:Wingdings;color:#1F497D'>J</span></i></b><b><i><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>.<o:p></o:p></span></i></b></p><p class=MsoNormal style='margin-bottom:12.0pt'><b><i><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>All the best,<o:p></o:p></span></i></b></p><p class=MsoNormal style='margin-bottom:12.0pt'><b><i><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Ron Teitelbaum </span></i></b><br><br>Thank you, <br><br>Sincerely, <br><br>Joe. <br><br><br><b><i><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p></o:p></span></i></b></p><div class=MsoNormal><hr size=3 width=300 style='width:2.5in' align=left></div><p class=MsoNormal>View this message in context: <a href="http://forum.world.st/FileDirectory-tp4897377p4897418.html">Re: FileDirectory</a><br>Sent from the <a href="http://forum.world.st/Squeak-Beginners-f107673.html">Squeak - Beginners mailing list archive</a> at Nabble.com.<o:p></o:p></p></div></div></body></html>