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
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:

Lecture 26 Design Last time 1 Basics of program design 2 Algorithms 3 Interfaces 4 Software design and system design Today 1 System design 2 Use cases 3 Command line Java 10 30 2006 CMSC 131 Fall 2006 Rance Cleaveland 2006 Univeristy of Maryland Project 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 automated CMSC 131 Fall 2006 Rance Cleaveland 2006 University of Maryland 1 Recall 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 CMSC 131 Fall 2006 Rance Cleaveland 2006 University of Maryland High level Low level 2 Recall 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 design CMSC 131 Fall 2006 Rance Cleaveland 2006 University of Maryland 3 System 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 System Chef owners waiters etc Restaurant CMSC 131 Fall 2006 Rance Cleaveland 2006 University of Maryland 4 System 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 2006 Rance Cleaveland 2006 University of Maryland 5 Essential 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 2006 Rance Cleaveland 2006 University of Maryland 6 Specifying Desired Behavior with Use Cases Use case a description of an interaction of a user and the system Use cases include Prerequisites pre conditions What must hold for this use case to arise Possible actions and interactions What 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 money Restaurant is open Actions get menu order food be served eat pay leave Post conditions Customer full less money Restaurant more money less food CMSC 131 Fall 2006 Rance Cleaveland 2006 University of Maryland 7 Principal 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 State What is the current status state of the units that define our system Interaction Use cases CMSC 131 Fall 2006 Rance Cleaveland 2006 University of Maryland 8 Example Pharmacy Store System Components Pharmacist 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 patient CMSC 131 Fall 2006 Rance Cleaveland 2006 University of Maryland 9 Relationship 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 methods CMSC 131 Fall 2006 Rance Cleaveland 2006 University of Maryland 10 Command Line Java So far we have been using Eclipse to Create Run Debug Test Java 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 2006 Rance Cleaveland 2006 University of Maryland 11 Creating 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 Foo CMSC 131 Fall 2006 Rance Cleaveland 2006 University of Maryland 12 Compiling Java Outside Eclipse The Java compiler creates bytecode from Java source code How to execute the compiler outside of Eclipse If the source file is Foo java the bytecode is contained in Foo class 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 directories to locate commands To add a directory to your path in Windows command window set path c Program Files Java jdk1 5 0 08 bin path CMSC 131 Fall 2006 Rance Cleaveland 2006 University of Maryland 13 Running Java Code Outside Eclipse java Foo Command java starts Java Virtual Machine The JVM then executes bytecodes in Foo class Command java is usually in same directory as javac java must be able to find Foo class Java uses a special path classpath for this To add current directory to classpath set classpath classpath CMSC


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 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?