[squeak-dev] The Inbox: Graphics-cbc.372.mcz

H. Hirzel hannes.hirzel at gmail.com
Thu Mar 30 04:51:08 UTC 2017


Hi

Eliot's argument is convincing for me and I suggest that the change
should be added to the trunk as is.

Adding another subclass just because of one method does not make sense though.

--Hannes

---------------------------------------------------------------------------------------------------------------------------------

Name: Graphics-cbc.372
Author: cbc
Time: 28 March 2017, 5:18:09.019402 pm
UUID: 7b9783b1-87c5-3549-ac32-42acd6abcb12
Ancestors: Graphics-eem.371

Added method to allow creating a rectangle based on teh center of the rectangle.

=============== Diff against Graphics-eem.371 ===============

Item was added:
+ ----- Method: Rectangle class>>exactCenter:extent: (in category
'instance creation') -----
+ exactCenter: centerPoint extent: extentPoint
+       "Answer an instance of me whose center is centerPoint and width
+       by height is extentPoint. "
+       ^ self origin: centerPoint - (extentPoint / 2) extent: extentPoint
+ !

On 3/29/17, Chris Cunningham <cunningham.cb at gmail.com> wrote:
> Hi.
>
> On Wed, Mar 29, 2017 at 12:58 PM, Eliot Miranda <eliot.miranda at gmail.com>
> wrote:
>
>> Hi Hannes,
>>
>> On Wed, Mar 29, 2017 at 8:45 AM, H. Hirzel <hannes.hirzel at gmail.com>
>> wrote:
>>
>>> Hi Chris,
>>>
>>> On 3/29/17, Chris Cunningham <cunningham.cb at gmail.com> wrote:
>>> > Hi,
>>
>> <snip>
>
>
>> The kind of thinking which restricts the system, such as adding methods
>>> that logically belong to SequenceableCollection to, say, String, simply
>>> because the programmer wanted a String method and didn't think about
>>> generality, is at best regrettable.
>>
>> I've been guilty of this in the past, and probably will in the future,
>> but
> I try not to be.
>
>>
>>
>>
>> > A better question is should I be using Rectangle for this.  Maybe we
>>> should
>>> > create a 'TrueRectangle' class or something similar so that we can
>>> actually
>>> > talk about and share what can really be done with rectangles, instead
>>> > of
>>> > the 'ScreenRectangle' that we have today called Rectangle.
>>>
>>
>> Why not the other way around? Add IntegralRectangle and have it
>> specialize
>> Rectangle.
>>
>>
> Let me re-state what I think you are saying, and please correct me if I am
> wrong.
>
> Make Rectangle more generic, and for instance, have the method
> #center:extent: use #/ instead of #//.
> Then, have a new class, IntegralRectangle, that re-implements that method
> and sends #// to ensure that the extents are integral.
> (and in general do whatever else is needed to relax Rectangle, and tighten
> up IntegralRectangle).
>
> Right?
>
> If so, the main reason not to do proceed is that Rectangle is used
> extensively in the system for today, and we'd have to replace those uses
> with IntegralRectangle, not to mention all of the indirect uses (such as
> #corner: that you used above, and make variants creating IntegralRectangle
> and generic Rectangle, or otherwise resolve those ambiguities).
>
> That said, I'm all for it.  I'd like a less strict Rectangle for, well,
> Rectangle uses.
>
> As a side note, if you look up Integral Rectangle in Google, you'll fine
> lots of discussions that have nothing to do with this question.  But
> Integral (integer) and Rectangle make perfect sense here in any case.
>
> -cbc
>


More information about the Squeak-dev mailing list