why in Puzzle bazzar we are using event mechanism to reveal LinkColumn

6 views
Skip to first unread message

SZK

unread,
Oct 28, 2010, 1:42:20 AM10/28/10
to PuzzleBazar-Dev
Hi,
Phil (or any body with relevent knowledge) please explain why in
Puzzle bazzar we are using event mechanism to reveal LinkColumn not
just

placeManager.revealPlace

Is it avoid it from being getting registered in history . Is this
really the best approach one line vs 2 classes (one class one
interface) .

If it is then it is but just want to confirm is that the only reason
and best approach .

PhilBeaudoin

unread,
Oct 28, 2010, 1:55:00 PM10/28/10
to PuzzleBazar-Dev
Ok, let me explain with a partial hierarchy of presenters in
PuzzleBazar:

RootPresenter
+-- PuzzlePresenter OR
PagePresenter
+-- TopBarPresenter (PresenterWidget)
+-- SplitMainPresenter
+-- MainPagePresenter OR
| UserSettingsTabPresenter OR
| AdminTabPresenter
+-- LinkColumnPresenter

(First off: it's a little too much. KISS should have dictated that I
leave out SplitMainPresenter until I really needed it.)

So, why LinkColumnPresenter?

1) Why is it a Presenter and not a PresenterWidget
It could have been a PresenterWidget, but I wanted to keep
SplitMainPresenter oblivious to the presenter displayed in its left
slot. Basically, the reasoning was: SplitMainPresenter never has
anything to say to LinkColumnPresenter so it should not discuss with
it and it should not be responsible of managing it.

2) Why not use placeManager.revealPlace?
LinkColumnPresenter is not a place, it is not something you can
navigate to on its own. MainPagePresenter is (and other presenters
under UserSettingsTabPresenter and AdminTabPresenter), but it wouldn't
make sense to bookmark, say, #link_column. Moreover, doing it this way
would be asking for trouble. The call sequence would look something
like:
- User navigates to #main
- MainPagePresenter reveals itself in SplitMainPresenter
- SplitMainPresenter.onReveal is called, so it knows something is
needed in its left slot
- It calls placeManager.revealPlace(...) with #link_column
- The place manager updates the browser url to #link_column

You can see this is fishy. Using an event, the two last steps become:
- It fires RevealDefaultLinkColumnEvent
- LinkColumnPresenter gets the event and reveals itself

Hope it helps!

Philippe

SZK

unread,
Oct 28, 2010, 11:09:16 PM10/28/10
to PuzzleBazar-Dev
Great very clear and helpful thanks a lot.
Reply all
Reply to author
Forward
0 new messages