Closed olekscode closed 5 years ago
It just just calls another method. And creates an instance variable for some reason:
cutWhereCamelCase: aName "This method is implemented in String" | name | name := aName. ^ name cutWhereCamelCase.
I would just put cutWhereCamelCase method into DMNameTokenizer (not extend the String class). And rename it to tokenize:
cutWhereCamelCase
DMNameTokenizer
String
tokenize:
DMNameTokenizer >> tokenize: aName | word token allTokens resultedTokens| word := aName deepCopy. token := ''. allTokens := OrderedCollection new. resultedTokens := OrderedCollection new. 1 to: word size do: [ :index | (self checkCapitalLetter: (word at: index)) ifTrue: [ allTokens add: token. token := (word at: index) asString. ] ifFalse: [ token := token , (word at: index) asString ]. (index == word size) ifTrue: [ allTokens add: token ] ]. token := ''. allTokens do: [ :each | (each size == 1) ifTrue: [ token := token , each asString ] ifFalse: [ resultedTokens add: token. token := ''. resultedTokens add: each ] ]. resultedTokens add: token. ^ resultedTokens reject: [ :each | each size ==0 ]
It just just calls another method. And creates an instance variable for some reason:
I would just put
cutWhereCamelCase
method intoDMNameTokenizer
(not extend theString
class). And rename it totokenize: