brickValue: in Glamour-Morphic-Brick

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

brickValue: in Glamour-Morphic-Brick

Nicolai Hess
Can we remove #brickValue: ?
I don't see how this is different from #cull:
And the name is strange, I don't see how this depends an a brick.

nicolai
Reply | Threaded
Open this post in threaded view
|

Re: brickValue: in Glamour-Morphic-Brick

Aliaksei Syrel
Can we remove #brickValue: ?
I don't see how this is different from #cull:
And the name is strange, I don't see how this depends an a brick.

Not really, it is implemented also in Object.
It is used to script brick layout properties. So user can say:

brick height: 10.
brick height: #approximate.
brick height: [ :b | b width * 2].

or even

brick height: HeightStrategy new.

so brickValue: is sent to any kind of object that is used as height. So without changing brick itself user can implement its own class and override brickValue: and have custom strategy to calculate height.

Such practice is used in many places in brick.



Cheers,
Alex

On Sun, Apr 26, 2015 at 12:16 AM, Nicolai Hess <[hidden email]> wrote:
Can we remove #brickValue: ?
I don't see how this is different from #cull:
And the name is strange, I don't see how this depends an a brick.

nicolai

Reply | Threaded
Open this post in threaded view
|

Re: brickValue: in Glamour-Morphic-Brick

Nicolai Hess


2015-04-26 1:35 GMT+02:00 Aliaksei Syrel <[hidden email]>:
Can we remove #brickValue: ?
I don't see how this is different from #cull:
And the name is strange, I don't see how this depends an a brick.

Not really, it is implemented also in Object.

Ah, ok, I missed that one.
 
It is used to script brick layout properties. So user can say:

brick height: 10.
brick height: #approximate.
brick height: [ :b | b width * 2].

or even

brick height: HeightStrategy new.

so brickValue: is sent to any kind of object that is used as height. So without changing brick itself user can implement its own class and override brickValue: and have custom strategy to calculate height.

Such practice is used in many places in brick.


I saw the call to brickValue: in GTSpotter and GLMAnimation, is it only used for brick attributes, like in your example above?

nicolai

 


Cheers,
Alex

On Sun, Apr 26, 2015 at 12:16 AM, Nicolai Hess <[hidden email]> wrote:
Can we remove #brickValue: ?
I don't see how this is different from #cull:
And the name is strange, I don't see how this depends an a brick.

nicolai


Reply | Threaded
Open this post in threaded view
|

Re: brickValue: in Glamour-Morphic-Brick

stepharo
In reply to this post by Aliaksei Syrel


Not really, it is implemented also in Object.
It is used to script brick layout properties. So user can say:

brick height: 10.


brick height: #approximate.
brick height: [ :b | b width * 2].

while I can see that this too cases are similar, sending value to any object is always to me over polymorphism.

If we could not extend Object, the provider could simply add value in his class?
We are always trying to remove messages from Object.

or even

brick height: HeightStrategy new.

so brickValue: is sent to any kind of object that is used as height. So without changing brick itself user can implement its own class and override brickValue: and have custom strategy to calculate height.

Such practice is used in many places in brick.



Cheers,
Alex

On Sun, Apr 26, 2015 at 12:16 AM, Nicolai Hess <[hidden email]> wrote:
Can we remove #brickValue: ?
I don't see how this is different from #cull:
And the name is strange, I don't see how this depends an a brick.

nicolai