3.9. (Optional) Software Engineering Case Study: Examining the ATM Requirements DocumentNow we begin our optional object-oriented design and implementation case study. The "Software Engineering Case Study" sections at the ends of this and the next several chapters will ease you into object orientation. We will develop software for a simple automated teller machine (ATM) system, providing you with a concise, carefully paced, complete design and implementation experience. In Chapters 0409 and 11, we will perform the various steps of an object-oriented design (OOD) process using the UML, while relating these steps to the object-oriented concepts discussed in the chapters. Appendix J implements the ATM using Visual Basic object-oriented programming (OOP) techniques. We present the complete case study solution. This is not an exercise; rather, it is an end-to-end experience that concludes with a detailed walkthrough of the complete Visual Basic code that implements our design. We begin our design process by presenting a requirements document that specifies the ATM system's purpose and what it must do. Throughout the case study, we refer to the requirements document to determine precisely what functionality the system must provide. Requirements DocumentA small local bank intends to install a new automated teller machine (ATM) to allow users (i.e., bank customers) to perform basic financial transactions (Fig. 3.31). For simplicity, each user can have only one account at the bank. ATM users should be able to view their account balance, withdraw cash (i.e., take money out of an account) and deposit funds (i.e., place money into an account). Figure 3.31. Automated teller machine user interface.The user interface of the automated teller machine contains the following hardware components:
The cash dispenser begins each day loaded with 500 $20 bills. [Note: Certain elements of the ATM described here simplify various aspects of a real ATM. For example, commercial ATMs typically contain a device that reads a user's account number from an ATM card, whereas our ATM asks the user to type an account number on the keypad (which you will simulate with your personal computer's keypad). Also, commercial ATMs usually print a paper receipt at the end of a session, but all output from this ATM appears on the screen.] The bank wants you to develop software to perform the financial transactions initiated by bank customers through the ATM. The bank will integrate the software with the ATM's hardware at a later time. The software should simulate the functionality of the hardware devices (e.g., cash dispenser, deposit slot) in software components, but it need not concern itself with how these devices perform their duties. The ATM hardware has not been developed yet, so instead of writing your software to run on the ATM, you should develop a first version of the software to run on a personal computer. This version should use the computer's monitor to simulate the ATM's screen, and the computer's keyboard to simulate the ATM's keypad. An ATM session consists of authenticating a user (i.e., proving the user's identity) based on an account number and personal identification number (PIN), followed by creating and executing financial transactions. To authenticate a user and perform transactions, the ATM must interact with the bank's account information database. [Note: A database is an organized collection of data stored on a computer.] For each bank account, the database stores an account number, a PIN and a balance indicating the amount of money in the account. [Note: The bank plans to build only one ATM, so we do not need to worry about multiple ATMs accessing the database at the same time. Furthermore, we assume that the bank does not make any changes to the information in the database while a user is accessing the ATM other than those initiated by this ATM session itself. Also, any business system like an ATM faces reasonably complicated security issues that go well beyond the scope of this bookwe make the simplifying assumption that the bank trusts the ATM to access and manipulate the information in the database without significant security measures.] Upon approaching the ATM, the user should experience the following sequence of events (see Fig. 3.31):
Figure 3.32. ATM main menu.
After the ATM authenticates the user, the main menu (Fig. 3.32) displays a numbered option for each of the three types of transactionsbalance inquiry (option 1), withdrawal (option 2) and deposit (option 3). The main menu also displays an option that allows the user to exit the system (option 4). The user then chooses either to perform a transaction (by entering 1, 2 or 3) or to exit the system (by entering 4). If the user enters an invalid option, the screen displays an error message, then redisplays the main menu. If the user enters 1 to make a balance inquiry, the screen displays the user's account balance. To do so, the ATM must retrieve the balance from the bank's database. The following actions occur when the user enters 2 to make a withdrawal:
The following actions occur when the user enters 3 (from the main menu) to make a deposit:
After the system successfully executes a transaction, the system should redisplay the main menu (Fig. 3.32) so that the user can perform additional transactions. If the user chooses to exit the system (by entering option 4), the screen should display a thank you message, then display the welcome message for the next user. Analyzing the ATM SystemThe preceding statement presented a simplified requirements document. Typically, such a document is the result of a detailed process of requirements gathering that might include interviews with potential users of the system and specialists in fields related to the system. For example, a systems analyst who is hired to prepare a requirements document for banking software (e.g., the ATM system described here) might interview people who have used ATMs and financial experts to gain a better understanding of what the software must do. The analyst would use the information gathered to compile a list of system requirements to guide systems designers. The process of requirements gathering is a key task of the first stage of the software life cycle. The software life cycle specifies the stages through which software evolves from the time it is conceived to the time at which it is retired from use. These stages typically include analysis, design, implementation, testing, debugging, deployment, maintenance and retirement. Several software life cycle models exist, each with its own preferences and specifications for when and how often software engineers should perform the various stages. Waterfall models perform each stage once in succession, whereas iterative models may repeat one or more stages several times throughout a product's life cycle. The analysis stage of the software life cycle focuses on precisely defining the problem to be solved. When designing any system, one must certainly solve the problem right, but of equal importance, one must solve the right problem. Systems analysts collect the requirements that indicate the specific problem to solve. Our requirements document describes our simple ATM system in sufficient detail that you do not need to go through an extensive analysis stageit has been done for you. To capture what a proposed system should do, developers often employ a technique known as use case modeling. This process identifies the use cases of the system, each of which represents a different capability that the system provides to its clients. For example, ATMs typically have several use cases, such as "View Account Balance," "Withdraw Cash," "Deposit Funds," "Transfer Funds Between Accounts" and "Buy Postage Stamps." The simplified ATM system we build in this case study requires only the first three use cases. Each use case describes a typical scenario in which the user uses the system. You have already read descriptions of the ATM system's use cases in the requirements document. The lists of steps required to perform each type of transaction (i.e., balance inquiry, withdrawal and deposit) actually described the three use cases of our ATM"View Account Balance," "Withdraw Cash" and "Deposit Funds." Use Case DiagramsWe create a use case diagram to model the interactions between a system's clients (in this case study, bank customers) and the system. The goal is to show the kinds of interactions users have with a system without providing the detailsthese are shown in other UML diagrams (which we present throughout the case study). Use case diagrams are often accompanied by informal text that describes the use cases in more detaillike the text that appears in the requirements document. Use case diagrams are produced during the analysis stage of the software life cycle. In larger systems, use case diagrams are simple but indispensable tools that help system designers focus on satisfying the users' needs. Fig. 3.34 shows the use case diagram for our ATM system. The stick figure represents an actor, which defines the roles that an external entitysuch as a person or another systemplays when interacting with the system. For our automated teller machine, the actor is a User who can view an account balance, withdraw cash and deposit funds using the ATM. The User is not an actual person, but instead comprises the roles that a real personwhen playing the part of a Usercan play while interacting with the ATM. Note that a use case diagram can include multiple actors. For example, the use case diagram for a real bank's ATM system might also include an actor named Administrator who refills the cash dispenser each day. Figure 3.34. Use case diagram for the ATM system from the User's perspective.
We identify the actor in our system by examining the requirements document, which states, "ATM users should be able to view their account balance, withdraw cash and deposit funds." The actor in each of the three use cases is simply the User who interacts with the ATM. An external entitya real personplays the part of the User to perform financial transactions. Fig. 3.34 shows one actor, whose name, User, appears below the actor in the diagram. The UML models each use case as an oval connected to an actor with a solid line. Systems designers must analyze the requirements document or a set of use cases, and design the system before programmers implement it in a particular programming language. During the analysis stage, systems designers focus on understanding the requirements document to produce a high-level specification that describes what the system is supposed to do. The output of the design stagea design specificationshould specify how the system should be constructed to satisfy these requirements. In the next several "Software Engineering Case Study" sections, we perform the steps of a simple object-oriented design (OOD) process on the ATM system to produce a design specification containing a collection of UML diagrams and supporting text. Recall that the UML can be used with any OOD process. Many such processes exist, the best known of which is the Rational Unified Process™ (RUP) developed by Rational Software Corporation (now a division of IBM). RUP is a rich process for designing "industrial strength" applications. For this case study, we employ a simplified design process. Designing the ATM SystemWe now begin the design stage of our ATM system. A system is a set of components that interact to solve a problem. For example, to perform the ATM system's designated tasks, our ATM system has a user interface (Fig. 3.31), contains software that executes financial transactions and interacts with a database of bank account information. System structure describes the system's objects and their interrelationships. System behavior describes how the system changes as its objects interact with one another. Every system has both structure and behaviordesigners must specify both. There are several distinct types of system structures and behaviors. For example, the interactions among objects in the system differ from those between the user and the system, yet both constitute a portion of the system behavior. The UML 2 specifies 13 diagram types for documenting system models. Each diagram type models a distinct characteristic of a system's structure or behaviorsix diagram types relate to system structure; the remaining seven relate to system behavior. We list here only the six types of diagrams used in our case studyone of these (class diagrams) models system structurethe remaining five model system behavior. We overview the remaining seven UML diagram types in Appendix K, UML 2: Additional Diagram Types:
In Section 4.9, we continue designing our ATM system by identifying the classes from the requirements document. We accomplish this by extracting key nouns and noun phrases from the requirements document. Using these classes, we develop our first draft of the class diagram that models the structure of our ATM system. Internet and Web ResourcesThe following URLs provide information on object-oriented design with the UML. www-306.ibm.com/software/rational/uml/ Lists frequently asked questions about the UML, provided by IBM Rational. www.agilemodeling.com/essays/umlDiagrams.htm Provides in-depth descriptions and tutorials on each of the 13 UML 2 diagram types. www.borland.com/us/products/together/index.html Provides a free 30-day license to download a trial version of Borland® Together® ControlCenter™a software development tool that supports the UML. www-306.ibm.com/software/rational/offerings/design.html Provides information about IBM Rational software available for designing systems. Provides downloads of 30-day trial versions of several products, such as IBM Rational Rose® XDE (e Xtended Development Environment) Developer. www.embarcadero.com/products/describe/index.html Provides a 15-day trial license for the Embarcadero Technologies® UML modeling tool Describe.™ www.ilogix.com/rhapsody/rhapsody.cfm Provides a free 30-day license to download a trial version of I-Logix Rhapsody®a UML 2-based model-driven development environment. argouml.tigris.org Contains information and downloads for ArgoUML, a free open-source UML tool. www.objectsbydesign.com/books/booklist.html Lists books on the UML and object-oriented design. www.objectsbydesign.com/tools/umltools_byCompany.html Lists software tools that use the UML, such as IBM Rational Rose, Embarcadero Describe, Sparx Systems Enterprise Architect, I-Logix Rhapsody and Gentleware Poseidon for UML. www.ootips.org/ood-principles.html Provides answers to the question, "What makes a good object-oriented design?" www.cetus-links.org/oo_uml.html Introduces the UML and provides links to numerous UML resources. Recommended ReadingsThe following books provide information on object-oriented design with the UML. Ambler, S. The Elements of the UML 2.0 Style. New York: Cambridge University Press, 2005. Booch, G. Object-Oriented Analysis and Design with Applications, Third Edition. Boston: Addison-Wesley, 2004. Eriksson, H., et al. UML 2 Toolkit. Hoboken, N.J.: John Wiley & Sons, 2003. Kruchten, P. The Rational Unified Process: An Introduction. Boston: Addison-Wesley, 2004. Larman, C. Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design, Second Edition. Upper Saddle River, NJ: Prentice Hall, 2002. Roques, P. UML in Practice: The Art of Modeling Software Systems Demonstrated Through Worked Examples and Solutions. Hoboken, N.J.: John Wiley & Sons, 2004. Rosenberg, D., and K. Scott. Applying Use Case Driven Object Modeling with UML: An Annotated e-Commerce Example. Reading, MA: Addison-Wesley, 2001. Rumbaugh, J., I. Jacobson and G. Booch. The Complete UML Training Course. Upper Saddle River, NJ: Prentice Hall, 2000. Rumbaugh, J., I. Jacobson and G. Booch. The Unified Modeling Language Reference Manual. Reading, MA: Addison-Wesley, 1999. Rumbaugh, J., I. Jacobson and G. Booch. The Unified Software Development Process. Reading, MA: Addison-Wesley, 1999. Software Engineering Case Study Self-Review Exercises
Answers to Software Engineering Case Study Self-Review Exercises
|