<!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">
On 4/28/2019 8:45 PM, Phil B wrote:
<blockquote
cite="mid:CAMJMOegiYfUXq77ocvAohDtRrAvY=Zo23xjm_fAwPh+4AVp0Hw@mail.gmail.com"
type="cite">
<div dir="ltr">
<div dir="ltr">Juan,</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Sun, Apr 28, 2019 at 6:48
PM Juan Vuletich <<a moz-do-not-send="true"
href="mailto:juan@jvuletich.org">juan@jvuletich.org</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin: 0px 0px 0px
0.8ex; border-left: 1px solid rgb(204, 204, 204);
padding-left: 1ex;">Hi Phil,<br>
<br>
On 4/28/2019 2:20 PM, Phil B via Cuis-dev wrote:<br>
> I was reading a thread going on over on pharo-dev about
Color and <br>
> thought it was apropos for us. Many of the more
commonly used <br>
> instance methods (#lighter, #darker, #alpha: etc.) are
named as if <br>
> they were accessors or actions which would most
naturally be assumed <br>
> to modify the current color but actually create a new
color. If you <br>
> work with Color to any extent the current behavior is
accepted as <br>
> normal since it is quasi-immutable, but this
naming/behavior impedance <br>
> mismatch does seem pretty obvious when you think about
it. Perhaps we <br>
> should think about modifying these method names to
better reflect what <br>
> they are actually doing? (and perhaps make Color more
explicitly <br>
> immutable?)<br>
<br>
I think that `Color red darker` makes perfect sense. No one
should think <br>
that it takes "red" and turns "all red" into "dark red". It
should be <br>
understood as 'just something like red, but darker'.<br>
<br>
</blockquote>
<div><br>
</div>
<div>Yes, but only if you're used to working with Color. If
you think about it relative to other classes it's actually
pretty weird: the normal Smalltalk way of thinking would be
that Color red returns a (new) red color, not a singleton
instance. (which I think is the crux of why the
implementation seems odd: it's neither a true singleton nor
an immediate but has a bit of feel from both) If you had
another (non-Color) object instance, it would be reasonable
to expect #darker to make just that instance darker, not all
instances or to return a new instance. So yes, you get used
to it if you're used to Color... but it is rather different
behavior from most of the rest of the system.</div>
<div> </div>
<blockquote class="gmail_quote" style="margin: 0px 0px 0px
0.8ex; border-left: 1px solid rgb(204, 204, 204);
padding-left: 1ex;">
#alpha: is wrong, because it really looks like a setter, but
Colors are <br>
(at least conceptually) immutable. You can not turn red into
something <br>
else, in the same way you can not turn 7 into something
else. #alpha: <br>
should be renamed #withAlpha:, so you can write `Color red
withAlpha: <br>
0.5` that does make sense. Same with #adjustBrightness: and
<br>
#adjustSaturation:brightness:.<br>
<br>
</blockquote>
<div><br>
</div>
<div>That was pretty much the point being made: rename the
methods so it's clear that they are returning a new color
rather than modifying the current one. (i.e. the issue is
the naming, not the underlying implementation)</div>
</div>
</div>
</blockquote>
<br>
Maybe we could add a 'but' prefix. For example `Color red
butDarker`. Would that sound better?<br>
<br>
<blockquote
cite="mid:CAMJMOegiYfUXq77ocvAohDtRrAvY=Zo23xjm_fAwPh+4AVp0Hw@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_quote">
<div> </div>
<blockquote class="gmail_quote" style="margin: 0px 0px 0px
0.8ex; border-left: 1px solid rgb(204, 204, 204);
padding-left: 1ex;">
WRT making Color immutable... All methods that change state
are marked <br>
as 'private'. What else do you suggest?<br>
<br>
</blockquote>
<div><br>
</div>
<div>Prefixing the setters with #private<whatever> would
be my preference.</div>
</div>
</div>
</blockquote>
<br>
I see. Yes, that would be nicer. But Color already inherits #at: and
#at:put: which we can not rename. In addition we'd need to change
that all over the system for consistency. If my script was correct,
Cuis includes 180 classes with a 'private' method categories. What
I'd like to have is real immutability.<br>
<br>
<blockquote
cite="mid:CAMJMOegiYfUXq77ocvAohDtRrAvY=Zo23xjm_fAwPh+4AVp0Hw@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_quote">
<div><br>
</div>
<div>Anyway, I raised it because I thought it was an
interesting and valid point. I'll leave it to you to decide
what, if anything, makes sense to change.</div>
<div> </div>
<blockquote class="gmail_quote" style="margin: 0px 0px 0px
0.8ex; border-left: 1px solid rgb(204, 204, 204);
padding-left: 1ex;">
Thanks,<br>
<br>
-- <br>
Juan Vuletich<br>
<a moz-do-not-send="true"
href="http://www.cuis-smalltalk.org" rel="noreferrer"
target="_blank">www.cuis-smalltalk.org</a><br>
<a moz-do-not-send="true"
href="https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev"
rel="noreferrer" target="_blank">https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev</a><br>
<a moz-do-not-send="true"
href="https://github.com/jvuletich" rel="noreferrer"
target="_blank">https://github.com/jvuletich</a><br>
<a moz-do-not-send="true"
href="https://www.linkedin.com/in/juan-vuletich-75611b3"
rel="noreferrer" target="_blank">https://www.linkedin.com/in/juan-vuletich-75611b3</a><br>
@JuanVuletich<br>
<br>
</blockquote>
<div><br>
</div>
<div>Thanks,</div>
<div>Phil </div>
</div>
</div>
</blockquote>
<br>
Thanks,<br>
<pre class="moz-signature" cols="72">--
Juan Vuletich
<a class="moz-txt-link-abbreviated" href="http://www.cuis-smalltalk.org">www.cuis-smalltalk.org</a>
<a class="moz-txt-link-freetext" href="https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev">https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev</a>
<a class="moz-txt-link-freetext" href="https://github.com/jvuletich">https://github.com/jvuletich</a>
<a class="moz-txt-link-freetext" href="https://www.linkedin.com/in/juan-vuletich-75611b3">https://www.linkedin.com/in/juan-vuletich-75611b3</a>
@JuanVuletich</pre>
</body>
</html>