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.

I have a MVC architecture, and I have the basic views completed. I now need to add the first user tutorial mode into the project. I don't want to add checks for first user state in all the views that need it, but the only alternative I can think of is to subclass everything and use those subclasses on first open. Is there a standard or widely-used practice for adding support for tutorials, etc. without making a mess of everything?

EDIT: I was unclear in my question.

I'm talking about tutorials that a user encounters when first using the app -- in our case we want to add visual effects to direct their attention to key UI elements. I wrote "first user state" to mean we store state about the number of uses on a local machine and use that to determine if display is necessary. Usually I would add some kind of edge case code to the views, say, if User.firstUse() arrowView.show();, but I was wondering if there's a cleaner way to partition that kind of code from regular code.

share|improve this question
2  
Your question is a bit vague - "the first user tutorial mode into the project" -- what mode? what project? Whit out knowing more, it is hard to say if there is a widely-used practice for adding support of tutorials. –  MichaelT Feb 25 '13 at 4:23
    
I'm thinking for any project that has a set of views with a usual behavior but must have some special-case behavior under certain conditions; guiding a user through an app tutorial being such a condition. –  John Cartwright Feb 25 '13 at 4:48
1  
It's difficult to understand what you're asking here. I think you've got a solid question here, but we (the community) need you to edit your question and be more clear in what you're asking. For example, what tutorials are you talking about? What are you referring to with "first user state"? –  GlenH7 Feb 25 '13 at 18:39
    
@GlenH7 I understand, thank you. I'm talking about tutorials that a user encounters when first using the app -- in our case we want to add visual effects to direct their attention to key UI elements. I wrote "first user state" to mean we store state about the number of uses on a local machine and use that to determine if display is necessary. Usually I would add some kind of edge case code to the views, say, if User.firstUse() arrowView.show();, but I was wondering if there's a cleaner way to partition that kind of code from regular code. –  John Cartwright Feb 26 '13 at 4:25
    
John - that's great information to edit into your question. Underneath your question you'll see 3 fields => share, edit, flag. Click on edit and update away! –  GlenH7 Feb 26 '13 at 15:44
show 1 more comment

1 Answer

up vote 2 down vote accepted

The main thing here is that you want to decouple the "first view" tutorial content from the rest of your program, so that you can remove that content cleanly from the UI after the user has seen it once. There are a number of design patterns that would let you do that; here are three:

  • decorator: Augment the functionality of an object foo by containing it in another object bar (the decorator) that has a similar interface and calls through to foo for each method. bar is used in the program in place of foo, so every time a method in the interface is called bar gets a chance to take some action, including modifying the way foo responds to the method.

  • delegation: A "helper" object is used to modify the behavior of the delegating object(s). For example, if you're following MVC, your view object could employ a delegate that inserts the tutorial material. When certain interesting events happen (view appears, user clicks a subview, view disappears, etc.) the view could offer the delegate a chance to respond. Once the user has seen the tutorial you can just skip creating the delegate and the tutorial material won't show up.

  • observer: Your view would send messages to any registered observer objects at interesting points in the program. Objects using the observer pattern are so loosely coupled that it's usually difficult for the observer to modify the behavior of the observed object, but that may not be necessary. For example, if you can provide a transparent view that overlays the regular UI, that view could observe what's happening in the UI and display tutorial content as necessary. When you don't want the tutorial, don't create the overlay.

Some of these patterns have potential to help you do more than just provide the tutorial content. If you were to implement my example in observer, for instance, you could use the same mechanism to display diagnostic information instead of tutorial content, so that debugging becomes easier.

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.