Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Currently I'm working on an basic application that has a 'tutorial mode'. Initially hints (bubbles with text) will be displayed above various ui elements, explaining how they work. Currently I have a main view which contains a hint object that can be updated (position, text, etc.) and I'm dispatching update events from the various views that need to display a hint. In most cases when the user click a hint, it disappears, but there are a few situations when the user must perform another action(like dragging-dropping an element, clicking another,etc.) to progress.

Phew, that's the background in a nutshell. My main question is:

Should there be dispatching events from various views and handle the hints centrally or should hints only be handled locally within each view ? What's the recommended approach ?

share|improve this question
add comment

migrated from codereview.stackexchange.com Aug 2 '12 at 3:19

This question came from our site for peer programmer code reviews.

1 Answer

up vote 1 down vote accepted

I'd suggest having hints dealt with in their own class, including body of the hint (so you can change it). To call it, just add one line of code, like:

 if ( hintsOn ) { HintHandeler.display ( ); }

The less the call to the hints needs to know, the better. Try to have whatever must be dealt with to be dealt with in the Hints class

To find out where the HintHandeler call came from, make use of: Thread.currentThread().getStackTrace(), and lex it as needed to find out where you came from. Ideally, store that in a variable, then have a massive switch{} statement, if possible (for speed), go down the list of places a call might be made from, and call additional code as necessary.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.