+ All Categories
Home > Documents > cs1110 - Dr. Kaminski Introduction to

cs1110 - Dr. Kaminski Introduction to

Date post: 30-Jul-2015
Category:
Upload: flashdomain
View: 362 times
Download: 1 times
Share this document with a friend
34
cs1110 - Dr. Kaminski Introduction to Computers & Programming
Transcript
Page 1: cs1110 - Dr. Kaminski Introduction to

cs1110 - Dr. Kaminski

Introduction toComputers & Programming

Page 2: cs1110 - Dr. Kaminski Introduction to

2

To do. . .

Attendance Class cancelled? (weather? I’m sick?) www.cs.wmich.edu/~cs1110

syllabus & schedule help link to Kaminski’s cs1110 WebPage

Page 3: cs1110 - Dr. Kaminski Introduction to

3

CS1110 Focus (scale of 0-5)

Programming (any language) 5 C# language (the basics) 5 Debugging 4 Algorithm design (basic) 3 Follow requirement specs 3 Testing 2 Programming environment (.NET) 1 GUI (Visual) interface 0

Page 4: cs1110 - Dr. Kaminski Introduction to

4

What’s a “computer”?PC (Windows machine), Mac, . . .

micro-computer (laptop, desktop, netbook),mini-computer, mainframe, supercomputer

Blackbery, iPhone, smart phone, iPod, Tivo, Xbox, …

print server, file server, DB server, web server,…

Page 5: cs1110 - Dr. Kaminski Introduction to

5

2 parts of a “computer”Hardware (HW)

1. CPU2. Memory (RAM, …)3. Storage devices: Disk, CD, DVD, thumb drive, …4. I/O devices 5. Connectivity: NW, wifi, bluetooth, ethernet, …

Software (SW) programs makes the computer “smart” controls HW hides most HW from user

Page 6: cs1110 - Dr. Kaminski Introduction to

6

HW – CPU

1) CU (Control Unit) - Boss fetch & decode instruction

(the instr. specified in PC (program counter) )

call & pass data to/from other HW units

2) ALU (Arithmetic & Logic Unit) - Worker arithmetic + - * / comparisons = <

Page 7: cs1110 - Dr. Kaminski Introduction to

7

HW - Storage

1 - Primary storage = Memory (RAM) internal storage temporary, volatile, small, fast-access e.g., 512MB, . . . 1GB, . . .

2 - Secondary storage disk, CD, DVD, SD card, USB thumb

drive external storage permanent, large capacity, slow-access e.g., 250GB, . . . 1TB, . . . HD

(or 2GB flash drive in netbook) . . .

Page 8: cs1110 - Dr. Kaminski Introduction to

8

HW – I/OInput

Devices: keyboard, mouse, touchscreen, . . .

camera, scanner, microphone, . . .

File, DB, internet, . . .

Output Devices: Screen,

printer, AV device, . . . Control machine, robot, . . . File, DB, internet, . . .

Page 9: cs1110 - Dr. Kaminski Introduction to

9

SW (programs)

system SW OS, utilities, device drivers, compilers,

text editors, NW SW, . . .

application SW general-purpose

DBMS, MS Office, browser, Visual Studio application-specific

Payroll, WMU registration

Page 10: cs1110 - Dr. Kaminski Introduction to

10

Programmer Application programmer Systems “ Database “ Network “ Web “ . . . . . . Games, AI, graphics, . . .

Page 11: cs1110 - Dr. Kaminski Introduction to

11

Program recipe detailed step-by-step INSTRUCTIONS tells computer EXACTLY what to do controls HW processes data

package vs. in-house programs “SW system” = set of programs

e.g., operating system

Page 12: cs1110 - Dr. Kaminski Introduction to

12

Software EngineerProgrammer - “Developer”Systems Analyst - “Designer”

SW Engineering activities: Plan, design, test, document Code (= write program) Develop GUI Develop modules (classes) Customize package Build SW from components . . .

Page 13: cs1110 - Dr. Kaminski Introduction to

13

IPO model (IPSO model?)

Input Processing Output & Storing

Page 14: cs1110 - Dr. Kaminski Introduction to

14

IPOHUMAN

see/hear [think & remember] speak/write

HW mouse/KB … [CPU & RAM & disk] screen, …

SW (traditional program) data [process & store] data

(user/file/DB) (user/file/DB) ^^^^^^^^^^ [= the PROGRAM]

Page 15: cs1110 - Dr. Kaminski Introduction to

15

Data text, numbers

graphics, sound, images, movies, . . .

mouse clicks (single/double, left/right), mouse hovers, . . .

web page, text message, . . .

Page 16: cs1110 - Dr. Kaminski Introduction to

16

Types of applications Batch processing

Typically: file in, file/printer out Interactive

simple text I/O with user (Console App)

GUI (Windows App)(Web App)

Visual C# can do all of theseCS1110 – only Console Applications

Page 17: cs1110 - Dr. Kaminski Introduction to

17

IPO

SW (windows application) user input [process & store] screen display mouse clicks DB data in a form

SW module (a method) input parameter [procedure] return value

[& local variables] [& class’s instance variables]

Page 18: cs1110 - Dr. Kaminski Introduction to

