RTMetricNormalizer new

elements: es;

normalizeSize: #numberOfMethods min: 20 max: 50;

normalizeColor: #numberOfVariables.


I now fully understand your question :-)
The terminology of object-orientation says that an “instance" is an “object” or a “class instance” (these three appellations are rigorously equivalent).
The code above creates an instance of the class RTMetricNormalizer and initializes it.
There are actually two normalizations, one occurring with the message #normalizeSize:min:max:, and the second one using #normalizeColor:
As you can guess, the first normalization affects the size while the latter affects the color. The normalization happens in the method invoked by these messages, which are RTMetricNormalizer>>normalizeSize:min:max: and RTMetricNormalizer>> normalizeColor:. 

The actual normalization happens in some private methods defined on RTMetricNormalizer. If you are curious, you can have a look at
RTMetricNormalizer>>normalizeColor: metricBlock using: colors using: transformation min: min max: max 

With “sideeffect” I meant in a way:

RTMetricNormalizer new elements: es; …

RTGridLayout new on: es.

Yes, you are absolutely right. The class RTMetricNormalizer, RTGridLayout operate by doing side effects on the relevant nodes. 
You can keep the instance if you wish so, but this is not necessary in this example.

Note that this way of coding is perfectly normal regarding object-oriented design. There is nothing particular to Roassal or Pharo here.

Tx for explaining, that symbols and blocks both respond to #value and can be used interchangeably.

Is there a section in Pharo by example explaining it? I have to look more deeply.


Agile Visualization mentions this aspect (as it is crucial in Roassal): 
https://dl.dropboxusercontent.com/u/31543901/AgileVisualization/PharoIntroduction/0102-PharoIntroduction.html

End of Section 1 mentions the use of symbols

 P.S.: It seems intuitive/compelling how to use Roassal, but after reading PharobyExample, there is an initial gap to understand the Roassal model (how it works), at least for me.

Yes, I understand your feeling. Roassal is a balance between easiness of writing code, and expressiveness of the framework. I believe that in any non-trivial framework / API there is a bit of complexity / magic that appears both fantastic and disturbing. 

Cheers,
Alexandre

 

BR Mike


Am 20.03.2017 2:39 nachm. schrieb "Alexandre Bergel" <alexandre.bergel@me.com>:
Dear Markus,

Agile Vis ebook is superb, copied following snippet, know hopefully what it's doing, but want to make sure I understand how it works (in terms of "plain" Pharo):

Thanks for your nice words. 

1) @ RTPopup: Class name is enough, but it is initiated under the hood?

Yes. You can particularize the popup. For example, consider the script:
-=-=-=-=-=-=-=-=-=
v := RTView new.
es := (RTEllipse new color: Color blue) elementsOn: Collection withAllSubclasses.
v addAll: es.

aPopup := RTPopup new 
text: [ :aClass | 
'Classname = ', aClass name, String cr,
'NbMethod=', aClass numberOfMethods asString, String cr,
'NbVariables=', aClass numberOfVariables asString ].
aPopup borderColor: Color black.
aPopup textColor: Color white.
aPopup backgroundColor: Color black.
es @ aPopup.

RTMetricNormalizer new
elements: es;
normalizeSize: #numberOfMethods min: 20 max: 50;
normalizeColor: #numberOfVariables.

RTGridLayout new on: es.

v
-=-=-=-=-=-=-=-=-=
<Screenshot 2017-03-20 10.26.56.png>
2) RTMetricNormalizer new ...: There is no need to keep reference to created object? Why? because messages sent to object (like normalizeSize) have a "sideeffect" on es?

To RTMetricNormalizer, you can provide the Roassal elements or your objects (#(4 5 1 2 3 5) in your example). 
What do you mean by side effect? The class RTMetricNormalizer needs some Roassal elements to operates. Either you provide them directly, as in the example, or you can provide a view and the objects (in this case, roassal elements are looked up).
The objects needs to answer to the messages indicated as argument to normalizeSize: and normalizeColor:. In your example it is #yourself (all pharo objects understand this, which returns the object itself). In the example I have just given, it is  #numberOfMethods and #numberOfVariables, which are understood by Pharo classes (used as objects).


3) RTMetricNormalizer connects to model via #yourself? Is every symbol or code block. that is sent to RTMetricNormalizer as argument, executed when finally "sent" to es?

#yourself in your example indicates where to get the number used for the size and color normalization. In that case, represented objects (numerical values) are taken directly by the normalizer. But it could be different as in my example. Classes are represented, and a metric is used to obtain a numerical value. 

Let us know if my answer make things clearer now. If no, then keep asking please :-)

Cheers,
Alexandre




BR Mike

v := RTView new. es := (RTEllipse new color: Color blue) elementsOn: #(4 5 1 2 3 5). v addAll: es. es @ RTPopup. RTMetricNormalizer new elements: es; alphaColor; normalizeSize: #yourself min: 20 max: 50; normalizeColor: #yourself. RTHorizontalLineLayout new alignCenter; on: es. es @ RTLabeled. v

-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.

_______________________________________________
Moose-dev mailing list
Moose-dev@list.inf.unibe.ch
https://www.list.inf.unibe.ch/listinfo/moose-dev

_______________________________________________
Moose-dev mailing list
Moose-dev@list.inf.unibe.ch
https://www.list.inf.unibe.ch/listinfo/moose-dev