Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pharo: How to compare objects in different inspectors?

I am using Pharo 4. Suppose my objects already implemented nice equality and hash methods.

How do I visually compare two or N objects in different inspectors? With visually I mean a side by side comparison where I can look differences easily.

I tried allInstances but is becoming tedious after a while.

like image 490
Juanjo Avatar asked Nov 08 '22 19:11

Juanjo


1 Answers

You might get inspired by looking at the diff browser you can choose when doing GLMBasicExamples open. With Glamour you can easily create a custom browser to help you with this. The diff example itself is 15 lines of code:

| browser | 
browser := GLMTabulator new.
browser 
    row: [:r | r column: #one; column: #two];
    row: #diff.
browser transmit to: #one; andShow: [ :a |
    a list 
        display: #first ].
browser transmit to: #two; andShow: [ :a | 
    a list
        display: #second ].
browser transmit to: #diff; from: #one; from: #two; andShow: [ :a | 
    a diff
        display: [ :one :two | {one asString . two asString}] ].
browser openOn: #(#(abc def ghi) #(abc xyz))

The diff view from glamour uses a DiffMorph to show differences. It needs a string representation of the two objects to compare

like image 97
Stephan Eggermont Avatar answered Nov 15 '22 13:11

Stephan Eggermont