<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    Hi Mark,<br>
    <br>
    On 6/13/2024 9:58 AM, Mark Volkmann via Cuis-dev wrote:
    <blockquote
cite="mid:CAFfRWnVzSRKueiTWr20LF0tup973z82McviPFNXFO_mVgi9Tdw@mail.gmail.com"
      type="cite">
      <div dir="ltr">Suppose I want to define a <font face="monospace">Dog</font>
        class that has the instance variables <font face="monospace">name</font>
        and <font face="monospace">breed</font> and I want the
        instances to be immutable. Is this the recommended way to define
        it?
        <div><br>
        </div>
        <div><font face="monospace">Object subclass: #Dog<br>
                instanceVariableNames: 'breed name'<br>
                classVariableNames: ''<br>
                poolDictionaries: ''<br>
                category: 'MyCategory'</font></div>
        <div><font face="monospace"><br>
          </font></div>
        <div><font face="arial, sans-serif">With this class method:<br>
          </font><br>
          <font face="monospace">name: aName breed: aBreed<br>
                ^self new initializeName: aName breed: aBreed<br
              clear="all">
          </font><br>
          And with these instance methods:</div>
        <div><br class="gmail-Apple-interchange-newline">
          <font face="monospace">initializeName: aName breed: aBreed<br>
                name := aName.<br>
                breed := aBreed<br>
            <br>
            breed<br>
                ^breed<br>
            <br>
            name<br>
                ^name<br>
            <br>
          </font>
          <div>If I want the following to be the only way to create an
            instance:</div>
          <div><br>
          </div>
          <div><font face="monospace">Dog name: 'Comet' breed: 'Whippet'</font></div>
          <div><br>
          </div>
          <div>would I do something to prevent using this?</div>
          <div><br>
          </div>
          <div><font face="monospace">Dog new</font></div>
          <div><br>
          </div>
          <span class="gmail_signature_prefix">-- </span><br>
          <div dir="ltr" class="gmail_signature"
            data-smartmail="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>
    </blockquote>
    <br>
    That looks good. See, for instance Point. In addition to what you
    did, the setter message begins with 'initializePvt'. This gives a
    warning if you try to call it from another class. It is also in a
    method category that clearly says it is private.<br>
    <br>
    If you want additional protection, `Feature require:
    'Immutability'`, and see #beImmutable and #beMutable .<br>
    <br>
    <br>
    Cheers,<br>
    <pre class="moz-signature" cols="72">-- 
Juan Vuletich
cuis.st
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich
linkedin.com/in/juan-vuletich-75611b3
twitter.com/JuanVuletich</pre>
  </body>
</html>