Presentation is loading. Please wait.

Presentation is loading. Please wait.

Key Ideas from day 1 slides

Similar presentations


Presentation on theme: "Key Ideas from day 1 slides"— Presentation transcript:

1 Key Ideas from day 1 slides
CS Kaminski

2 Program (app) Software Program recipe
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 HW SW see/hear  think & remember  speak/write
mouse/KB …  CPU & RAM & disk  screen, … SW data  process & store  data (user/file/DB) (user/file/DB) ^^^^^^^^^^^^^ “the PROGRAM”

7 IPO (IPSO) PROGRAM program’s METHOD
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 }

10 Procedural Programming (PP)
program = set of procedures procedure (= method) NAMED set 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: = problem-solving   solution
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 … + 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 for a specific CPU / OS [simplistically]
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 file into 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 Text editor (or IDE) Source code (.java)
saves Java statements Java compiler (javac) is read by Byte code (.class) produces Java Virtual Machine (java) is interpreted by Program Execution results in

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


Download ppt "Key Ideas from day 1 slides"

Similar presentations


Ads by Google