1/16/2008itk 1681 hardwaresoftware theory 1800 ad architecture 1945 ad what is computer science?...

Post on 17-Jan-2016

215 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

1/16/2008 ITK 168 1

Hardware SoftwareTheory1800 AD

Architecture1945 AD

What is Computer Science?

Languages1960 AD

1/16/2008 ITK 168 2

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

1/16/2008 ITK 168 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

1/16/2008 ITK 168 4

Hardware

0 1 1 0

24=16

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

Software

1/16/2008 ITK 168 5

Hardware

Input device Output device

Central Processor Unit:

Internal Storage

Control Unit+

Arithmetic-Logic Unit(ALU)

1/16/2008 ITK 168 6

Logical Gates for an Adder (half adder)

A

+) Bc S

A B c S

0 0 0 0

0 1 0 1

1 0 0 1

1 1 1 0AND

OR

AND

NOT

B

A

S

c

1

1

0

11 1

11

1

1

10

0

Half-Adder

1/16/2008 ITK 168 7

4 bits Adder

Full Adder

Full Adder

Full Adder

Full Adder

A

B 0

1 1 0 1

0 1 0

1 0 1 1

0

0 1 0

0 1 0

0

1 0 1 1

+) 0 0 1 0

1 1 0 1

10 0

1/16/2008 ITK 168 8

Software: 1. Operation systems2. Applications

XP,Unix,VAX

Words

Excel

E.I.

Hello

Java

Hello.javajavacHello.class

(class loader)

Eclipse,NetBean IDE, Sun

1/16/2008 ITK 168 9

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

Java 2 Software Development Kit (J2SDK)

Eclipse

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

1/16/2008 ITK 168 10

Solving a problems by computers.

1+2+3+4+..............+98+99+100 = ?

0 + 1 = sum1;

sum1+2=sum2

sum2+3=sum3

sum3+4=sum4

sum4+5=sum5

sum5+6=sum6.............sum99+100 = sum100

0+1=1

1+2=3

3+3=6

6+4=10

10+5=15

15+6=21...............4950+100=5050

1/16/2008 ITK 168 11

Solving a problems by computers. 0 + 1 = sum1

sum1+2=sum2

sum2+3=sum3

sum3+4=sum4

sum4+5=sum5

sum5+6=sum6.............sum99+100 = sum100

sum = 0sum = sum+1

sum = sum+2

sum = sum+3

sum = sum +4

sum = sum +5.............sum = sum+100

computercan do the samething againand againfast

1/16/2008 ITK 168 12

Algorithm: a procedure of calculating (manipulate) data

1+2+3+4+ .............. +98+99+100 = ?

sum = 0sum = sum+1sum = sum+2sum = sum+3sum = sum +4sum = sum +5......sum = sum+100

sum = 0;i = 1;while (i <= 100) do the following{

sum = sum + i;i = i+1;

}sum is the answer;

1/16/2008 ITK 168 13

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)

1/16/2008 ITK 168 14

How much effort in using an IDE

Using IDE 95%

JAVA 4%

Solving Problem %1

Using IDE %4

JAVA %95

Solving Problem %1

IDE Helps?

2 week from now

1/16/2008 ITK 168 15

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

1 year from now

1/16/2008 ITK 168 16

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…)

1/16/2008 ITK 168 17

What is “model”?

X models an ideal style of Y

X objects Y problem

1/16/2008 ITK 168 18

Class A class is a concept of something

Vehicle4 wheels, seat, engine, windows……

Truck…………

Sedan…………

SUV…………

1/16/2008 ITK 168 19

Objects: an instance of some class

Vehicle

SUV

Honda Pilot

011-JAV

instantiation

Class

Object

1/16/2008 ITK 168 20

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.

1/16/2008 ITK 168 21

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

1/16/2008 ITK 168 22

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

1/16/2008 ITK 168 23

Modeling what?Modeling Robots with Software Objects - the title o 1.3

But 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 backbag

...

...

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

void move()

void turnLeft()

void pickThing()

void putThing()

...

CityString name

int stree_No

...

...

....

....

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

....

....

....

....

1/16/2008 ITK 168 24

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 City();

Thing X = new Thing(A,1,2);Robot karel = new Robot(A,0,0,

Direction.East); // direct the robot

karel.move();karel.move();karel.turnLeft(); karel.turnLeft();

karel.turnLeft(); karel.move();karel.pickThing();

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

}}

named Karel

top related