Hi Peter, 2015-04-09 21:20 GMT+02:00 Peter Uhnák <i.uhnak@gmail.com>:
Is there some common / best way for coding builders?
Two ways that I see are:
a) using a block - I've seen this in menus and some other, however in my case I need to add an extra parameter as label
"variant with two params" aForm addDropList: 'Type' with: [ :dropList | dropList items: #(input #output); " ... ". ].
"variant with one method param and value holder" aForm addDropList: [ :labelHolder :dropList | labelHolder value: 'Type'. dropList items: #(input #output); " ... ". ].
b) using return value - no blocks, no extra code (aForm addDropList: 'Type') items: #(input #output); " ... ".
I would use the second variant as it looks much cleaner, however considering how widespread is the use of the first variant I think I must be missing something.
Can you give an example, where the first variant is used. I don't really understand the use of the valueHolder in the second example. Wouldn't it be cleaner to define a DropList class /model that has methods for setting the label and items list? aForm addDropList:[:dropListMode | dropListModel setLabel:'...'. dropListModel setItems:{ .... } ]
Thanks, Peter