cs1110 - Dr. Kaminski Introduction to

473 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
473
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

cs1110 - Dr. Kaminski Introduction to

  1. 1. cs1110 - Dr. Kaminski Introduction to Computers & Programming
  2. 2. To do. . . <ul><li>Attendance </li></ul><ul><li>Class cancelled? (weather? I’m sick?) </li></ul><ul><li>www.cs.wmich.edu/~cs1110 </li></ul><ul><ul><li>syllabus & schedule </li></ul></ul><ul><ul><li>help </li></ul></ul><ul><ul><li>link to Kaminski’s cs1110 WebPage </li></ul></ul>
  3. 3. CS1110 Focus (scale of 0-5) <ul><li>Programming (any language) 5 </li></ul><ul><li>C# language (the basics) 5 </li></ul><ul><li>Debugging 4 </li></ul><ul><li>Algorithm design (basic) 3 </li></ul><ul><li>Follow requirement specs 3 </li></ul><ul><li>Testing 2 </li></ul><ul><li>Programming environment (.NET) 1 </li></ul><ul><li>GUI (Visual) interface 0 </li></ul>
  4. 4. What’s a “computer”? <ul><li>PC (Windows machine), Mac, . . . </li></ul><ul><li>micro-computer (laptop, desktop, netbook), </li></ul><ul><li>mini-computer, mainframe, supercomputer </li></ul><ul><li>Blackbery, iPhone, smart phone, iPod, Tivo, Xbox, … </li></ul><ul><li>print server, file server, DB server, web server,… </li></ul>
  5. 5. 2 parts of a “computer” <ul><li>Hardware (HW) </li></ul><ul><ul><li>CPU </li></ul></ul><ul><ul><li>Memory (RAM, …) </li></ul></ul><ul><ul><li>Storage devices: Disk, CD, DVD, thumb drive, … </li></ul></ul><ul><ul><li>I/O devices </li></ul></ul><ul><ul><li>Connectivity: NW, wifi, bluetooth, ethernet, … </li></ul></ul><ul><li>Software (SW) </li></ul><ul><ul><li>programs </li></ul></ul><ul><ul><li>makes the computer “smart” </li></ul></ul><ul><ul><li>controls HW </li></ul></ul><ul><ul><li>hides most HW from user </li></ul></ul>
  6. 6. HW – CPU <ul><li>1) CU (Control Unit) - Boss </li></ul><ul><ul><li>fetch & decode instruction </li></ul></ul><ul><ul><li> (the instr. specified in PC (program counter) ) </li></ul></ul><ul><ul><li>call & pass data to/from other HW units </li></ul></ul><ul><li>2) ALU (Arithmetic & Logic Unit) - Worker </li></ul><ul><ul><li>arithmetic + - * / </li></ul></ul><ul><ul><li>comparisons = < </li></ul></ul>
  7. 7. HW - Storage <ul><li>1 - Primary storage = Memory (RAM) </li></ul><ul><ul><li>internal storage </li></ul></ul><ul><ul><li>temporary, volatile, small, fast-access </li></ul></ul><ul><ul><li>e.g., 512MB, . . . 1GB, . . . </li></ul></ul><ul><li>2 - Secondary storage </li></ul><ul><ul><li>disk, CD, DVD, SD card, USB thumb drive </li></ul></ul><ul><ul><li>external storage </li></ul></ul><ul><ul><li>permanent, large capacity, slow-access </li></ul></ul><ul><ul><li>e.g., 250GB, . . . 1TB, . . . HD </li></ul></ul><ul><ul><li>(or 2GB flash drive in netbook) . . . </li></ul></ul>
  8. 8. HW – I/O <ul><li>Input </li></ul><ul><ul><li>Devices: keyboard, mouse, touchscreen, . . . </li></ul></ul><ul><ul><li>camera, scanner, microphone, . . . </li></ul></ul><ul><ul><li>File, DB, internet, . . . </li></ul></ul><ul><li>Output </li></ul><ul><ul><li>Devices: Screen, printer, AV device, . . . </li></ul></ul><ul><ul><li>Control machine, robot, . . . </li></ul></ul><ul><ul><li>File, DB, internet, . . . </li></ul></ul>
  9. 9. SW (programs) <ul><li>system SW </li></ul><ul><ul><li>OS, utilities, device drivers, compilers, text editors, NW SW, . . . </li></ul></ul><ul><li>application SW </li></ul><ul><ul><li>general-purpose </li></ul></ul><ul><ul><ul><li>DBMS, MS Office, browser, Visual Studio </li></ul></ul></ul><ul><ul><li>application-specific </li></ul></ul><ul><ul><ul><li>Payroll, WMU registration </li></ul></ul></ul>
  10. 10. Programmer <ul><li>Application programmer </li></ul><ul><li>Systems “ </li></ul><ul><li>Database “ </li></ul><ul><li>Network “ </li></ul><ul><li>Web “ </li></ul><ul><li>. . . </li></ul><ul><li>. . . </li></ul><ul><li>Games, AI, graphics, . . . </li></ul>
  11. 11. Program <ul><ul><li>recipe </li></ul></ul><ul><ul><li>detailed step-by-step INSTRUCTIONS </li></ul></ul><ul><ul><li>tells computer EXACTLY what to do </li></ul></ul><ul><ul><li>controls HW </li></ul></ul><ul><ul><li>processes data </li></ul></ul><ul><li>package vs. in-house programs </li></ul><ul><li>“SW system” = set of programs </li></ul><ul><ul><li>e.g., operating system </li></ul></ul>
  12. 12. Software Engineer <ul><li>Programmer - “Developer” </li></ul><ul><li>Systems Analyst - “Designer” </li></ul><ul><li>SW Engineering activities: </li></ul><ul><ul><li>Plan, design, test, document </li></ul></ul><ul><ul><li>Code (= write program) </li></ul></ul><ul><ul><li>Develop GUI </li></ul></ul><ul><ul><li>Develop modules (classes) </li></ul></ul><ul><ul><li>Customize package </li></ul></ul><ul><ul><li>Build SW from components </li></ul></ul><ul><ul><li>. . . </li></ul></ul>
  13. 13. IPO model (IPSO model?) <ul><li>Input  Processing  Output </li></ul><ul><li> & Storing </li></ul>
  14. 14. IPO <ul><li>HUMAN </li></ul><ul><ul><li>see/hear  [think & remember]  speak/write </li></ul></ul><ul><li>HW </li></ul><ul><ul><li>mouse/KB …  [CPU & RAM & disk]  screen, … </li></ul></ul><ul><li>SW (traditional program) </li></ul><ul><ul><li>data  [process & store]  data </li></ul></ul><ul><ul><li>(user/file/DB) (user/file/DB) </li></ul></ul><ul><ul><li> ^^^^^^^^^^ </li></ul></ul><ul><ul><li> [= the PROGRAM] </li></ul></ul>
  15. 15. Data <ul><li>text, numbers </li></ul><ul><li>graphics, sound, images, movies, . . . </li></ul><ul><li>mouse clicks (single/double, left/right), mouse hovers, . . . </li></ul><ul><li>web page, text message, . . . </li></ul>
  16. 16. Types of applications <ul><li>Batch processing </li></ul><ul><ul><li>Typically: file in, file/printer out </li></ul></ul><ul><li>Interactive </li></ul><ul><ul><li>simple text I/O with user (Console App) </li></ul></ul><ul><ul><li>GUI (Windows App) </li></ul></ul><ul><ul><li>(Web App) </li></ul></ul><ul><li>Visual C# can do all of these </li></ul><ul><li>CS1110 – only Console Applications </li></ul>
  17. 17. IPO <ul><li>SW (windows application) </li></ul><ul><ul><li>user input  [process & store]  screen display </li></ul></ul><ul><ul><li>mouse clicks   DB </li></ul></ul><ul><ul><li>data in a form  </li></ul></ul><ul><li>SW module (a method) </li></ul><ul><ul><li>input parameter  [procedure]  return value </li></ul></ul><ul><ul><li> [& local variables] </li></ul></ul><ul><ul><li> [& class’s instance variables] </li></ul></ul>
  18. 18. Types of Programs/Programming <ul><li>Event-driven program </li></ul><ul><li>Modular program </li></ul><ul><li>Visual program </li></ul><ul><li>Structured program </li></ul><ul><li>Procedural program (next time & …) </li></ul><ul><li>Object-oriented program (couple weeks) </li></ul><ul><ul><li>OOP </li></ul></ul><ul><li>Visual C# can do all of these </li></ul>
  19. 19. Event-driven programming <ul><li>IPO: event  [handler module </li></ul><ul><li>in program]  effects </li></ul><ul><li>Events: </li></ul><ul><li>left-mouse-click on button/slider bar/menu item, </li></ul><ul><li>mouse hovers over X, </li></ul><ul><li>user hits Enter key, hit F5 key, </li></ul><ul><li>sensor detects change, </li></ul><ul><li>change made to the DB, </li></ul><ul><li>. . . </li></ul><ul><li>Programming: Write a module to handle any event that could happen </li></ul>
  20. 20. Windows App vs. Console App <ul><li>event-driven </li></ul><ul><li>Windows App vs. Console App </li></ul><ul><li>Controller User Program (Main) </li></ul><ul><li>Input PUSHed into PULLed by </li></ul><ul><li> program by user program </li></ul><ul><li>Interface Windows/GUI/ Console (text) </li></ul><ul><li>Visual/web/… </li></ul><ul><li>Mode Interactive Batch or </li></ul><ul><li> simple text I/O </li></ul>
  21. 21. Modular programming <ul><li>Program = a collection of small modules </li></ul><ul><li>A module is: </li></ul><ul><ul><li>(in Procedural Prog.) </li></ul></ul><ul><ul><ul><li>an IPO procedure or function </li></ul></ul></ul><ul><ul><li>(in Object Oriented Prog.) </li></ul></ul><ul><ul><ul><li>a Class (object) </li></ul></ul></ul><ul><ul><ul><li>a IPO method within a class </li></ul></ul></ul><ul><ul><ul><ul><ul><li>~ procedure </li></ul></ul></ul></ul></ul><ul><li>Programming – write modules </li></ul><ul><ul><li>Top-down or bottom-up </li></ul></ul>
  22. 22. Visual Programming <ul><li>Visual C#, Visual Basic, Visual C++, Visual J# </li></ul><ul><li>1) Construct GUI from pre-existing visual components </li></ul><ul><ul><li>Text box, radio button, slider bar, dropdown list,... </li></ul></ul><ul><li>2) Adjust the properties of these objects </li></ul><ul><li>3) Add procedural code (a module) specifying: </li></ul><ul><li>WHAT to do for </li></ul><ul><li>each EVENT that might happen to this object </li></ul><ul><ul><li>(Much code is automatically generated for an object) </li></ul></ul>
  23. 23. Structured Programming <ul><li>All procedural code (C# methods) is made from stacking or nesting of: </li></ul><ul><li>1) Sequence Structure </li></ul><ul><ul><ul><li>action1, action2, action3, . . . </li></ul></ul></ul><ul><li>2) Selection (condition) Structure </li></ul><ul><ul><ul><li>if conditionX is true </li></ul></ul></ul><ul><ul><ul><li>then action1 </li></ul></ul></ul><ul><ul><ul><li>else </li></ul></ul></ul><ul><ul><ul><li>action2 </li></ul></ul></ul><ul><li>3) Repetition (loop) Structure </li></ul><ul><ul><ul><li>while conditionX is true do </li></ul></ul></ul><ul><ul><ul><li>{ action1, </li></ul></ul></ul><ul><ul><ul><li>action2, </li></ul></ul></ul><ul><ul><ul><li>... </li></ul></ul></ul><ul><ul><ul><li>} </li></ul></ul></ul>
  24. 24. Programming <ul><li>= problem-solving   solution </li></ul><ul><ul><li>Solve the problem right AND </li></ul></ul><ul><ul><li>Solve the right problem </li></ul></ul><ul><li>Determine: </li></ul><ul><li>WHAT needs to be done </li></ul><ul><li>HOW to do it (the algorithm) </li></ul>
  25. 25. Example Problems <ul><li>iPod - List Song titles in alphabetical order </li></ul><ul><li>Calculate final grade in cs1110 </li></ul><ul><li>Sync up iPod & iTunes on PC </li></ul><ul><li>Pay off a car loan at X% over Y years </li></ul><ul><li>Google Map Directions </li></ul><ul><li> – find the shortest path Kzoo  GR </li></ul>
  26. 26. Steps in programming <ul><li>Requirements specification (what) </li></ul><ul><li>Program design (how) </li></ul><ul><ul><li>The Algorithm (in Pseudocode) </li></ul></ul><ul><ul><li>Which Modules </li></ul></ul><ul><ul><li>GUI </li></ul></ul><ul><li>Coding (development) [in C#] </li></ul><ul><li>Testing & debugging </li></ul><ul><li>Documentation (external) </li></ul><ul><li>Maintenance </li></ul>
  27. 27. Algorithm (the “P” of IPO) <ul><li>e.g., find all Prime Numbers <= 120? </li></ul><ul><li>View of “P”: </li></ul><ul><li>User’s view: BLACK-box </li></ul><ul><li>Programmer’s view : WHITE(“clear”)-box </li></ul><ul><li>(write & test actual code) </li></ul><ul><li>Program’s “P” (the processing) could: </li></ul><ul><ul><li>Lookup in a table / file / DB </li></ul></ul><ul><ul><li>Calculate using </li></ul></ul><ul><ul><ul><li>Algorthm1 or Algorithm2 or . . . </li></ul></ul></ul>
  28. 28. Construct program from <ul><li>pre-existing classes/methods in library </li></ul><ul><ul><li>just need to know interface (I/O) </li></ul></ul><ul><li>classes/methods written by programmer </li></ul>
  29. 29. Basic Operations (processing) used in a program <ul><li>1) Actual Work </li></ul><ul><ul><li>arithmetic </li></ul></ul><ul><ul><li>comparison ( =, <, >, and, or, not) </li></ul></ul><ul><li>2) Move/storing data </li></ul><ul><ul><li>Assignment Mem  Mem </li></ul></ul><ul><ul><li>I/O (Read) </li></ul></ul><ul><ul><ul><ul><li>KB/mouse/text-on-screen/touchscreen/file/…  Mem </li></ul></ul></ul></ul><ul><ul><li>I/O (Write) </li></ul></ul><ul><ul><ul><ul><li>Mem  screen/printer/file/… </li></ul></ul></ul></ul>
  30. 30. Basic Operations (processing) used in a program <ul><li>3) Control the flow </li></ul><ul><li>(what instruction executes next) </li></ul><ul><ul><li>default: do next line </li></ul></ul><ul><ul><li>maybe do this line (if, switch) </li></ul></ul><ul><ul><li>jump to specific line (loop, break) </li></ul></ul><ul><ul><li>goto & return (call) </li></ul></ul><ul><li>4) Packaging </li></ul><ul><ul><li>Methods (procedures) </li></ul></ul><ul><ul><li>Classes </li></ul></ul>
  31. 31. 1 st & 2 nd Generation Programming Languages <ul><li>Machine Languages (ML) </li></ul><ul><ul><li>11010010001010011110000111000111 </li></ul></ul><ul><ul><li>Machine-dependent </li></ul></ul><ul><li>Assembly Languages </li></ul><ul><ul><li>Add 210(8,13) </li></ul></ul><ul><ul><li>Machine-dependent </li></ul></ul>
  32. 32. 3 rd Generation Languages <ul><li>High Level Languages (HLL), e.g., C# </li></ul><ul><ul><li>Average = (Ex1 + Ex2 + Ex3) / 3; </li></ul></ul><ul><li>2 main programming paradigms </li></ul><ul><ul><ul><li>Procedural (PP) </li></ul></ul></ul><ul><ul><ul><ul><li>C, COBOL, Fortran, Basic, ... , </li></ul></ul></ul></ul><ul><ul><ul><ul><li>any OOP can do PP </li></ul></ul></ul></ul><ul><ul><ul><li>Object-oriented (OOP) </li></ul></ul></ul><ul><ul><ul><ul><li>C#, Java, C++, Visual Basic.NET </li></ul></ul></ul></ul>
  33. 33. Compiler <ul><li>HLL program  [compiler]  ML program </li></ul><ul><li>Hello.cs  C# compiler  Hello.exe </li></ul><ul><li>(source code) (executable) </li></ul>
  34. 34. 4 th & 5 th Generation Languages <ul><li>Application-specific Languages </li></ul><ul><ul><li>e.g., SQL for DBS </li></ul></ul><ul><ul><li>Select name, phone from student </li></ul></ul><ul><ul><ul><li>where major = “CS” and state = “MI”; </li></ul></ul></ul><ul><li>Natural Languages (English, . . .) </li></ul><ul><ul><li>If patient is age 65 or older </li></ul></ul><ul><ul><li>and is disoriented </li></ul></ul><ul><ul><li>and has pain in his/her left arm </li></ul></ul><ul><ul><li>then patient could have had a heart attack </li></ul></ul>

×