How can I cleanly separate first open tutorial code from my regular display code under OOP?

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.

6

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.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật