[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-smalltalk] gst-shape
From: |
Paolo Bonzini |
Subject: |
Re: [Help-smalltalk] gst-shape |
Date: |
Mon, 18 Oct 2010 12:05:33 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100907 Fedora/3.1.3-1.fc13 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.3 |
On 10/18/2010 11:42 AM, Gwenaël Casaccio wrote:
Hi,
I would like to announce gst-shape git://github.com/MrGwen/gst-shape.git
a refactoring of the class shape, a small example of the power of this new
refactoring:
This is very nice, thanks. You can also use a branch of smalltalk.git
rather than a fully separate repository. This will make it easier for
me to pull.
However, I wouldn't use class methods. I think it's bad design. It's
better to use a simpler hierarchy and put these on the instance side
using instance variables:
Shape "class methods for mapping integers to ShapeSymbol instance"
VMShape
FixedShape "current NilShape"
IntegerShape "adds #byteSize, #byteSize:"
SignedIntegerShape
UnsignedIntegerShape
FloatingPointShape
CharacterShape
EncodedCharacterShape
UnicodeCharacterShape
ShapeAliasSymbol "abstract class maybe not necessary"
ShapeInherit
ShapeWord
This is because you can use #nextBytes:signed: and #nextPutBytes:of: to
implement dumping. Those methods are private, but we can un-privatize them.
"wrongClassIfFloatOrDoubleShape:" and
"wrongClassIfCharacterOrUtf32Shape:" can be unified to
"checkArgumentClass:".
The "subclassResponsibilityIfCharacterOrUtf32Shape" and
"subclassResponsibilityIfNotCharacterOrUtf32Shape" methods are also bad.
First of all, the former should not be used (it's always using
#ifFalse: in kernel/CharArray.st). Second, I'd anyway use a method
#hasValueAtPrimitives that returns true/false.
Thanks,