16
1 Mass IT Course Fall 2008 Bob Wilson [email protected] S-3-071

1 Mass IT Course Fall 2008 Bob Wilson [email protected] S-3-071

Embed Size (px)

Citation preview

Page 1: 1 Mass IT Course Fall 2008 Bob Wilson bobw@cs.umb.edu S-3-071

1

Mass IT CourseFall 2008

Bob Wilson

[email protected]

S-3-071

Page 2: 1 Mass IT Course Fall 2008 Bob Wilson bobw@cs.umb.edu S-3-071

2

Welcome to Mass IT Course

• Syllabus is home page on the website:http://www.cs.umb.edu/~bobw/MassIT

• Lecture 1 reviewing:– UML– Eclipse and ANT

• Lecture 2 reviewing:– Java Language– Object-Oriented Programming

Page 3: 1 Mass IT Course Fall 2008 Bob Wilson bobw@cs.umb.edu S-3-071

3

Welcome to Mass IT Course

• Lecture 3 for this session:– Collections– Iterable and Iterator Interfaces– “For-each” loops

e.g. for (Type object : collection)

• Exercise for this session:– Sudoku Solution Verifier– Use of Collections, Iterable and Iterator

Page 4: 1 Mass IT Course Fall 2008 Bob Wilson bobw@cs.umb.edu S-3-071

4

Unified Modeling Language (UML)• UML is a graphical tool to visualize and

analyze the requirements and do design of an object-oriented solution to a problem

• Three basic types of diagrams:– Use Case Diagram– Class Diagram– Interaction Diagram

• A good reference is UML Distilled, 3rd Ed., Martin Fowler, Addison-Wesley/Pearson

Page 5: 1 Mass IT Course Fall 2008 Bob Wilson bobw@cs.umb.edu S-3-071

5

Unified Modeling Language (UML)

• Advantage of UML – It is graphical– Allows you to visualize the problem / solution– Organizes your detailed information

• Disadvantage of UML – It is graphical– Can be done with pencil and paper - tedious– We have UMLPAD which is a simple design

tool to aid in drawing the diagrams– Commercial UML S/W tools are expensive!

• Example: Rational ROSE (IBM acquired Rational)

Page 6: 1 Mass IT Course Fall 2008 Bob Wilson bobw@cs.umb.edu S-3-071

6

Use Case Diagrams

• Typically the first diagram(s) drawn• Helpful for visualizing the requirements• Icons on the Use Case Diagram

– Actors: Users or other external systems– Objects: Potential classes in the solution– Scenarios: Sequences of interactions

between Actors and Objects that are typical for the solution to the problem (Both success cases and error cases should be included)

Page 7: 1 Mass IT Course Fall 2008 Bob Wilson bobw@cs.umb.edu S-3-071

7

Example: Use Case Diagram

“No Sale”

Buy with Cash

Buy On Credit

Customer

Sales Person

Cry over lostcommission

Bartender

ProcessCash Sale

CashRegister

Credit CardBank

ProcessCredit SaleCash

Card SwipeMachine

Stiff Drink

Product

<<includes>>

Page 8: 1 Mass IT Course Fall 2008 Bob Wilson bobw@cs.umb.edu S-3-071

8

Class Diagrams

• Classify the Objects in the Use Cases• Define name of each class• Define each class’s attributes

– Constants– Variables

• Define each class’s behaviors– Methods

• Show relationships between classes– Depends on, Inherits, etc.

Page 9: 1 Mass IT Course Fall 2008 Bob Wilson bobw@cs.umb.edu S-3-071

9

Example: Class DiagramCredit Card

- myCardData : CardData

+ read( ) : CardData

Bank

- name : String- address : String- accounts [ ] : AcctData

+ processCharge ( thisCardData : CardData amt : double, storeName : String, storeBank : Bank, storeAcctNumber : int ) : boolean

CardData

- cardType : enum {Visa, …}- myBank : Bank- myAcctNumber : int

+ getCardType( ) : enum+ getBank( ) : Bank+ getAcctNumber( ) : int

AcctData

-acctLimit : double-acctBalance: double…

Page 10: 1 Mass IT Course Fall 2008 Bob Wilson bobw@cs.umb.edu S-3-071

10

Interaction Diagrams

• Shows the time relationship of the events in a scenario between actors and objects– UML Sequence Diagram– Sometimes called a “ladder diagram”

• A vertical line represents an actor or object

• A horizontal line represents an interaction– E.G. a call to a method of another object

• Progress of time is shown down the page

Page 11: 1 Mass IT Course Fall 2008 Bob Wilson bobw@cs.umb.edu S-3-071

11

Example: Interaction DiagramProcess Credit Sale

SalesPerson Credit Card

Card SwipeMachine Bank

read( )

processCharge( … )enterAmt(…)

swipeCard( )

return boolean

return CardData

Time

readResponse( )

return “OK”

Page 12: 1 Mass IT Course Fall 2008 Bob Wilson bobw@cs.umb.edu S-3-071

12

Software Development Tools• Using Sun Java SDK alone

SourceFile(s)(.java)

Programmer

Compiler(javac)

ClassFile(s)(.class)

VirtualMachine

(java)

Editor

Programexecutes

Parts of Sun Java SDK

Command Line Interface

Page 13: 1 Mass IT Course Fall 2008 Bob Wilson bobw@cs.umb.edu S-3-071

13

Using Sun Java SDK Alone

• Example DOS Commands and ParametersC:\ > edit HelloWorld.java

(Create/edit “source file” in an external window)

C:\ > javac HelloWorld.java (creates .class file)

C:\ > java -classpath … HelloWorld

Hello World

C:\ > exit

Page 14: 1 Mass IT Course Fall 2008 Bob Wilson bobw@cs.umb.edu S-3-071

14

Software Development Tools• We will use a combination of the Eclipse IDE

with ANT and the Sun Java SDK

SourceFile(s)(.java)

Programmer

Eclipse

Compiler(javac)

ClassFile(s)(.class)

VirtualMachine

(java)

Edit Build Run

Programexecutes

Graphical User Interface

build.xml

ANT

Page 15: 1 Mass IT Course Fall 2008 Bob Wilson bobw@cs.umb.edu S-3-071

15

Eclipse IDE

Page 16: 1 Mass IT Course Fall 2008 Bob Wilson bobw@cs.umb.edu S-3-071

16

Software Development Tools

• Download/install the software development tools on your own PC if you wish to do your project assignments at home– Sun Software Development Kit (SDK)– Eclipse (IDE)

• Use the PCs in the web lab as they already have these tools installed