DOC PREVIEW
UMD CMSC 131 - Lecture 26: Design

This preview shows page 1-2-3-4-5-6 out of 19 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

10/30/2006 CMSC 131 Fall 2006Rance Cleaveland©2006 Univeristy of MarylandLecture 26:DesignLast time:1. Basics of program design2. Algorithms3. Interfaces4. Software design and system designToday:1. System design2. Use cases3. Command-line JavaCMSC 131 Fall 2006Rance Cleaveland©2006 University of Maryland1Project #5 Assigned! Project due Tuesday, 10/31 at 11 pm Project is closed You must complete the project by yourself Assistance can only be provided by teaching assistants (TAs) and instructors You must not look at other students' code Start now! Read entire assignment from beginning to end before starting to code Check out assignment now from CVS Follow the instructions exactly, as much of grading is automatedCMSC 131 Fall 2006Rance Cleaveland©2006 University of Maryland2Recall from Last Lecture:Coding vs. Software DesignCoding: writing of (Java) code to implement classes, methods, etc. Projects so far have been primarily coding We have told you what to code Design: determination of what to code What classes are needed?  How should classes interact? What methods belong in each class? How should method functionality be implemented?High-levelLow-levelCMSC 131 Fall 2006Rance Cleaveland©2006 University of Maryland3Recall from Last Lecture:Upper Levels of Software DesignWhere do ideas for classes, interactions between classes come from? Software development part of larger system design process System design requires identifying what system users expect system to do These user requirements often suggest system components and how they fit together First part of software design: understand system designCMSC 131 Fall 2006Rance Cleaveland©2006 University of Maryland4System Design: What Is It? System design is concerned with: coordinating a collection of entities… … to achieve a complex process Each entity has its own responsibilities to the others to achieve an overall objective E.g. Restaurant Entities Chef, owners, waiters, etc. System RestaurantCMSC 131 Fall 2006Rance Cleaveland©2006 University of Maryland5System Examples Classroom environment: Lecturers, TAs, students, … Library: Circulation (checkout and return), indexing services (online catalogue), library users, book buyers, shelvers, … Pharmacy: Patients (and medical records), pharmacists, doctors, drug retailers, the pharmacy (products in stock), … Video game: Race cars, motorcycles, warriors, space ships, death squads, monsters, aliens, mutants, guns, swords, weapons of mass destruction, cute Japanese cartoon animals with huge eyes, …CMSC 131 Fall 2006Rance Cleaveland©2006 University of Maryland6Essential Questions What is the desired behavior of the program (as a whole)? What are the entities that produce this behavior? How does each one work? How do these entities interact?CMSC 131 Fall 2006Rance Cleaveland©2006 University of Maryland7Specifying Desired Behavior with Use CasesUse case: a description of an interaction of a user and the system. Usecases include: Prerequisites (pre-conditions)What must hold for this use case to arise? Possible actions and interactionsWhat happens? Effects (post-conditions)What conditions hold, what changes have taken place, as a result of these actions. Example: Customer in a restaurant Pre-conditions: Customer: hungry and has moneyRestaurant: is open Actions: get menu, order food, be served, eat, pay, leave Post-conditions: Customer: full, less moneyRestaurant: more money, less foodCMSC 131 Fall 2006Rance Cleaveland©2006 University of Maryland8Principal Design Elements Components What are the entities that make up our system? What are the roles they play? How do we separate the system into distinct units? Contract What are the responsibilities and services associated with each component? What guarantees does it make? StateWhat is the current status/state of the units that define our system? InteractionUse casesCMSC 131 Fall 2006Rance Cleaveland©2006 University of Maryland9Example: Pharmacy Store SystemComponentsPharmacist, customers, doctors, prescription, store stock, … Contract Pharmacists can fill prescriptions Doctors write prescriptions Pharmacists only fill the prescriptions written by doctors  Pharmacists and doctors maintain patient records etc. State (patient)Current prescriptions, number of times refilled, date of last refill, health insurance information Fill prescription use case: A valid prescription presented by the customer Pharmacists checks patient records and informs of possible side-effects Pharmacist dispenses prescription Patient records updated Medication given to patientCMSC 131 Fall 2006Rance Cleaveland©2006 University of Maryland10Relationship to Java System: A Java program Components: Java classes and objects State: Object instance variables, class static variables Contract: API / interface The external (class user) view of an object Provides an abstraction of what the object does, without indicating how it is implemented Includes prototypes of actions (methods) The contract is implemented using methodsCMSC 131 Fall 2006Rance Cleaveland©2006 University of Maryland11Command-Line Java So far we have been using Eclipse to Create Run Debug TestJava programs Is Eclipse the only way to write Java? No! Any text editor can be used to create Java code Java can be compiled and executed from the “command line” (= DOS prompt = Unix shell = etc.)CMSC 131 Fall 2006Rance Cleaveland©2006 University of Maryland12Creating Java Programs with a Text EditorYou can use any text editor: Wordpad Notepad Emacs vi etc. Be sure the file is saved as “plain text” (= ASCII) The name of the file must be Foo.java if the name of the class being defined is FooCMSC 131 Fall 2006Rance Cleaveland©2006 University of Maryland13Compiling Java Outside Eclipse The Java compiler creates bytecode from Java source code If the source file is Foo.java … … the bytecode is contained in Foo.class How to execute the compiler outside of Eclipse? Start a command window Execute command javac Foo.java This creates Foo.class Note: the operating system must be able to find javac! My machine: c:\Program Files\Java\jdk1.5.0_08\bin Windows use the notion of path = list of


View Full Document

UMD CMSC 131 - Lecture 26: Design

Documents in this Course
Set #3

Set #3

7 pages

Exam #1

Exam #1

6 pages

Exam #1

Exam #1

6 pages

Notes

Notes

124 pages

Notes

Notes

124 pages

Load more
Download Lecture 26: Design
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 26: Design and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 26: Design 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?