Date post: | 30-Jul-2015 |
Category: |
Documents |
Upload: | flashdomain |
View: | 362 times |
Download: | 1 times |
cs1110 - Dr. Kaminski
Introduction toComputers & Programming
2
To do. . .
Attendance Class cancelled? (weather? I’m sick?) www.cs.wmich.edu/~cs1110
syllabus & schedule help link to Kaminski’s cs1110 WebPage
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
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,…
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
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 = <
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) . . .
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, . . .
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
10
Programmer Application programmer Systems “ Database “ Network “ Web “ . . . . . . Games, AI, graphics, . . .
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
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 . . .
13
IPO model (IPSO model?)
Input Processing Output & Storing
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]
15
Data text, numbers
graphics, sound, images, movies, . . .
mouse clicks (single/double, left/right), mouse hovers, . . .
web page, text message, . . .
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
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]
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
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
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
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
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)
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,...
}
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)
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
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
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 . . .
28
Construct program from
pre-existing classes/methods in library just need to know interface (I/O)
classes/methods written by programmer
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/…
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
31
1st & 2nd Generation Programming Languages
Machine Languages (ML) 11010010001010011110000111000111 Machine-dependent
Assembly Languages Add 210(8,13) Machine-dependent
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
33
Compiler
HLL program [compiler] ML program
Hello.cs C# compiler Hello.exe(source code) (executable)
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