5.2 Smart Ticket in ActionThe Smart Ticket client allows the user to manage user preferences, browse movie schedules, order tickets, rate watched movies, and pre-download the schedule. We discuss those features one by one in this section. NoteThe Smart Ticket blueprint is designed for educational purposes. It demonstrates the use of design patterns. As developers, we should judicially use patterns learned from the Smart Ticket. The overuse of design patterns results in unnecessary abstraction layers and produces slow and large applications.5.2.1 Manage User PreferencesWhen the user starts the MIDP client for the first time, she will be asked to create a profile. The profile includes two types of information:Account credentials: The username, password, and optional credit card numbers.User preferences: The theater search zip codes, favorite day of the week, and preferred seating. Figure 5.1 shows how to manage user preferences. Figure 5.1. Manage user preferences.![]() After the user submits the profile, a corresponding user account is created on the J2EE server. The preference information is cached on the device. The user could configure the MIDP client to cache the account credentials so that she does not need to manually sign in every time she wants to purchase tickets or submit movie ratings. User preferences can be modified at any time through the MIDP UI.Chapters 19 and 20. 5.2.2 Search and Purchase TicketsOnce logged in, the user can browse theaters, movies, and show times in her zip code areas. This process involves a series of real-time queries to the J2EE server. Once she selects a show, she will be asked to select currently available seats from an interactive seating map to make reservations. The reservation is persisted to the server database. Figure 5.2 illustrates the browsing and reserving process from the user's perspective. Figure 5.2. Browse and purchase movie tickets.![]() NoteThe interactive seating map allows the user to move a flashing cursor using the phone's navigation pad. The currently reserved and available seats are differentiated by colors. It demonstrates the rich UI capabilities of the MIDP.5.2.3 Rate MoviesThe user can rate movies she has seen (Figure 5.3). The ratings are not immediately submitted to the server. They are cached on device and can be synchronized to the server upon the user request. That allows the user to rate movies even when the phone is out of network range (for example, in a shielded cinema building!). The synchronization agent is smart: When the same user rates the same movie multiple times, it resolves the issue by keeping only the most recent rating in the backend database. Figure 5.3. Rate watched movies.![]() NoteThe user can only rate movies for which she has purchased tickets via the Smart Ticket system. This is necessary to ensure the integrity of the rating system. It also simplifies the UI design.5.2.4 Cache Theater SchedulesSmart Ticket allows the user to download a theater's schedule to the mobile client. The cached schedule enables offline browsing and improves the performance by reducing network round trips. The user can delete or re-download the schedule as needed (Figure 5.4). Figure 5.4. Download movie schedules into the on-device cache.![]() NoteNotice that the theaters with cached schedules have a different icon. That helps the user to avoid downloading the same schedule multiple times. It also helps the user to make quick choices of theaters in the browsing mode (Figure 5.2).Now, let's examine how those features are implemented in the Smart Ticket application. |