Top Banner
04/24/22 ITK 179 1 Hardware Software Theory 1800 AD Architecture 1945 AD What is Computer Science? Languages 1960 AD
27
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 7/27/10 ITK 179

04/10/23 ITK 179 1

Hardware SoftwareTheory1800 AD

Architecture1945 AD

What is Computer Science?

Languages1960 AD

Page 2: 7/27/10 ITK 179

2ITK 17904/10/23

Alan Turing (1912-1954) – The Enigma

The man who invented the computer

Image from http://ei.cs.vt.edu/~history/Turing.html

Turing Machines

Turing Award: the Nobel Prize in CS

Page 3: 7/27/10 ITK 179

04/10/23 ITK 179 3

Said:

“Turing Machines are human that compute.”

“In logic nothing is accidental”

Ludwig Wittgenstein (1889-1951)

Image from http://www.ags.uci.edu/~bcarver/wgallery.html

Page 4: 7/27/10 ITK 179

04/10/23 ITK 179 4

Hardware

0 1 1 0

24=16

0 1 0 01 1 0 0... ... ... ...

Software

Page 5: 7/27/10 ITK 179

04/10/23 ITK 179 5

Hardware

Input device Output device

Central Processor Unit:

Internal Storage

Control Unit+

Arithmetic-Logic Unit(ALU)

Page 6: 7/27/10 ITK 179

04/10/23 ITK 179 6

Software: 1. Operation systems2. Applications

XP,Unix,VAX

Words

Excel

E.I.

Hello

Java

Hello.javajavacHello.class

(class loader)

Eclipse,NetBean IDE, Sun

Page 7: 7/27/10 ITK 179

04/10/23 ITK 179 7

IDE (Integrated Development Environment)1. A customized plain text editor2. Compiler3. Loader4. Debugging tool

JDK (Java Development Kid) = IDE+JRE

Eclipse = IDE

1. notepad2. javac hello3. java hello4. ......

Page 8: 7/27/10 ITK 179

04/10/23 ITK 179 8

How much effort in solving a problem

Java's Features Solving Problem

Java's Features Solving Problem

This is more important and difficult;

data structures,algorithm analysis

This is a basic requirement. We need to reduce this portion

6 month from now

Page 9: 7/27/10 ITK 179

04/10/23 ITK 179 9

ProblemsSolutions cycle

Problems

System analyst, Project leader

Algorithms

Senior Programmers

Programs in JAVA (or any high level Programming Language)

compiler

AssemblyAssembler

Machine code

linkerResults

Customers

ProgrammersSyntaxSemantics

(human)

IDE(computers)

Page 10: 7/27/10 ITK 179

04/10/23 ITK 179 10

Procedure vs Object

To solve a program is:

To find a way to manipulate data --

• We design procedures • Procedure-Oriented Programming

Statements + functions programs

To find objects to model the problem –

• We choose data (object) • Object-Oriented Programming

Classes + Objects programs

(interfaces, methods, attributes…)

Page 11: 7/27/10 ITK 179

04/10/23 ITK 179 11

What is “model”?

X models an ideal style of Y

X objects Y problem

Page 12: 7/27/10 ITK 179

04/10/23 ITK 179 12

Class A class is a concept of something

Vehicle4 wheels, seat, engine, windows……

Truck…………

Sedan…………

SUV…………

Page 13: 7/27/10 ITK 179

04/10/23 ITK 179 13

Objects: an instance of some class

Vehicle

SUV

Honda Pilot

011-JAV

instantiation

Class

Object

Page 14: 7/27/10 ITK 179

04/10/23 ITK 179 14

Method & Attribute

Each class: Method & AttributeThe class designer should determine whatkind of methods and attribute its object should have

Method: behaviors, service, operation, and functionalities of the object.

Field (attribute): the information, status, and properties of the object.

Page 15: 7/27/10 ITK 179

04/10/23 ITK 179 15

011-JAV

Honda Pilot

Honda PilotPlate: 011-JAV

Color: Blue

Engine size: 3.0 L

...

...

Start the engine()

Stop()

Turn (direction)

Air()

...

...

Services, methods

Attributes

UML (Unified Modeling Language) class diagram

Class name

Z.Turn(right)

Z

Page 16: 7/27/10 ITK 179

