Supposing I have a domain model, Activity, which looks like this:
Object subclass: #Activity
�� �� �� �� instanceVariableNames: 'title cost'
�� �� �� �� classVariableNames: ''
�� �� �� �� category: 'PERT'
Then I have the expected accessors for title and cost.
Now the Spec version of this I have looks like this:
SpecEditActivity>>initializePresenter
�� �� �� �� super initializePresenter.
�� �� �� �� titleWidget whenTextChanged: [ :newText | activity title: newText ].
�� �� �� �� costWidget whenTextChanged: [ :newCost | activity cost: newCost ]
Then on the class side of things, I have this layout:
SpecEditActivity class>>layout
�� �� �� �� <spec>
�� �� �� �� ^ SpecLayout composed
�� �� �� �� �� �� �� �� newColumn: [ :column |
�� �� �� �� �� �� �� �� �� �� �� �� column
�� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� newRow: [ :row |
�� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� row
�� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� add: #titleLabel;
�� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� add: #titleWidget ];
�� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� newRow: [ :row |
�� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� ��row
�� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� add: #costLabel;
�� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� add: #costWidget ] ];
�� �� �� �� �� �� �� �� yourself
I make all the expected "getter" methods.
I can see how to get the model value out: I do something like this:
activityDialog := SpecEditActivity new openDialogWithSpec; yourself.
activityDialog model activity
I have two questions about the Spec side of the house:
1. The title/costWidget whenTextChanged: stuff. With Polymorph, I can just say, here's an object, here's the getter/setter, deal with it. Does Spec have anything like this, or do you have to do this manual data shuffling? Is there an example I can learn from?
2. This layout is a bit on the ugly side. I looked at the examples and saw usage of the expert layout with asking how tall a line is. Is that the best that can be done, or is there something more like Polymorph's label layout that can be used instead?
Thanks for your time and patience!
���
Daniel Lyons