On Wed, 21 Dec 2016 08:07:39 +0100, Tudor Girba <tudor(a)tudorgirba.com>
wrote:
Hi,
MissingValue (or NoValue) is definitely the way to go. The
UniformOrderedCollection is an interesting idea, too. We had a NoValue
like solution a long time ago but we discarded because we missed the
idea around collections. It would be really cool to have this working.
I can continue to see the amount of protocol that should be implemented.
Now I'm thinking that for moose I would like MetricComputer (an object
computing a metric)
and that tools list explicitly the metrics they need.
The goal is to make metrics first class entity (but not at the model level
rto avoid to have object just wrapping a number).
stef
Cheers,
Doru
On Dec 20, 2016, at 10:15 PM, stepharong
<stepharong(a)free.fr> wrote:
Hi dear great OO designers
Here is a little challenges for your brainy souls :)
In Moose when we compute metrics it may happen than a tool (often
external to pharo) does not compute a metrics
and when we request it in moose we check and often we return a not so
good -1.
I'm trying to brainstorm on a solution
- first may be the simplest way is to not invoke a metrics when it is
not computed. But it means that we should know it and that we should
have a registration mechanism. After all this is probably the best
solution.
- Second we were thinking to use exception but when we have multiple
entities missing one metrics.... I have serious doubts.
- Second I was thinking about having the following behavior
testCollect
| uarray collected |
uarray := UniformOrderedCollection new.
uarray add: 10.
uarray add: 20.
uarray add: (MissingValue discarding).
collected := uarray collect: [ :each | each ].
self assert: collected size equals: 2.
testDo
| res uarray |
uarray := UniformOrderedCollection new.
uarray add: 10.
uarray add: 20.
uarray add: (MissingValue discarding).
uarray add: 40.
res := 0.
uarray do: [ :each | res := res + each ].
self assert: res equals: 70.
testCollectDefaulting
| uarray collected |
uarray := UniformOrderedCollection new.
uarray add: 10.
uarray add: 20.
uarray add: (MissingValue default: 33).
collected := uarray collect: [ :each | each ].
self assert: collected size equals: 3.
self assert: collected third equals: 33
I basically started to implement
do: aBlock
"Refer to the comment in Collection|do:."
1 to: self size do:
[:index | (self at: index) toDo: aBlock on: self]
collect: aBlock
"Evaluate aBlock with each of the receiver's elements as the argument.
Collect the resulting values into a collection like the receiver.
Answer
the new collection."
| newCollection |
newCollection := self species new.
self
do: [ :each | each toCollect: aBlock on: newCollection ].
^ newCollection
and
DiscardingValue >> toCollect: aBlock on: aCollection
"discard computation"
^ self
Object >> toCollect: aBlock on: aCollection
^ aCollection add: (aBlock value: self)
So I imagine that you see the design and I wanted to get your point of
view.
--
Using Opera a kind of bad mail client but far better than thunderbird
_______________________________________________
Moose-dev mailing list
Moose-dev(a)list.inf.unibe.ch
https://www.list.inf.unibe.ch/listinfo/moose-dev
--
www.tudorgirba.com
www.feenk.com
"One cannot do more than one can do."
--
Using Opera's mail client:
http://www.opera.com/mail/