Spec: why is there an initialize in ClassMethodBrowser and none in MethodBrowser example?

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

Spec: why is there an initialize in ClassMethodBrowser and none in MethodBrowser example?

philippeback
MethodBrowser works without that initialize (and uses
initializeWidgets for the instantiation) where ClassMethodBrowser
requires one (doesnt work without as models are nil).

ClassMethodBrowser>>initialize
        "Initialization code for ClassMethodBrowser"

        super initialize.

        listModel := self instantiate: ListComposableModel.
        methodModel := self instantiate: MethodBrowser.
       
        self focusOrder
                add: listModel;
                add: methodModel.
       
        listModel whenSelectedItemChanged: [:selection |
                selection
                        ifNotNil: [:class |
                                methodModel methods: (class methodDict values sort: [:a :b | a
selector < b selector]).
                                methodModel listModel resetSelection ]].
       
        methodModel wrapWith: [:method | method selector ].

And

ClassMethodBrowser>>initializeWidgets

        self instantiateModels: #(
                listModel ListComposableModel
                methodModel MethodBrowser ).
       
        self focusOrder
                add: listModel;
                add: methodModel.
       
        methodModel displayBlock: [:method | method selector ].

has the instantiateModels.

There seems to be a double instantiation in here...

What is the right way to proceed? The Spec Report of June 2012 and the
Spec tex thing in the SCM aren't right, so I wonder what the right way
to do things is.

TIA

Phil

Reply | Threaded
Open this post in threaded view
|

Re: Spec: why is there an initialize in ClassMethodBrowser and none in MethodBrowser example?

Benjamin Van Ryseghem (Pharo)
The initialise method should not exists anymore.

Probably the rest of an old refactoring.

The "right" way is to use initialize for initialising your  inst var (other than sub widgets),
initializeWidgets for initialising sub widgets (instantiate them, set them, etc) and
initializePresenter to specify the interactions between sub widgets.

Thanks for the report :)

Ben

On Feb 18, 2013, at 9:53 PM, [hidden email] wrote:

MethodBrowser works without that initialize (and uses
initializeWidgets for the instantiation) where ClassMethodBrowser
requires one (doesnt work without as models are nil).

ClassMethodBrowser>>initialize
"Initialization code for ClassMethodBrowser"

super initialize.

listModel := self instantiate: ListComposableModel.
methodModel := self instantiate: MethodBrowser.

self focusOrder
add: listModel;
add: methodModel.

listModel whenSelectedItemChanged: [:selection |
selection
ifNotNil: [:class |
methodModel methods: (class methodDict values sort: [:a :b | a
selector < b selector]).
methodModel listModel resetSelection ]].

methodModel wrapWith: [:method | method selector ].

And

ClassMethodBrowser>>initializeWidgets

self instantiateModels: #(
listModel ListComposableModel
methodModel MethodBrowser ).

self focusOrder
add: listModel;
add: methodModel.

methodModel displayBlock: [:method | method selector ].

has the instantiateModels.

There seems to be a double instantiation in here...

What is the right way to proceed? The Spec Report of June 2012 and the
Spec tex thing in the SCM aren't right, so I wonder what the right way
to do things is.

TIA

Phil


Reply | Threaded
Open this post in threaded view
|

Re: Spec: why is there an initialize in ClassMethodBrowser and none in MethodBrowser example?

philippeback
Thanks.

Still, when I do not have the initialize in the ClassMethodBrowser,
the thing doesn't work as the models aren't initialized properly.

I'll check again. I am trying to recreate the example from scratch to
understand how all of this works.

Regards,
Phil

2013/2/19 Benjamin <[hidden email]>:

> The initialise method should not exists anymore.
>
> Probably the rest of an old refactoring.
>
> The "right" way is to use initialize for initialising your  inst var (other
> than sub widgets),
> initializeWidgets for initialising sub widgets (instantiate them, set them,
> etc) and
> initializePresenter to specify the interactions between sub widgets.
>
> Thanks for the report :)
>
> Ben
>
> On Feb 18, 2013, at 9:53 PM, [hidden email] wrote:
>
> MethodBrowser works without that initialize (and uses
> initializeWidgets for the instantiation) where ClassMethodBrowser
> requires one (doesnt work without as models are nil).
>
> ClassMethodBrowser>>initialize
> "Initialization code for ClassMethodBrowser"
>
> super initialize.
>
> listModel := self instantiate: ListComposableModel.
> methodModel := self instantiate: MethodBrowser.
>
> self focusOrder
> add: listModel;
> add: methodModel.
>
> listModel whenSelectedItemChanged: [:selection |
> selection
> ifNotNil: [:class |
> methodModel methods: (class methodDict values sort: [:a :b | a
> selector < b selector]).
> methodModel listModel resetSelection ]].
>
> methodModel wrapWith: [:method | method selector ].
>
> And
>
> ClassMethodBrowser>>initializeWidgets
>
> self instantiateModels: #(
> listModel ListComposableModel
> methodModel MethodBrowser ).
>
> self focusOrder
> add: listModel;
> add: methodModel.
>
> methodModel displayBlock: [:method | method selector ].
>
> has the instantiateModels.
>
> There seems to be a double instantiation in here...
>
> What is the right way to proceed? The Spec Report of June 2012 and the
> Spec tex thing in the SCM aren't right, so I wonder what the right way
> to do things is.
>
> TIA
>
> Phil
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Spec: why is there an initialize in ClassMethodBrowser and none in MethodBrowser example?

Benjamin Van Ryseghem (Pharo)
If you have questions, I will be glad to answer :)

Ben

On Feb 19, 2013, at 12:24 AM, [hidden email] wrote:

Thanks.

Still, when I do not have the initialize in the ClassMethodBrowser,
the thing doesn't work as the models aren't initialized properly.

I'll check again. I am trying to recreate the example from scratch to
understand how all of this works.

Regards,
Phil

2013/2/19 Benjamin <[hidden email]>:
The initialise method should not exists anymore.

Probably the rest of an old refactoring.

The "right" way is to use initialize for initialising your  inst var (other
than sub widgets),
initializeWidgets for initialising sub widgets (instantiate them, set them,
etc) and
initializePresenter to specify the interactions between sub widgets.

Thanks for the report :)

Ben

On Feb 18, 2013, at 9:53 PM, [hidden email] wrote:

MethodBrowser works without that initialize (and uses
initializeWidgets for the instantiation) where ClassMethodBrowser
requires one (doesnt work without as models are nil).

ClassMethodBrowser>>initialize
"Initialization code for ClassMethodBrowser"

super initialize.

listModel := self instantiate: ListComposableModel.
methodModel := self instantiate: MethodBrowser.

self focusOrder
add: listModel;
add: methodModel.

listModel whenSelectedItemChanged: [:selection |
selection
ifNotNil: [:class |
methodModel methods: (class methodDict values sort: [:a :b | a
selector < b selector]).
methodModel listModel resetSelection ]].

methodModel wrapWith: [:method | method selector ].

And

ClassMethodBrowser>>initializeWidgets

self instantiateModels: #(
listModel ListComposableModel
methodModel MethodBrowser ).

self focusOrder
add: listModel;
add: methodModel.

methodModel displayBlock: [:method | method selector ].

has the instantiateModels.

There seems to be a double instantiation in here...

What is the right way to proceed? The Spec Report of June 2012 and the
Spec tex thing in the SCM aren't right, so I wonder what the right way
to do things is.

TIA

Phil