1 CS210 Intermediate Computing with Data Structures (Java) Saaid Baraty sbaraty@cs.umb.edu S-3-90

Preview:

Citation preview

1

CS210Intermediate Computing

with Data Structures (Java)Saaid Baraty

sbaraty@cs.umb.edu

S-3-90

2

Outline of Today's Class

• Looking at the course syllabus and requirements.

• About this course.• Software Engineering and Software

Quality.• Data Structures and Their importance in

Software Engineering. • UML Diagram.

3

Welcome to CS210

• What are the values of this course?– This course provides the knowledge for you to

understand and use data structures, especially the Java Collections API, for writing more effective and efficient computer programs.

– Also, you will write many programs in Java. This sharpens your Java programming skills.

4

Software Engineering

• Software engineering is the study of techniques, theory and principles to develop high quality software.

• Software qualities:– Correctness– Reliability– Robustness– Usability– Maintainability– Re-usability/Extendability– Portability– Efficiency

5

Software Development Methods

Edit and save source code

Build source codeto create program

Run program andevaluate results

Errors

Errors

• Classical “Waterfall” Development Steps

6

Errors

• A program can have three types of errors:

• The IDE editor and/or compiler will find syntax errors and other basic problems (compile-time errors)

– If compile-time errors exist, an executable version of the program is not created

• A problem can occur during program execution, such as trying to divide by zero, which causes a program to terminate abnormally (run-time errors)

• A program may run, but produce incorrect results, perhaps using an incorrect formula (logical errors)

7

Data Structures

• Data structures refer to the structures or organizations we use to store or retrieve data in memory.

8

Data Structures and Program Efficiency

The choice of the data structure that we use in our program can dramatically affect the efficiency (in terms of running time ) of our program.

9

Data Structure Example

We have a program that accepts a number as input and tells us if the number exists in the following set of numbers stored in memory:

{ 2, 10, 9, 11, 100, -6, 21 }

What data structure should we use to store the numbers for obtaining the highest efficiency?

10

Option 1

An unordered list:

{ 2, 10, 9, 11, 100, -6, 21 }

10 9 112 100 -6 21

pros and cons

11

Option 2

An ordered list:

{ 2, 10, 9, 11, 100, -6, 21 }

2 9 10-6 11 21 100

pros and cons

12

Option 3

A binary tree

{ 2, 10, 9, 11, 100, -6, 21 }

9

100

2

21

10

11

-6

pros and cons

13

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.

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

14

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!– Commercial UML S/W tools are expensive!

• Example: Rational ROSE (IBM acquired Rational)

15

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.

16

UML Diagram for a Class

CreditCard

- myCardData : CardData

+ read( ) : CardData

• Class name: CreditCard

• Attribute name: myCardData

• Method name: read()

17

Class Diagram Showing Inheritance

BankAccount

balance

getBalance()

CheckingAccount

monthlyFee

getFee()

SavingAccount

interest

getInterest()

18

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)– Integrated Development Environment (IDE) or

you can use the command prompt (terminal)

• Use the PCs in the Healey Library labs as they already have these tools installed

19

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

20

Software Development Tools• We can use a combination of the an IDE and

the Sun Java SDK

SourceFile(s)(.java)

Programmer

Eclipse IDE

Compiler(javac)

ClassFile(s)(.class)

VirtualMachine

(java)

Edit Build Run

Programexecutes

Parts of Sun Java SDK

Graphical User Interface

Recommended