1 / 25

Key Ideas from day 1 slides

Key Ideas from day 1 slides. CS1110 - Kaminski. Program (app). Software Makes computer “smart” controls HW hides most HW (& low-level SW) from user s olution to a problem Program recipe detailed step-by-step set of instructions tells computer exactly what to do processes data.

lehner
Télécharger la présentation

Key Ideas from day 1 slides

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Key Ideasfrom day 1 slides CS1110 - Kaminski

  2. Program (app) Software • Makes computer “smart” • controls HW • hides most HW (& low-level SW) from user • solution to a problem Program • recipe • detailed step-by-step set of instructions • tells computer exactly what to do • processes data

  3. Programming = Problem solving • Understand problem & requirements - I P O • Design modular program • Design algorithms • Code solution • Test & debug

  4. algorithm written in pseudocode(or flowchart or . . .) pseudocode implemented in high level language (Java or …) (source code) source code translated into machine language (all 0’s and 1’s) by a compiler

  5. IPO (IPSO) Input  Processing  Output & Storing

  6. IPO (IPSO) HUMAN see/hear think & remember  speak/write HW mouse/KB …  CPU & RAM & disk  screen, … SW data process & store  data (user/file/DB) (user/file/DB) ^^^^^^^^^^^^^ “the PROGRAM”

  7. IPO(IPSO) PROGRAM user input process & store  screen display mouse clicks  DB data in a form  program’s METHOD input parameters procedure  return value [& local variables] [& class’s instance variables]

  8. Modular programming Program = a collection of small modules module: • (in Procedural Programming) an IPSO procedure (or function) • (in Object Oriented Programming) • a Class (object) • a IPSO method (~ a procedure) in a class Programming = write modules • Top-down or bottom-up

  9. Structured Programming methods made from STACKING & NESTING: • Sequence do action1 do action2 ... 2) Selection if conditionX is true then do action1 ... else do action2 ... 3) Repetition while conditionY is true then { do action1 do action2 ... }

  10. Procedural Programming (PP) program = set of procedures procedure (= method) NAMEDset of statements which do a specific task procedure data passed IN to it (from caller) it PROCESSES data it sends results data OUT (to caller)

  11. Object-Oriented Programming (OOP) focus: create objects (vs. procedures) Object = both Data = attributes of object Procedures = methods - behaviors of object - services users of object might need

  12. Programming Determine: • WHAT needs to be done • HOW to do it (algorithm) = problem-solving   solution • Solve the right problem AND • Solve the problem right

  13. Steps in programming • Requirements specification [what] I P O • Program design [how] I P S O, algorithm, modules, GUI • Coding [Java] • Test & debug • compile errors / logic errors / runtime errors • validate output results • Document • Maintenance

  14. A Good Program • gives correct output • follows client/designer’s specs • functionality • output • runs fast • is compact (space) • clear & easy to change

  15. Algorithm (P of IPSO) EXAMPLE: find sum of 1st 100 integers User view: BLACK box Programmer view: WHITE (“clear”) box ( actual code) Which algorithm? • Look up - table / file / DB • Ask - crowdsource micro-task on internet • Calculate – Algor. A 1 + 2 + 3 + … + 100 • Calculate – Algor. B (100 * (100+1)) / 2

  16. Basic Program Operations 1) Actual Work • arithmetic (+ - * / %) • comparison ( == < > and, or, not) 2) Move/store data • Assignment (=) memory  memory • I/O (read) keyboard /mouse/touchscreen/file/…  memory • I/O (write) memory  screen/printer/file/…

  17. 3) Control flow(next instruction to run) • default: next line • maybe do next line(s) (if, switch) • do next line(s) multiple times (loop) • go to line elsewhere & return here (call) 4) Packaging • method headers • class headers

  18. Why Java? “cross platform” - portable program written for 1 type of device/HW/OS runs on ANY OTHER device/HW/OS without rewriting/recompiling program

  19. Compiler (traditional) Compiler = a program (IPO) translates: Input data: source code file Output data: machine language file also finds syntax errors spelling, grammar, structure errors that violate rules of that language .

  20. write program in high-level lang. (BASIC, C, C++, COBOL,…) using text editor or IDE save it as a source code file compiler translates source code fileinto executable code file (SomeProgramName.exe) for a specific CPU / OS[simplistically]

  21. Java compiler compiler translates Java source file (.java) into file containing byte code instructions(.class) byte code instructions: the “machine language” of the Java Virtual Machine (JVM)[these can NOT be executed directly by a CPU]

  22. JVM program that emulates a hardware CPU JVM executes each byte code instruction, as it’s read (unlike a compiler that produces .exe file) Java = an interpreted language

  23. Program Development Source code (.java) saves Java statements is read by Byte code(.class) Java compiler (javac) produces is interpreted by Program Execution Java Virtual Machine (java) results in Text editor (or IDE)

  24. Java programs portable program written for 1 type of computer runs on wide variety of computers (with little/no modification) (e.g., applets from web) “compiled” Java .class program portable specific JVM’s exist for many platforms: Windows, Mac, Linux, etc.

  25. 2 ways to compile Java program command-prompt (B&W) window javac is Java compiler (for specific JVM) to compile: javac SomeProgram.java IDE automates (& hides) this icon to build (instead of compile) automatic build when program is run

More Related