[squeak-dev] The Inbox: Kernel-cmm.761.mcz

Tobias Pape Das.Linux at gmx.de
Fri Jul 5 05:13:41 UTC 2013


Can’t we name that ‘properties’?
I think that ‘attributes’ is too close to the notion of
attributes in general OO design as well as UML. 
These attributes would correspond to our attributes.

Magritte and SqueakSource both provide such properties-bearing
approach; the implementation is similar but does not
(yet) provide the deepcopy stuff; the protocol would be similar
but with ‘at’ instead of ‘named’

Fun fact. Magritte supports descriptions that can access either
 instance variables directly or via accessor, or alternatively,
such a properties dictionary, as long as it is named ‘properties’.


Best 
     -Tobias

Am 05.07.2013 um 07:02 schrieb commits at source.squeak.org:

> A new version of Kernel was added to project The Inbox:
> http://source.squeak.org/inbox/Kernel-cmm.761.mcz
> 
> ==================== Summary ====================
> 
> Name: Kernel-cmm.761
> Author: cmm
> Time: 4 July 2013, 9:01:30.236 pm
> UUID: b9aaab83-9dfc-4c4f-a4e6-203167954cc1
> Ancestors: Kernel-cmm.760
> 
> - Introduce AttributableObject, an abstract class whose subclass instances allow a variable number of attributes to be set and accessed at run time.
> 
> =============== Diff against Kernel-cmm.760 ===============
> 
> Item was added:
> + Object subclass: #AttributableObject
> +    instanceVariableNames: 'attributes'
> +    classVariableNames: ''
> +    poolDictionaries: ''
> +    category: 'Kernel-Models'!
> + 
> + !AttributableObject commentStamp: 'cmm 10/7/2009 21:03' prior: 0!
> + Subclass from this abstract class to inherit an attribute Dictionary.!
> 
> Item was added:
> + ----- Method: AttributableObject>>attributeNamed: (in category 'attributes') -----
> + attributeNamed: aString 
> +    ^ attributes ifNotNil: 
> +        [ attributes 
> +            at: aString
> +            ifAbsent: [ nil ] ]!
> 
> Item was added:
> + ----- Method: AttributableObject>>attributeNamed:put: (in category 'attributes') -----
> + attributeNamed: aString put: anObject 
> +    anObject ifNotNil: [ attributes ifNil: [ attributes := Dictionary new ] ].
> +    ^ anObject
> +        ifNil:
> +            [ self removeAttributeNamed: aString.
> +            anObject ]
> +        ifNotNil:
> +            [ attributes
> +                at: aString
> +                put: anObject ]!
> 
> Item was added:
> + ----- Method: AttributableObject>>attributesToDeepCopy (in category 'copying') -----
> + attributesToDeepCopy
> +    "Subclasses override."
> +    ^ attributes
> +        ifNil: [ Array empty ]
> +        ifNotNil: [ attributes keys ]!
> 
> Item was added:
> + ----- Method: AttributableObject>>removeAttributeNamed: (in category 'attributes') -----
> + removeAttributeNamed: aString 
> +    ^ attributes ifNotNil: 
> +        [ | answer |
> +        answer := attributes 
> +            removeKey: aString
> +            ifAbsent: [ nil ].
> +        attributes ifEmpty: [ attributes := nil ].
> +        answer ]!
> 
> Item was added:
> + ----- Method: AttributableObject>>veryDeepInner: (in category 'copying') -----
> + veryDeepInner: aDeepCopier 
> +    super veryDeepInner: aDeepCopier.
> +    attributes := attributes copy.
> +    self attributesToDeepCopy do:
> +        [ : eachAttribute | attributes
> +            at: eachAttribute
> +            ifPresent:
> +                [ : value | attributes
> +                    at: eachAttribute
> +                    put: (value veryDeepCopyWith: aDeepCopier) ]
> +            ifAbsent: [ self error: eachAttribute, ' is not an attribute.' ] ]!
> 
> 


More information about the Squeak-dev mailing list