<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2853" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV>&nbsp;<A title=alemartinez2112@gmail.com 
href="mailto:alemartinez2112@gmail.com">Alejandro Martínez</A><FONT face=Arial 
size=2>&nbsp; wrote:</FONT><BR></DIV>
<BLOCKQUOTE 
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV>Hello list. I'm searching for the opinion of experienced 
  developers:<BR><BR>In which case do you create specialized class message for 
  instantiating an object?<BR><BR>I think two factors are fundamental:<BR>1) You 
  want to enforce correcteness of your objects by making sure they are complete, 
  so you "minimize" #new and provide specialized messages for creation. <BR>2) 
  You do not want to enforce anything until real usage experience shows you 
  which messages you must "promote" to the class side.<BR></DIV></BLOCKQUOTE>
<DIV><FONT face=Arial size=2>Point 1 is indeed fundamental: Specialized instance 
creation methods are</FONT></DIV>
<DIV><FONT face=Arial size=2>used to create fully initialized instances. 
Beautiful examples of that</FONT></DIV>
<DIV><FONT face=Arial size=2>approach can be found mainly in the old parts of 
Squeak. Have a</FONT></DIV>
<DIV><FONT face=Arial size=2>look e.g. at</FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp; PluggableListView<BR>&nbsp;&nbsp; 
PluggableButtonView<BR>&nbsp; &nbsp;PluggableTextView<BR>&nbsp; 
&nbsp;PopUpMenu<BR>&nbsp; &nbsp;SelectionMenu</FONT></DIV>
<DIV><FONT face=Arial size=2>or at classes Browser&nbsp; and 
Inspector.</FONT></DIV>
<DIV><FONT face=Arial size=2>PluggableListView has one general class method that 
creates</FONT></DIV>
<DIV><FONT face=Arial size=2>a fully initialized instance. That method is also 
sent by two</FONT></DIV>
<DIV><FONT face=Arial size=2>simpler class methods that provide reasonable 
default values</FONT></DIV>
<DIV><FONT face=Arial size=2>for unneeded features of an instance.</FONT></DIV>
<DIV><FONT face=Arial size=2>In PopUpMenu&nbsp;a general class method is 
#labelArray:lines:</FONT></DIV>
<DIV><FONT face=Arial size=2>its simplified variant is #labelArray:</FONT></DIV>
<DIV><FONT face=Arial size=2>All the classes that I just&nbsp;mentioned provide 
both general</FONT></DIV>
<DIV><FONT face=Arial size=2>and specialized class methods for instance 
creation.</FONT></DIV>
<DIV><FONT face=Arial size=2>That approach is, in my opinion, an example of 
careful</FONT></DIV>
<DIV><FONT face=Arial size=2>class design that </FONT><FONT face=Arial 
size=2>should be followed. I agree however</FONT></DIV>
<DIV><FONT face=Arial size=2>that some additional work is needed to find out 
required</FONT></DIV>
<DIV><FONT face=Arial size=2>initial values and suitable default values for 
features</FONT></DIV>
<DIV><FONT face=Arial size=2>that are not always needed.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Additional remark: In the absence of other 
documentation</FONT></DIV>
<DIV><FONT face=Arial size=2>a set of specialized instance creation method helps 
you to</FONT></DIV>
<DIV><FONT face=Arial size=2>understand how you should use a class. At times 
this can</FONT></DIV>
<DIV><FONT face=Arial size=2>be very helpful.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Second additional remark:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;myClass new</FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp; initVariable1: 
&lt;anExpression1&gt;;</FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp; initVariable2: 
&lt;anExpression2&gt;;</FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp; initVariable3: 
&lt;anExpression3&gt;.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>is of course possible, but it does not </FONT><FONT 
face=Arial size=2>surpass the</FONT></DIV>
<DIV><FONT face=Arial size=2>quality of code that is generated </FONT><FONT 
face=Arial size=2>by simple tools.</FONT></DIV>
<DIV><FONT face=Arial size=2>As we are not code generators we should 
perhaps</FONT></DIV>
<DIV><FONT face=Arial size=2>try to do better.&nbsp; :-)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Greetings,</FONT></DIV>
<DIV><FONT face=Arial size=2>Boris</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV></BODY></HTML>