Page 307 -
P. 307

274     Part 3  •  the analysis Process

                                             One of the difficulties for the analyst is to determine how to include the studentNumber
                                         after clicking the Next button, because the :Student class is no longer available. There are three
                                         ways to store and retransmit data from a web page:

                                           1. Include the information in the URL displaying in the address or location area of the
                                             browser. In this case, the location line might read something like the following:
                                             http://www.cpu.edu/student/studentinq.html?studentNumber=12345 Everything after the
                                             question mark is data that may be used by the class methods. This means of storing data is
                                             easy to implement and is often used in search engines.
                                             There are several drawbacks to using this method, and an analyst must use due caution.
                                             The first concern is privacy; anyone can read the Web address. If the application involves
                                             medical information, credit card numbers, and so on, this is not a good choice. Most
                                             browsers also display previous Web address data in subsequent sessions if the user enters
                                             the first few characters, and the information may be compromised, leading to identity theft.
                                             A second disadvantage is that the data are usually lost after the user closes the browser.
                                           2. Store the information in a cookie, a small file stored on the client (browser) computer.
                                             Using cookies is the only way to store data that have persistence, existing beyond the cur-
                                             rent browser session. This enables the web page to display a message such as “Welcome
                                             back, Robin. If you are not Robin, click here.” Cookies usually store primary key account
                                             numbers, but not credit card numbers or other private information. Cookies are lim-
                                             ited to 20 per domain (such as www.cpu.edu), and each cookie must be 4,000 or fewer
                                             characters.
                                                An analyst must work with other business units to determine who needs to use cook-
                                             ies, and there must be some central control over the names used in the cookies. If the
                                             organization needs to have more than 20 cookies, a common solution is to create different
                                             domain names used by the organization, such as support.cpu.edu or instruction.cpu.edu.
                                           3. Use hidden Web form fields. These fields usually contain data that are sent by the server,
                                             are invisible, and do not occupy any space on the web page. In the preceding example, the
                                             :View Student Interface Controller class added a hidden field containing the student-
                                             Number to the studentWebPage form along with the nextButton. When the student clicks
                                             the nextButton, the studentNumber is sent to the server, and the :View Student Interface
                                             Controller knows which student to obtain course and grade information for. The data in
                                             hidden forms is not saved from one browser session to another, so privacy is maintained.


                                         Presentation, Business, and Persistence Layers in Sequence
                                         Diagrams
                                         In the previous example, we showed all the classes in the same diagram. When it comes to writ-
                                         ing code for systems, it has been useful to look at sequence diagrams as having three distinct
                                         layers:
                                           1. The presentation layer, which represents what the user sees. This layer contains the inter-
                                             face or boundary classes.
                                           2. The business layer, which contains the unique rules for this application. This layer contains
                                             the control classes.
                                           3. The persistence, or data access, layer, which describes obtaining and storing data. This
                                             layer contains the entity classes.
                                         Ideally, program code would be written separately for each of these layers.
                                             With the introduction of Ajax, the lines became blurred. Ajax, an acronym for Asynchronous
                                         JavaScript and XML, is a collection of techniques that allows Web applications to retrieve
                                         information from the server without altering the display of the current page. This turns out to be
                                         an advantage because the entire web page does not need to be reloaded when it gets additional
                                         data from the server.
                                             Before Ajax was created, a user visiting a website would answer some questions by entering
                                         data on a Web-based form and then wait until a new page loaded. This was necessary because
                                         the code to validate, get the data, and then answer the user resided on the server. With the advent
                                         of Ajax, the web page is updated rapidly because much of the validation and other control logic
   302   303   304   305   306   307   308   309   310   311   312