04/10/23 ITK 179 16

Robotint street

int avenue

Direction direction

ThingBag backback

...

...

Robot(City aCity, int aStreet, int aAvenue, Direction aDir)

void move()

void turnLeft()

void pickThing()

void putThing()

...

...

Services, methods

Attributes

UML class diagram for Robot

Class name

Constructor

Page 17: 7/27/10 ITK 179

04/10/23 ITK 179 17

Modeling what?Modeling Robots with Software Objects

- the title of 1.3 in ITK168 textbookBut this phrase does not make too much sense to me...

Should be: Modeling Robots in a City with Software Classes.

Robotint street

int avenue

Direction direction

ThingBag backback

...

...

Robot(City aCity, int aStreet, int aAvenue, Direction aDir)

void move()

void turnLeft()

void pickThing()

void putThing()

...

CityString name

int stree_No

...

...

....

....

City(...........)

....

....

....

....

Page 18: 7/27/10 ITK 179

04/10/23 ITK 179 18

Object–Oriented Programming

• Model the structure and behavior of a system through the interaction of software objects that represent entities from the problem domain

Page 19: 7/27/10 ITK 179

04/10/23 ITK 179 19

Task: deliver X from (1,2) to (3,1) and step away

X0

1

2

3

4

0 1 2 3 4import becker.robot.*;

public class DeliverX{

public static void main(String args[]){ // set up Initial situation City A = new A();

Thing X = new Thing(A,1,2); Robot karel = new Robot(A,0,0, Direction.East); // direct the robot

karel.move();karel.move();karel.turnRight();karel.move();karel.pickThing();

karek.move(); karel.move();karel.turnRight();karel.move(); karel.putThing();karel.move();

}}

name Karel

Page 20: 7/27/10 ITK 179

04/10/23 ITK 179 20

A Java programimport javax.swing.JOptionPane;public class time{ public static void main(String args[]){

int x,y,z; String X,Y;

X = JOptionPane.showInputDialog("Input x"); Y = JOptionPane.showInputDialog("Input y"); x = Integer.parseInt(X); y = Integer.parseInt(Y);

z = x*y;

JOptionPane.showMessageDialog( null, x + " * " + y + " = " + z, "The product of " + x + " and " + y, JOptionPane.PLAIN_MESSAGE ); System.exit(0); }}

classes methods

package

arguments

Variable declaration

Page 21: 7/27/10 ITK 179

04/10/23 ITK 179 21

Data Type

• Characterize data into different kinds for convenience

1. bit2. byte3. integer4. ascii5. character6. array7. string8. real9. record

+ operations Objects

Page 22: 7/27/10 ITK 179

04/10/23 ITK 179 22

Abstraction

• A tool to manage complexity• Hide irrelevant details; focus on the features

needed to use a thing• Examples

– File deletion using icons– The brakes on a car– Television remote– What else?

Page 23: 7/27/10 ITK 179

04/10/23 ITK 179 23

Data Type

• Specification View of a data type– Data values– Operations defined on those values

Abstract Data Type (ADT) –use of abstraction!

• Implementation View of a data type– Language-specific representation for the values– Implementation of the operations

Implementation of an ADT

Page 24: 7/27/10 ITK 179

04/10/23 ITK 179 24

Abstract model of Priority Queues (Specification View)

Priority Queue

a black box

insert oneitem

Get the one with the highest priority

the minimum one(or equivalently, maximum)

Abstract Data Type (ADT)

Page 25: 7/27/10 ITK 179

04/10/23 ITK 179 25

Abstract model of Priority Queues (Implementation View)

Binary Search Treeor

Binary Heap?

insert oneitem

Get the one with the highest priority

the minimum one(or equivalently, maximum)

Abstract Data Type (ADT)

Page 26: 7/27/10 ITK 179

04/10/23 ITK 179 26

The Java Collections Framework (JCF)

UML Class Diagram

Page 27: 7/27/10 ITK 179

04/10/23 ITK 179 27

Collection Operations

• Add an element• Remove an element• Replace an element• Retrieve an element• Determine if a collection

contains an element• Get the collection’s size

• Determine if a collection is empty

• Traverse a collection• Determine if two

collections are equal• Clone a collection• Serialize a collection

Most collections support the same operations, but may givethem different names.