18

Types of Programs/Programming

Event-driven program Modular program Visual program Structured program Procedural program (next time & …)

Object-oriented program (couple weeks) OOP

Visual C# can do all of these

Page 19: cs1110 - Dr. Kaminski Introduction to

19

Event-driven programmingIPO: event [handler module

in program] effectsEvents:

left-mouse-click on button/slider bar/menu item, mouse hovers over X,user hits Enter key, hit F5 key,sensor detects change,change made to the DB,. . .

Programming: Write a module to handle any event that could happen

Page 20: cs1110 - Dr. Kaminski Introduction to

20

Windows App vs. Console App

event-drivenWindows App vs. Console App

Controller User Program (Main)Input PUSHed into PULLed by

program by user programInterface Windows/GUI/ Console (text)

Visual/web/…Mode Interactive Batch or

simple text I/O

Page 21: cs1110 - Dr. Kaminski Introduction to

21

Modular programming

Program = a collection of small modulesA module is:

(in Procedural Prog.) an IPO procedure or function

(in Object Oriented Prog.) a Class (object) a IPO method within a class

~ procedure

Programming – write modules Top-down or bottom-up

Page 22: cs1110 - Dr. Kaminski Introduction to

22

Visual Programming

Visual C#, Visual Basic, Visual C++, Visual J#

1) Construct GUI from pre-existing visual components Text box, radio button, slider bar, dropdown list,...

2) Adjust the properties of these objects3) Add procedural code (a module) specifying:

WHAT to do for

each EVENT that might happen to this object(Much code is automatically generated for an object)

Page 23: cs1110 - Dr. Kaminski Introduction to

23

Structured ProgrammingAll procedural code (C# methods) is made from stacking or

nesting of:

1) Sequence Structureaction1, action2,

action3, . . .

2) Selection (condition) Structureif conditionX is true

then action1else

action2

3) Repetition (loop) Structurewhile conditionX is

true do{ action1,

action2,...

}

Page 24: cs1110 - Dr. Kaminski Introduction to

24

Programming

= problem-solving solution

1) Solve the problem right AND2) Solve the right problem

Determine:WHAT needs to be doneHOW to do it (the algorithm)

Page 25: cs1110 - Dr. Kaminski Introduction to

25

Example Problems

iPod - List Song titles in alphabetical order

Calculate final grade in cs1110 Sync up iPod & iTunes on PC Pay off a car loan at X% over Y years Google Map Directions

– find the shortest path Kzoo GR

Page 26: cs1110 - Dr. Kaminski Introduction to

26

Steps in programming

1. Requirements specification (what)2. Program design (how)

The Algorithm (in Pseudocode) Which Modules GUI

3. Coding (development) [in C#]4. Testing & debugging5. Documentation (external)6. Maintenance

Page 27: cs1110 - Dr. Kaminski Introduction to

27

Algorithm (the “P” of IPO)e.g., find all Prime Numbers <= 120?

View of “P”:User’s view: BLACK-boxProgrammer’s view : WHITE(“clear”)-box

(write & test actual code)

Program’s “P” (the processing) could: Lookup in a table / file / DB Calculate using

Algorthm1 or Algorithm2 or . . .

Page 28: cs1110 - Dr. Kaminski Introduction to

28

Construct program from

pre-existing classes/methods in library just need to know interface (I/O)

classes/methods written by programmer

Page 29: cs1110 - Dr. Kaminski Introduction to

29

Basic Operations (processing)used in a program

1) Actual Work arithmetic comparison ( =, <, >, and, or, not)

2) Move/storing data Assignment Mem Mem I/O (Read)

KB/mouse/text-on-screen/touchscreen/file/… Mem I/O (Write)

Mem screen/printer/file/…

Page 30: cs1110 - Dr. Kaminski Introduction to

30

Basic Operations (processing)used in a program

3) Control the flow(what instruction executes next)

default: do next line maybe do this line (if, switch) jump to specific line (loop, break) goto & return (call)

4) Packaging Methods (procedures) Classes

Page 31: cs1110 - Dr. Kaminski Introduction to

31

1st & 2nd Generation Programming Languages

Machine Languages (ML) 11010010001010011110000111000111 Machine-dependent

Assembly Languages Add 210(8,13) Machine-dependent

Page 32: cs1110 - Dr. Kaminski Introduction to

32

3rd Generation Languages

High Level Languages (HLL), e.g., C# Average = (Ex1 + Ex2 + Ex3) / 3;

2 main programming paradigms Procedural (PP)

C, COBOL, Fortran, Basic, ... , any OOP can do PP

Object-oriented (OOP) C#, Java, C++, Visual Basic.NET

Page 33: cs1110 - Dr. Kaminski Introduction to

33

Compiler

HLL program [compiler] ML program

Hello.cs C# compiler Hello.exe(source code) (executable)

Page 34: cs1110 - Dr. Kaminski Introduction to

34

4th & 5th Generation Languages

Application-specific Languagese.g., SQL for DBS

Select name, phone from studentwhere major = “CS” and state = “MI”;

Natural Languages (English, . . .)If patient is age 65 or older

and is disorientedand has pain in his/her left arm

then patient could have had a heart attack


Recommended