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,

_______________________________________________
help-smalltalk mailing list
help-smalltalk@gnu.org
http://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to