Software Construction

Size: px
Start display at page:

Download "Software Construction"

Transcription

1 Lecture 2: Decomposition and Java Methods Software Construction in Java for HSE Moscow Tom Verhoeff Eindhoven University of Technology Department of Mathematics & Computer Science Software Engineering & Technology Group wstomv/edu/sc-hse c 2014, T. TUE.NL 1/48 Software Construction: Lecture 2

2 Overview Feedback on Series 1 Manage complexity by Divide and Conquer Java methods Procedural abstraction Functional decomposition Assignments for Series 2 c 2014, T. TUE.NL 2/48 Software Construction: Lecture 2

3 Registration in peach students joined the course in peach 3 (expected 103) Please, provide all information about your name This will be used on your certificate! Example: Wernher Magnus Maximilian von Braun First name = Given name: Wernher Initials: W.M.M. Connectives (mostly for Dutch/German names): von Family Name: Braun Fix this, if it is not OK Bad name No grade c 2014, T. TUE.NL 3/48 Software Construction: Lecture 2

4 Automatic Feedback by peach 3 Mostly disabled before the deadline Enabled after the deadline Check peach 3 feedback; read the explanation: Proper files, cut line, etc. Diff with given files Checkstyle audit Javadoc (in the future) Compilation Test runs c 2014, T. TUE.NL 4/48 Software Construction: Lecture 2

5 Assignments Are to Be Made Individually All assignments must be made individually Do not copy each other s work peach 3 compares all submitted work peach 3 discovered some (nearly) identical copies c 2014, T. TUE.NL 5/48 Software Construction: Lecture 2

6 Statistics for Series 1 Candy 99 submissions 14 open test run 0 secret test runs 83 with 14 points 6 with 13 points 2 with 12 points 6 with 11 points 1 with 3 points 0 rejected DiceGame 97 submissions 6 open test run 0 secret test runs 86 with 6 points 11 with 4 points 0 rejected All test runs are now open c 2014, T. TUE.NL 6/48 Software Construction: Lecture 2

7 General Remarks and Observations Deadlines are hard and are enforced by peach 3 Be disciplined: Set yourself an earlier deadline Place your code at indicated comments only, and nowhere else No package statement allowed; preserve the --8<-- Submit your *.java source file, not *.class, *.rar Use the given class name and file name (= class name +.java) Unless otherwise stated, you may assume that input is valid There was no need to check input validity Suppress your built-in testing code : delete or comment out c 2014, T. TUE.NL 7/48 Software Construction: Lecture 2

8 Coding Standard Not all submissions adhered to the coding standard Some were very sloppy Why adhere to a coding standard? You will make fewer mistakes: sloppy coding = sloppy thinking If you make mistakes, you find them more easily and quickly If you cannot find them yourself, others can help you better Business perspective: When sued, you have a better court case Review the Coding Standard for 2IP15 c 2014, T. TUE.NL 8/48 Software Construction: Lecture 2

9 Coding Idiom Condition b == false is better written as! b (say: not b) Use else to make intention explicit: if (a < b) { S1; } if (a == b) { S2; } if (a < b) { S1; } else if (a == b) { S2; } else { // a > b // do nothing (on purpose) } What if, later, S1 is adapted to modify variables a, b? Be prepared for future evolution of software! c 2014, T. TUE.NL 9/48 Software Construction: Lecture 2

10 Candy Avoid floating-point arithmetic; instead, use % (modulo) operator Avoid division by zero The case divide(0, 0): Consider the equation c == k * q with unknown q Consider two cases: k == 0 and k!= 0 If k == 0, then the equation reduces to c == 0 What does that mean? There are two subcases! Also k!= 0 has two subcases c 2014, T. TUE.NL 10/48 Software Construction: Lecture 2

11 DiceGame Use java.util.random random 0 <= random.nextint(k) < k How to roll two dice? How to roll a dodecahedron? How to determine the round outcome? How to administrate winning counts? Sum of counts = number of rounds (peach 3 tests for this) c 2014, T. TUE.NL 11/48 Software Construction: Lecture 2

12 How to create something big and complex? Engineering, technology Science How to be in control? How to improve probability of success? c 2014, T. TUE.NL 12/48 Software Construction: Lecture 2

13 How to create something big and complex? There are two ways of constructing a software design: one way is to make it so simple that there are obviously no deficiencies, and the other is to make it so complicated that there are no obvious deficiencies. C. A. R. Hoare (winner of Turing Award 1980) c 2014, T. TUE.NL 13/48 Software Construction: Lecture 2

14 The Essence of Engineering [I]t is the essence of modern engineering not only to be able to check one s own work, but also to have one s work checked and to be able to check the work of others. In order for this to be done, the work must follow certain conventions, conform to certain standards, and be an understandable piece of technical communication. H. Petroski. To Engineer is Human: The Role of Failure in Successful Design. Vintage Books, c 2014, T. TUE.NL 14/48 Software Construction: Lecture 2

15 Procedural Abstraction See Chapter 4 (Subroutines) of Eck, especially 4.1 through 4.4 c 2014, T. TUE.NL 15/48 Software Construction: Lecture 2

16 Monolithic Programs The imperative core of Java, consisting of types, values, variables, expressions, assignment, selection, repetition allows you to express every computation! However, in that case, programs are monolithic, without explicit structure, unmanageable c 2014, T. TUE.NL 16/48 Software Construction: Lecture 2

17 Manage Complexity Technique: Divide and Conquer General problem solving technique: 1. Split problem into subproblems ( Decomposition ) 2. Solve subproblems independently ( Recursion possible) 3. Combine subproblem solutions into total solution ( Integration ) c 2014, T. TUE.NL 17/48 Software Construction: Lecture 2

18 Problems and Solutions in Java Wrapped-up solutions in Java can take the form of methods classes packages... c 2014, T. TUE.NL 18/48 Software Construction: Lecture 2

19 Divide and Conquer with Java Methods Specify a subproblem Divide Syntax: method name, (formal) parameters, return type Semantics: Contract with pre/post assumptions/obligations Create (design and implement) subproblem solution Conquer Method body Use subproblem solutions and Rule Method invocations with arguments (actual parameters) Hierarchical (recursive) subdivision: Create subproblem solution by using subsubproblem solutions c 2014, T. TUE.NL 19/48 Software Construction: Lecture 2

20 Java Methods modifiers return type name ( parameters ) { statements } procedure : return type void, used as statement (a.k.a. command) function : return type not void, used as expression (a.k.a. query, inspector) parameters : name, type, final or not, modified or not order of parameters variables : local versus global aliasing : different names referring to the same entity c 2014, T. TUE.NL 20/48 Software Construction: Lecture 2

21 Manage Complexity Why: Intellectual limits of human beings, concerning productivity, memory, communication, accuracy,... Some related concepts: Divide & Conquer Separation of Concerns Decomposition Modularization Encapsulation Abstraction c 2014, T. TUE.NL 21/48 Software Construction: Lecture 2

22 Abstraction To abstract from something Ignore/suppress distinctions that are considered irrelevant Separate relevant from irrelevant details Example: Identify fractions a/b and c/d (b 0 d) when ad = bc Set Theory: equivalence relation, equivalence class, quotient set Abstract from how a subproblem is solved, through a specification Abstract from which subproblem is solved, through parameters Abstract from how a solution will be used c 2014, T. TUE.NL 22/48 Software Construction: Lecture 2

23 Abstraction Example: Rectangle Problem On input are 6 integers, representing three points in a Cartesian coordinate system, for each point first the x- and then the y-coordinate. The first two points designate a rectangle with sides parallel to the axes. The first point is the top left corner of the rectangle, the second point is the bottom right corner. The program has to decide whether the third point is inside the rectangle (including the edges) or outside. The program should output an error message if the rectangle is ill-defined, i.e., if the second point is not to the right of and below the first point. The program may assume that no other errors occur in the input. c 2014, T. TUE.NL 23/48 Software Construction: Lecture 2

24 Abstraction Example: Monolithic Solution, Variables 1 // Monolithic solution 2 3 import java.util.scanner; // for input 4 5 class Rectangle1 { 6 7 static Scanner scanner; // input source 8 static int tlx; // top left x 9 static int tly; // top left y 10 static int brx; // bottom right x 11 static int bry; // bottom right y 12 static int px; // point x 13 static int py; // point y c 2014, T. TUE.NL 24/48 Software Construction: Lecture 2

25 Abstraction Example: Monolithic Solution, Method 15 static void dorectangle() { 16 scanner = new Scanner(System.in); 17 tlx = scanner.nextint(); 18 tly = scanner.nextint(); 19 brx = scanner.nextint(); 20 bry = scanner.nextint(); 21 px = scanner.nextint(); 22 py = scanner.nextint(); if (tlx > brx tly > bry) { 25 System.out.println("error"); 26 return; 27 } 28 // tlx <= brx && tly <= bry c 2014, T. TUE.NL 25/48 Software Construction: Lecture 2

26 Abstraction Example: Monolithic Solution, Method 29 if (tlx <= px && px <= brx && tly <= py && py <= bry) { 30 System.out.println("inside"); 31 } else { 32 System.out.println("outside"); 33 } 34 } c 2014, T. TUE.NL 25/48 Software Construction: Lecture 2

27 Abstraction Example: Separate Methods, Top Level + Output 15 static void dorectangle() { 16 scanner = new Scanner(System.in); 17 readinput(); if (! isvalidrectangle()) { 20 System.out.println("error"); 21 return; 22 } 23 // input rectangle is valid 24 if (ispointinsiderectangle()) { 25 System.out.println("inside"); 26 } else { 27 System.out.println("outside"); 28 } 29 } c 2014, T. TUE.NL 26/48 Software Construction: Lecture 2

28 Abstraction Example: Separate Methods, Input 31 // Read input into tlx,..., py via scanner 32 static void readinput() { 33 tlx = scanner.nextint(); 34 tly = scanner.nextint(); 35 brx = scanner.nextint(); 36 bry = scanner.nextint(); 37 px = scanner.nextint(); 38 py = scanner.nextint(); 39 } Note that readinput() operates on the global variables. c 2014, T. TUE.NL 27/48 Software Construction: Lecture 2

29 Abstraction Example: Separate Methods, Calculations 1 // Returns whether tlx,..., bry is a rectangle 2 static boolean isvalidrectangle() { 3 return tlx <= brx && tly <= bry; 4 } 5 6 // Returns whether px, py is inside rectangle tlx,..., bry 7 static boolean ispointinsiderectangle() { 8 return tlx <= px && px <= brx && tly <= py && py <= bry; 9 } Note that these methods also operate on the global variables. c 2014, T. TUE.NL 28/48 Software Construction: Lecture 2

30 Abstraction Example: Dependence Diagram 1 dorectangle() Scanner() readinput() isvalidrectangle() ispointinsiderectangle() System.out.println() scanner, tlx, tly, brx, bry, px, py c 2014, T. TUE.NL 29/48 Software Construction: Lecture 2

31 Dependence Diagrams Thinking in terms of dependencies is key to good design. A B means A depends on B When code of B changes, code of A may also have to change Code of A can change, without affecting code of B When reusing code of A, also code of/like B is needed When reusing code of B, code of A is not needed c 2014, T. TUE.NL 30/48 Software Construction: Lecture 2

32 Abstraction Example: Now with Parameters 14 static void dorectangle() { 15 readinput(new Scanner(System.in)); if (! isvalidrectangle(tlx, tly, brx, bry)) { 18 System.out.println("error"); 19 return; 20 } 21 // input rectangle is valid 22 if (ispointinsiderectangle(tlx, tly, brx, bry, 23 px, py)) { 24 System.out.println("inside"); 25 } else { 26 System.out.println("outside"); 27 } 28 } c 2014, T. TUE.NL 31/48 Software Construction: Lecture 2

33 Abstraction Example: Separate Methods, Input 30 // Read input into global tlx,..., py via scanner 31 static void readinput(scanner scanner) { 32 tlx = scanner.nextint(); 33 tly = scanner.nextint(); 34 brx = scanner.nextint(); 35 bry = scanner.nextint(); 36 px = scanner.nextint(); 37 py = scanner.nextint(); 38 } Note that readinput() still operates on the global variables. (In Java, this is harder to avoid.) c 2014, T. TUE.NL 32/48 Software Construction: Lecture 2

34 Abstraction Example: Separate Methods, Calculations 1 // Returns whether tlx,..., bry is a rectangle 2 static boolean isvalidrectangle(int tlx, int tly, 3 int brx, int bry) { 4 return tlx <= brx && tly <= bry; 5 } 6 7 // Returns whether x, y is inside rectangle tlx,..., bry 8 static boolean ispointinsiderectangle(int tlx, int tly, 9 int brx, int bry, 10 int x, int y) { 11 return tlx <= x && x <= brx && tly <= y && y <= bry; 12 } Note that these methods now do not involve the global variables. Instead, they operate on parameters only. c 2014, T. TUE.NL 33/48 Software Construction: Lecture 2

35 Abstraction Example: Dependence Diagram 2 dorectangle() Scanner() readinput() isvalidrectangle() ispointinsiderectangle() System.out.println() tlx, tly, brx, bry, px, py c 2014, T. TUE.NL 34/48 Software Construction: Lecture 2

36 Abstraction Example: Separate Methods, Aux Calculation 47 // Returns whether tlx,..., bry is a rectangle 48 static boolean isvalidrectangle(int tlx, int tly, 49 int brx, int bry) { 50 return isdominated(tlx, tly, brx, bry); 51 } // Returns whether x, y is inside rectangle tlx,..., bry 54 static boolean ispointinsiderectangle(int tlx, int tly, 55 int brx, int bry, 56 int x, int y) { 57 return isdominated(tlx, tly, x, y) && 58 isdominated(x, y, brx, bry); 59 } // Returns whether ax, ay is dominated by bx, by 62 static boolean isdominated(int ax, int ay, int bx, int by) { 63 return ax <= bx && ay <= by; 64 } c 2014, T. TUE.NL 35/48 Software Construction: Lecture 2

37 Abstraction Example: Dependence Diagram 3 dorectangle() Scanner() readinput() isvalidrectangle() ispointinsiderectangle() isdominated() System.out.println() tlx, tly, brx, bry, px, py c 2014, T. TUE.NL 36/48 Software Construction: Lecture 2

38 Abstraction Example (cont d) Separate input, calculations, and output Parameterize methods N.B. In this style, it is harder to parameterize readinput further, because Java has no output parameters, only return values. No Java method with parameters v, E equivalent to v := E exists. readinput() could return an array, but then the indexing would be awkward. Separate classes for rectangles and points is the Java way. Doing output could be separated from the top-level coordination, using a string result. c 2014, T. TUE.NL 37/48 Software Construction: Lecture 2

39 Guidelines for Functional Decomposition: Cohesion Maximize cohesion Cohesion = measure of relatedness of things inside a module Keep related things together; separate unrelated things c 2014, T. TUE.NL 38/48 Software Construction: Lecture 2

40 Guidelines for Functional Decomposition: Coupling Minimize coupling, also stated as minimize dependency Coupling = measure of connectedness between modules Interface of a module concerns all its external connections Consider both number and nature of dependencies: GOOD : via parameter OK : use constant, type, (variable,) method defined elsewhere BAD : implicit common knowledge (file name in string literal) BAD : global variables c 2014, T. TUE.NL 39/48 Software Construction: Lecture 2

41 Guidelines for Functional Decomposition (cont d) Each function should solve a single well-defined problem If purpose is difficult to describe, then something is wrong (Describe purpose on the right level of data abstraction!) Limit the size of the interface, i.e., number of parameters Possibly combine parameters (in a new class, representing a new concept, raising the level of abstraction) [NOT THIS WEEK] Each function should have a small implementation No more than a (few) dozen lines, with limited nesting depth If it tends to become larger, consider subdivision Nested control structures should invite further subdivision, especially nested loops c 2014, T. TUE.NL 40/48 Software Construction: Lecture 2

42 Generalization Consider possibilities for generalization : solving a more general problem than (initially) required. Generalization improves (re)usability and insight. It can also simplify solution! Generalize by means of parameters, not via global variables. Parameters abstract from the identity of the data. Code duplication should invite refactoring by parameterization. Decomposing a problem into simpler versions of itself gives rise to recursion. Weigh benefits against costs: too general makes use costly. c 2014, T. TUE.NL 41/48 Software Construction: Lecture 2

43 Generalization Example How many regions are created when space is cut by five arbitrary planes? Arbitrary means: No two planes are parallel, and no three planes have a point in common. c 2014, T. TUE.NL 42/48 Software Construction: Lecture 2

44 Generalization Example How many regions are created when space is cut by five arbitrary planes? Arbitrary means: No two planes are parallel, and no three planes have a point in common. Parameterize on number of planes N c 2014, T. TUE.NL 42/48 Software Construction: Lecture 2

45 Generalization Example How many regions are created when space is cut by five arbitrary planes? Arbitrary means: No two planes are parallel, and no three planes have a point in common. Parameterize on number of planes N Parameterize on dimension D of space to be divided : D = 1 line, D = 2 plane, D = 3 space c 2014, T. TUE.NL 42/48 Software Construction: Lecture 2

46 Generalization Example: Solution R(D, N) = # regions in D-space when cut by N arbitrary D 1-spaces c 2014, T. TUE.NL 43/48 Software Construction: Lecture 2

47 Generalization Example: Solution R(D, N) = # regions in D-space when cut by N arbitrary D 1-spaces R(D, 0) = 1 (when not divided) R(1, N) = N + 1 (a line divided by N points) R(D, N) = R(D, N 1) + R(D 1, N 1) if 2 D and 1 N c 2014, T. TUE.NL 43/48 Software Construction: Lecture 2

48 Generalization Example: Solution R(D, N) = # regions in D-space when cut by N arbitrary D 1-spaces R(D, 0) = 1 (when not divided) R(1, N) = N + 1 (a line divided by N points) R(D, N) = R(D, N 1) + R(D 1, N 1) if 2 D and 1 N R(D, N) N D c 2014, T. TUE.NL 43/48 Software Construction: Lecture 2

49 Typical Purposes of Functions Input, calculate, output Parse, convert, format De-nest (disentangle) control structures Initialize, query, update, finalize Check condition Create, delete Coordinate activities, handle events Abstract from the way data is represented c 2014, T. TUE.NL 44/48 Software Construction: Lecture 2

50 Function Names, Parameter Order Use verb-plus-noun, but avoid overly general words: processinput Do not include the object name that this refers to In class Document do not name a method printdocument Function name should reflect returned value Procedure name should reflect postcondition Short parameter names facilitate writing of specifications Parameter order: 1 input-only, 2 input-and-output, 3 output-only (status and error information last). c 2014, T. TUE.NL 45/48 Software Construction: Lecture 2

51 Assignments Series 2 Improve your Candy program Complete the decomposition for DiceGame Answer some open questions (in preparation of written exam) c 2014, T. TUE.NL 46/48 Software Construction: Lecture 2

52 Before Submitting Work for Assignments in peach 3 Code adheres to Coding Standard for 2IP15 Include author name, group ID, date, above cut line with --8<-- Check your code: read it and test it c 2014, T. TUE.NL 47/48 Software Construction: Lecture 2

53 Summary Why adhere to a coding standard Manage complexity by Divide and Conquer Java methods, with parameters Guidelines for functional decomposition c 2014, T. TUE.NL 48/48 Software Construction: Lecture 2

2IP15 Programming Methods

2IP15 Programming Methods Lecture 1: Introduction, Functional Decomposition 2IP15 Programming Methods From Small to Large Programs Tom Verhoeff Eindhoven University of Technology Department of Mathematics & Computer Science Software

More information

Software Construction

Software Construction Lecture 1: Introduction Software Construction in Java for HSE Moscow Tom Verhoeff Eindhoven University of Technology Department of Mathematics & Computer Science Software Engineering & Technology Group

More information

The following topics will be covered in this course (not necessarily in this order).

The following topics will be covered in this course (not necessarily in this order). The following topics will be covered in this course (not necessarily in this order). Introduction The course focuses on systematic design of larger object-oriented programs. We will introduce the appropriate

More information

EINDHOVEN UNIVERSITY OF TECHNOLOGY

EINDHOVEN UNIVERSITY OF TECHNOLOGY EINDHOVEN UNIVERSITY OF TECHNOLOGY Department of Mathematics & Computer Science Exam Programming Methods, 2IP15, Wednesday 17 April 2013, 09:00 12:00 TU/e THIS IS THE EXAMINER S COPY WITH (POSSIBLY INCOMPLETE)

More information

Software Construction

Software Construction Lecture 7: Type Hierarchy, Iteration Abstraction Software Construction in Java for HSE Moscow Tom Verhoeff Eindhoven University of Technology Department of Mathematics & Computer Science Software Engineering

More information

Software Construction

Software Construction Lecture 11: Command Design Pattern Software Construction in Java for HSE Moscow Tom Verhoeff Eindhoven University of Technology Department of Mathematics & Computer Science Software Engineering & Technology

More information

Controls Structure for Repetition

Controls Structure for Repetition Controls Structure for Repetition So far we have looked at the if statement, a control structure that allows us to execute different pieces of code based on certain conditions. However, the true power

More information

2IP15 Programming Methods

2IP15 Programming Methods Lecture 5: Iteration Abstraction 2IP15 Programming Methods From Small to Large Programs Tom Verhoeff Eindhoven University of Technology Department of Mathematics & Computer Science Software Engineering

More information

CS111: PROGRAMMING LANGUAGE II

CS111: PROGRAMMING LANGUAGE II 1 CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 1: Introduction Lecture Contents 2 Course info Why programming?? Why Java?? Write once, run anywhere!! Java basics Input/output Variables

More information

Software Construction

Software Construction Lecture 5: Robustness, Exceptions Software Construction in Java for HSE Moscow Tom Verhoeff Eindhoven University of Technology Department of Mathematics & Computer Science Software Engineering & Technology

More information

Functional Programming. Big Picture. Design of Programming Languages

Functional Programming. Big Picture. Design of Programming Languages Functional Programming Big Picture What we ve learned so far: Imperative Programming Languages Variables, binding, scoping, reference environment, etc What s next: Functional Programming Languages Semantics

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 3 Thomas Wies New York University Review Last week Names and Bindings Lifetimes and Allocation Garbage Collection Scope Outline Control Flow Sequencing

More information

CSE101-lec#12. Designing Structured Programs Introduction to Functions. Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU

CSE101-lec#12. Designing Structured Programs Introduction to Functions. Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU CSE101-lec#12 Designing Structured Programs Introduction to Functions Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU Outline Designing structured programs in C: Counter-controlled repetition

More information

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011 CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics Dan Grossman Spring 2011 Review e ::= λx. e x e e c v ::= λx. e c τ ::= int τ τ Γ ::= Γ, x : τ (λx. e) v e[v/x] e 1 e 1 e 1 e

More information

Programming Logic and Design Seventh Edition Chapter 2 Elements of High-Quality Programs

Programming Logic and Design Seventh Edition Chapter 2 Elements of High-Quality Programs Programming Logic and Design Chapter 2 Elements of High-Quality Programs Objectives In this chapter, you will learn about: Declaring and using variables and constants Assigning values to variables [assignment

More information

CPS122 Lecture: From Python to Java last revised January 4, Objectives:

CPS122 Lecture: From Python to Java last revised January 4, Objectives: Objectives: CPS122 Lecture: From Python to Java last revised January 4, 2017 1. To introduce the notion of a compiled language 2. To introduce the notions of data type and a statically typed language 3.

More information

CS 142 Style Guide Grading and Details

CS 142 Style Guide Grading and Details CS 142 Style Guide Grading and Details In the English language, there are many different ways to convey a message or idea: some ways are acceptable, whereas others are not. Similarly, there are acceptable

More information

Big Ideas. Chapter Computational Recipes

Big Ideas. Chapter Computational Recipes Chapter 1 Big Ideas This course is an introduction to programming and problem solving. We shall focus on some big ideas of computer science key themes that are seen again and again throughout the discipline.

More information

CS 302: Introduction to Programming

CS 302: Introduction to Programming CS 302: Introduction to Programming Lectures 2-3 CS302 Summer 2012 1 Review What is a computer? What is a computer program? Why do we have high-level programming languages? How does a high-level program

More information

CPS122 Lecture: From Python to Java

CPS122 Lecture: From Python to Java Objectives: CPS122 Lecture: From Python to Java last revised January 7, 2013 1. To introduce the notion of a compiled language 2. To introduce the notions of data type and a statically typed language 3.

More information

WELCOME! (download slides and.py files and follow along!) LECTURE 1

WELCOME! (download slides and.py files and follow along!) LECTURE 1 WELCOME! (download slides and.py files and follow along!) 6.0001 LECTURE 1 6.0001 LECTURE 1 1 TODAY course info what is computation python basics mathematical operations python variables and types NOTE:

More information

CHAPTER 5 GENERAL OOP CONCEPTS

CHAPTER 5 GENERAL OOP CONCEPTS CHAPTER 5 GENERAL OOP CONCEPTS EVOLUTION OF SOFTWARE A PROGRAMMING LANGUAGE SHOULD SERVE 2 RELATED PURPOSES : 1. It should provide a vehicle for programmer to specify actions to be executed. 2. It should

More information

Session 4b: Review of Program Quality

Session 4b: Review of Program Quality Session 4b: Review of Program Quality What makes one program "better" than another? COMP 170 -- Fall, 2013 Mr. Weisert What is a good program? Suppose we give the same assignment to two programmers (or

More information

Data and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence

Data and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence Data and Variables Data Types Expressions Operators Precedence String Concatenation Variables Declaration Assignment Shorthand operators Review class All code in a java file is written in a class public

More information

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

CSE 331 Software Design & Implementation

CSE 331 Software Design & Implementation CSE 331 Software Design & Implementation Hal Perkins Winter 2018 Module Design and General Style Guidelines UW CSE 331 Winter 2018 1 Style Use the active voice. Omit needless words. Don't patch bad code

More information

More Things We Can Do With It! Overview. Circle Calculations. πr 2. π = More operators and expression types More statements

More Things We Can Do With It! Overview. Circle Calculations. πr 2. π = More operators and expression types More statements More Things We Can Do With It! More operators and expression types More s 11 October 2007 Ariel Shamir 1 Overview Variables and declaration More operators and expressions String type and getting input

More information

CS125 : Introduction to Computer Science. Lecture Notes #4 Type Checking, Input/Output, and Programming Style

CS125 : Introduction to Computer Science. Lecture Notes #4 Type Checking, Input/Output, and Programming Style CS125 : Introduction to Computer Science Lecture Notes #4 Type Checking, Input/Output, and Programming Style c 2005, 2004, 2002, 2001, 2000 Jason Zych 1 Lecture 4 : Type Checking, Input/Output, and Programming

More information

Example Program. public class ComputeArea {

Example Program. public class ComputeArea { COMMENTS While most people think of computer programs as a tool for telling computers what to do, programs are actually much more than that. Computer programs are written in human readable language for

More information

COMP 202 Java in one week

COMP 202 Java in one week CONTENTS: Basics of Programming Variables and Assignment Data Types: int, float, (string) Example: Implementing a calculator COMP 202 Java in one week The Java Programming Language A programming language

More information

ECE 122. Engineering Problem Solving with Java

ECE 122. Engineering Problem Solving with Java ECE 122 Engineering Problem Solving with Java Lecture 14 Array Wrap-Up Outline Problem: How can I store information in arrays without complicated array management? The Java language supports ArrayLists

More information

Programming with Java

Programming with Java Programming with Java Data Types & Input Statement Lecture 04 First stage Software Engineering Dep. Saman M. Omer 2017-2018 Objectives q By the end of this lecture you should be able to : ü Know rules

More information

Readability [Skrien 4.0] Programs must be written for people to read, and only incidentally for machines to execute.

Readability [Skrien 4.0] Programs must be written for people to read, and only incidentally for machines to execute. Readability [Skrien 4.0] Programs must be written for people to read, and only incidentally for machines to execute. Abelson & Sussman Use a good set of coding conventions, such as the ones given in the

More information

Programming Constructs Overview. Method Call System.out.print( hello ); Method Parameters

Programming Constructs Overview. Method Call System.out.print( hello ); Method Parameters Programming Constructs Overview Method calls More selection statements More assignment operators Conditional operator Unary increment and decrement operators Iteration statements Defining methods 27 October

More information

Introduction to Computer Programming

Introduction to Computer Programming Introduction to Computer Programming Lecture 2- Primitive Data and Stepwise Refinement Data Types Type - A category or set of data values. Constrains the operations that can be performed on data Many languages

More information

How invariants help writing loops Author: Sander Kooijmans Document version: 1.0

How invariants help writing loops Author: Sander Kooijmans Document version: 1.0 How invariants help writing loops Author: Sander Kooijmans Document version: 1.0 Why this document? Did you ever feel frustrated because of a nasty bug in your code? Did you spend hours looking at the

More information

Programming Languages and Compilers Qualifying Examination. Answer 4 of 6 questions.

Programming Languages and Compilers Qualifying Examination. Answer 4 of 6 questions. Programming Languages and Compilers Qualifying Examination Fall 2017 Answer 4 of 6 questions. GENERAL INSTRUCTIONS 1. Answer each question in a separate book. 2. Indicate on the cover of each book the

More information

OOPs: The Harsh Realities of Programming

OOPs: The Harsh Realities of Programming Division of Mathematics and Computer Science Maryville College Outline Course Overview 1 Course Overview 2 3 4 Preliminaries Course Overview Required Materials Big C++ 2nd Edition by Cay Horstmann An Account

More information

Control Structures. Lecture 4 COP 3014 Fall September 18, 2017

Control Structures. Lecture 4 COP 3014 Fall September 18, 2017 Control Structures Lecture 4 COP 3014 Fall 2017 September 18, 2017 Control Flow Control flow refers to the specification of the order in which the individual statements, instructions or function calls

More information

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018 Object-oriented programming 1 and data-structures CS/ENGRD 2110 SUMMER 2018 Lecture 1: Types and Control Flow http://courses.cs.cornell.edu/cs2110/2018su Lecture 1 Outline 2 Languages Overview Imperative

More information

Lecture 1 Contracts. 1 A Mysterious Program : Principles of Imperative Computation (Spring 2018) Frank Pfenning

Lecture 1 Contracts. 1 A Mysterious Program : Principles of Imperative Computation (Spring 2018) Frank Pfenning Lecture 1 Contracts 15-122: Principles of Imperative Computation (Spring 2018) Frank Pfenning In these notes we review contracts, which we use to collectively denote function contracts, loop invariants,

More information

Object Oriented Programming with Java

Object Oriented Programming with Java Object Oriented Programming with Java What is Object Oriented Programming? Object Oriented Programming consists of creating outline structures that are easily reused over and over again. There are four

More information

CS111: PROGRAMMING LANGUAGE II

CS111: PROGRAMMING LANGUAGE II CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 1(c): Java Basics (II) Lecture Contents Java basics (part II) Conditions Loops Methods Conditions & Branching Conditional Statements A

More information

Programming Languages Third Edition

Programming Languages Third Edition Programming Languages Third Edition Chapter 12 Formal Semantics Objectives Become familiar with a sample small language for the purpose of semantic specification Understand operational semantics Understand

More information

6. Control Statements II

6. Control Statements II Visibility Declaration in a block is not visible outside of the block. 6. Control Statements II Visibility, Local Variables, While Statement, Do Statement, Jump Statements main block int main () int i

More information

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 24 Thursday, April 19, 2018 1 Error-propagating semantics For the last few weeks, we have been studying type systems.

More information

CSE 1223: Introduction to Computer Programming in Java Chapter 3 Branching

CSE 1223: Introduction to Computer Programming in Java Chapter 3 Branching CSE 1223: Introduction to Computer Programming in Java Chapter 3 Branching 1 Flow of Control The order in which statements in a program are executed is called the flow of control So far we have only seen

More information

Compiler Construction D7011E

Compiler Construction D7011E Compiler Construction D7011E Lecture 2: Lexical analysis Viktor Leijon Slides largely by Johan Nordlander with material generously provided by Mark P. Jones. 1 Basics of Lexical Analysis: 2 Some definitions:

More information

Data dependent execution order data dependent control flow

Data dependent execution order data dependent control flow Chapter 5 Data dependent execution order data dependent control flow The method of an object processes data using statements, e.g., for assignment of values to variables and for in- and output. The execution

More information

The return Statement

The return Statement The return Statement The return statement is the end point of the method. A callee is a method invoked by a caller. The callee returns to the caller if the callee completes all the statements (w/o a return

More information

CISC-124. This week we continued to look at some aspects of Java and how they relate to building reliable software.

CISC-124. This week we continued to look at some aspects of Java and how they relate to building reliable software. CISC-124 20180129 20180130 20180201 This week we continued to look at some aspects of Java and how they relate to building reliable software. Multi-Dimensional Arrays Like most languages, Java permits

More information

CMSC 330: Organization of Programming Languages. OCaml Imperative Programming

CMSC 330: Organization of Programming Languages. OCaml Imperative Programming CMSC 330: Organization of Programming Languages OCaml Imperative Programming CMSC330 Spring 2018 1 So Far, Only Functional Programming We haven t given you any way so far to change something in memory

More information

Introduction to Functional Programming in Haskell 1 / 56

Introduction to Functional Programming in Haskell 1 / 56 Introduction to Functional Programming in Haskell 1 / 56 Outline Why learn functional programming? The essence of functional programming What is a function? Equational reasoning First-order vs. higher-order

More information

Computer Programming

Computer Programming Computer Programming Introduction Marius Minea marius@cs.upt.ro http://cs.upt.ro/ marius/curs/cp/ 26 September 2017 Course goals Learn programming fundamentals no prior knowledge needed for those who know,

More information

Review. CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Let bindings (CBV) Adding Stuff. Booleans and Conditionals

Review. CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Let bindings (CBV) Adding Stuff. Booleans and Conditionals Review CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics e ::= λx. e x ee c v ::= λx. e c (λx. e) v e[v/x] e 1 e 2 e 1 e 2 τ ::= int τ τ Γ ::= Γ,x : τ e 2 e 2 ve 2 ve 2 e[e /x]:

More information

COMP 250: Java Programming I. Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette

COMP 250: Java Programming I. Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette COMP 250: Java Programming I Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette Variables and types [Downey Ch 2] Variable: temporary storage location in memory.

More information

Supplementary Test 1

Supplementary Test 1 Name: Please fill in your Student Number and Name. Student Number : Student Number: University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ 2009 Supplementary Test 1 Question

More information

Recursion 1. Recursion is the process of defining something in terms of itself.

Recursion 1. Recursion is the process of defining something in terms of itself. Recursion 1 Recursion is the process of defining something in terms of itself. A method that calls itself is said to be recursive. Recursion is an alternative form of program control. It is repetition

More information

CMSC 330: Organization of Programming Languages. Formal Semantics of a Prog. Lang. Specifying Syntax, Semantics

CMSC 330: Organization of Programming Languages. Formal Semantics of a Prog. Lang. Specifying Syntax, Semantics Recall Architecture of Compilers, Interpreters CMSC 330: Organization of Programming Languages Source Scanner Parser Static Analyzer Operational Semantics Intermediate Representation Front End Back End

More information

COMP 202. Java in one week

COMP 202. Java in one week COMP 202 CONTENTS: Basics of Programming Variables and Assignment Data Types: int, float, (string) Example: Implementing a calculator Java in one week The Java Programming Language A programming language

More information

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments. Java How to Program, 9/e Education, Inc. All Rights Reserved. } Java application programming } Use tools from the JDK to compile and run programs. } Videos at www.deitel.com/books/jhtp9/ Help you get started

More information

COMP-202 Unit 4: Programming with Iterations

COMP-202 Unit 4: Programming with Iterations COMP-202 Unit 4: Programming with Iterations Doing the same thing again and again and again and again and again and again and again and again and again... CONTENTS: While loops Class (static) variables

More information

Last Time. Introduction to Design Languages. Syntax, Semantics, and Model. This Time. Syntax. Computational Model. Introduction to the class

Last Time. Introduction to Design Languages. Syntax, Semantics, and Model. This Time. Syntax. Computational Model. Introduction to the class Introduction to Design Languages Prof. Stephen A. Edwards Last Time Introduction to the class Embedded systems Role of languages: shape solutions Project proposals due September 26 Do you know what you

More information

Procedural Abstraction

Procedural Abstraction Procedural Abstraction Comp-303 : Programming Techniques Lecture 5 Alexandre Denault Computer Science McGill University Winter 2004 February 16, 2004 Lecture 5 Comp 303 : Programming Techniques Page 1

More information

LECTURE 3: SOFTWARE DESIGN. Software Engineering Mike Wooldridge

LECTURE 3: SOFTWARE DESIGN. Software Engineering Mike Wooldridge LECTURE 3: SOFTWARE DESIGN Mike Wooldridge 1 Design Computer systems are not monolithic: they are usually composed of multiple, interacting modules. Modularity has long been seen as a key to cheap, high

More information

Concepts of Programming Languages

Concepts of Programming Languages Concepts of Programming Languages Lecture 10 - Object-Oriented Programming Patrick Donnelly Montana State University Spring 2014 Patrick Donnelly (Montana State University) Concepts of Programming Languages

More information

Exam 1 Format, Concepts, What you should be able to do, and Sample Problems

Exam 1 Format, Concepts, What you should be able to do, and Sample Problems CSSE 120 Introduction to Software Development Exam 1 Format, Concepts, What you should be able to do, and Sample Problems Page 1 of 6 Format: The exam will have two sections: Part 1: Paper-and-Pencil o

More information

Control Structures in Java if-else and switch

Control Structures in Java if-else and switch Control Structures in Java if-else and switch Lecture 4 CGS 3416 Spring 2017 January 23, 2017 Lecture 4CGS 3416 Spring 2017 Selection January 23, 2017 1 / 26 Control Flow Control flow refers to the specification

More information

4. Java Project Design, Input Methods

4. Java Project Design, Input Methods 4-1 4. Java Project Design, Input Methods Review and Preview You should now be fairly comfortable with creating, compiling and running simple Java projects. In this class, we continue learning new Java

More information

Type Checking and Type Equality

Type Checking and Type Equality Type Checking and Type Equality Type systems are the biggest point of variation across programming languages. Even languages that look similar are often greatly different when it comes to their type systems.

More information

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17 List of Programs xxv List of Figures xxix List of Tables xxxiii Preface to second version xxxv PART 1 Structured Programming 1 1 Getting started 3 1.1 Programming 3 1.2 Editing source code 5 Source code

More information

Object-Oriented Software Engineering Practical Software Development using UML and Java

Object-Oriented Software Engineering Practical Software Development using UML and Java Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes Lecture 5 5.1 What is UML? The Unified Modelling Language is a standard graphical

More information

Tester vs. Controller. Elementary Programming. Learning Outcomes. Compile Time vs. Run Time

Tester vs. Controller. Elementary Programming. Learning Outcomes. Compile Time vs. Run Time Tester vs. Controller Elementary Programming EECS1022: Programming for Mobile Computing Winter 2018 CHEN-WEI WANG For effective illustrations, code examples will mostly be written in the form of a tester

More information

CONTENTS: Arrays Strings. COMP-202 Unit 5: Loops in Practice

CONTENTS: Arrays Strings. COMP-202 Unit 5: Loops in Practice CONTENTS: Arrays Strings COMP-202 Unit 5: Loops in Practice Computing the mean of several numbers Suppose we want to write a program which asks the user to enter several numbers and then computes the average

More information

Object-Oriented Software Engineering Practical Software Development using UML and Java. Chapter 2: Review of Object Orientation

Object-Oriented Software Engineering Practical Software Development using UML and Java. Chapter 2: Review of Object Orientation Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 2: Review of Object Orientation 2.1 What is Object Orientation? Procedural paradigm: Software is organized

More information

Types and Type Inference

Types and Type Inference Types and Type Inference Mooly Sagiv Slides by Kathleen Fisher and John Mitchell Reading: Concepts in Programming Languages, Revised Chapter 6 - handout on the course homepage Outline General discussion

More information

Chapter 4: Control structures. Repetition

Chapter 4: Control structures. Repetition Chapter 4: Control structures Repetition Loop Statements After reading and studying this Section, student should be able to Implement repetition control in a program using while statements. Implement repetition

More information

Lecture 1 Contracts : Principles of Imperative Computation (Fall 2018) Frank Pfenning

Lecture 1 Contracts : Principles of Imperative Computation (Fall 2018) Frank Pfenning Lecture 1 Contracts 15-122: Principles of Imperative Computation (Fall 2018) Frank Pfenning In these notes we review contracts, which we use to collectively denote function contracts, loop invariants,

More information

6.001 Notes: Section 6.1

6.001 Notes: Section 6.1 6.001 Notes: Section 6.1 Slide 6.1.1 When we first starting talking about Scheme expressions, you may recall we said that (almost) every Scheme expression had three components, a syntax (legal ways of

More information

Lecture Overview. [Scott, chapter 7] [Sebesta, chapter 6]

Lecture Overview. [Scott, chapter 7] [Sebesta, chapter 6] 1 Lecture Overview Types 1. Type systems 2. How to think about types 3. The classification of types 4. Type equivalence structural equivalence name equivalence 5. Type compatibility 6. Type inference [Scott,

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

when you call the method, you do not have to know exactly what those instructions are, or even how the object is organized internally

when you call the method, you do not have to know exactly what those instructions are, or even how the object is organized internally I. Methods week 4 a method consists of a sequence of instructions that can access the internal data of an object (strict method) or to perform a task with input from arguments (static method) when you

More information

n Specifying what each method does q Specify it in a comment before method's header n Precondition q Caller obligation n Postcondition

n Specifying what each method does q Specify it in a comment before method's header n Precondition q Caller obligation n Postcondition Programming as a contract Assertions, pre/postconditions and invariants Assertions: Section 4.2 in Savitch (p. 239) Loop invariants: Section 4.5 in Rosen Specifying what each method does q Specify it in

More information

Elementary Programming

Elementary Programming Elementary Programming EECS1022: Programming for Mobile Computing Winter 2018 CHEN-WEI WANG Learning Outcomes Learn ingredients of elementary programming: data types [numbers, characters, strings] literal

More information

Curriculum Map Grade(s): Subject: AP Computer Science

Curriculum Map Grade(s): Subject: AP Computer Science Curriculum Map Grade(s): 11-12 Subject: AP Computer Science (Semester 1 - Weeks 1-18) Unit / Weeks Content Skills Assessments Standards Lesson 1 - Background Chapter 1 of Textbook (Weeks 1-3) - 1.1 History

More information

8 Designing classes. Main concepts to be covered. Software changes. Change or die. The Zuul Classes. World of Zuul

8 Designing classes. Main concepts to be covered. Software changes. Change or die. The Zuul Classes. World of Zuul Main concepts to be covered 8 Designing classes BK Chap. 8 How to write classes that are easily understandable, maintainable and reusable Responsibility-driven design Coupling Cohesion Refactoring 2 Software

More information

Arithmetic and IO. 25 August 2017

Arithmetic and IO. 25 August 2017 Arithmetic and IO 25 August 2017 Submissions you can submit multiple times to the homework dropbox file name: uppercase first letter, Yourlastname0829.java the system will use the last submission before

More information

Example: Fibonacci Numbers

Example: Fibonacci Numbers Example: Fibonacci Numbers Write a program which determines F n, the (n + 1)-th Fibonacci number. The first 10 Fibonacci numbers are 0, 1, 1, 2, 3, 5, 8, 13, 21, and 34. The sequence of Fibonacci numbers

More information

Mid Term Exam 1. Programming I (CPCS 202) Instructor: M. G. Abbas Malik Date: Sunday November 3, 2013 Total Marks: 50 Obtained Marks:

Mid Term Exam 1. Programming I (CPCS 202) Instructor: M. G. Abbas Malik Date: Sunday November 3, 2013 Total Marks: 50 Obtained Marks: Mid Term Exam 1 Programming I (CPCS 202) Instructor: M. G. Abbas Malik Date: Sunday November 3, 2013 Student Name: Total Marks: 50 Obtained Marks: Instructions: Do not open this exam booklet until you

More information

CS 314 Principles of Programming Languages

CS 314 Principles of Programming Languages CS 314 Principles of Programming Languages Lecture 15: Review and Functional Programming Zheng (Eddy) Zhang Rutgers University March 19, 2018 Class Information Midterm exam forum open in Sakai. HW4 and

More information

Hardware versus software

Hardware versus software Logic 1 Hardware versus software 2 In hardware such as chip design or architecture, designs are usually proven to be correct using proof tools In software, a program is very rarely proved correct Why?

More information

Exercise 4: Loops, Arrays and Files

Exercise 4: Loops, Arrays and Files Exercise 4: Loops, Arrays and Files worth 24% of the final mark November 4, 2004 Instructions Submit your programs in a floppy disk. Deliver the disk to Michele Zito at the 12noon lecture on Tuesday November

More information

6.001 Notes: Section 8.1

6.001 Notes: Section 8.1 6.001 Notes: Section 8.1 Slide 8.1.1 In this lecture we are going to introduce a new data type, specifically to deal with symbols. This may sound a bit odd, but if you step back, you may realize that everything

More information

PRIMITIVE VARIABLES. CS302 Introduction to Programming University of Wisconsin Madison Lecture 3. By Matthew Bernstein

PRIMITIVE VARIABLES. CS302 Introduction to Programming University of Wisconsin Madison Lecture 3. By Matthew Bernstein PRIMITIVE VARIABLES CS302 Introduction to Programming University of Wisconsin Madison Lecture 3 By Matthew Bernstein matthewb@cs.wisc.edu Variables A variable is a storage location in your computer Each

More information

Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Fall 2016 Howard Rosenthal

Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Fall 2016 Howard Rosenthal Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Fall 2016 Howard Rosenthal Lesson Goals Understand Control Structures Understand how to control the flow of a program

More information

CMSC 330: Organization of Programming Languages. OCaml Imperative Programming

CMSC 330: Organization of Programming Languages. OCaml Imperative Programming CMSC 330: Organization of Programming Languages OCaml Imperative Programming CMSC330 Fall 2017 1 So Far, Only Functional Programming We haven t given you any way so far to change something in memory All

More information

Compilers and computer architecture: A realistic compiler to MIPS

Compilers and computer architecture: A realistic compiler to MIPS 1 / 1 Compilers and computer architecture: A realistic compiler to MIPS Martin Berger November 2017 Recall the function of compilers 2 / 1 3 / 1 Recall the structure of compilers Source program Lexical

More information

Computer Science 145 Midterm 1 Fall 2016

Computer Science 145 Midterm 1 Fall 2016 Computer Science 145 Midterm 1 Fall 2016 Doodle here. This is a closed-book, no-calculator, no-electronic-devices, individual-effort exam. You may reference one page of handwritten notes. All answers should

More information

Lecture Set 2: Starting Java

Lecture Set 2: Starting Java Lecture Set 2: Starting Java 1. Java Concepts 2. Java Programming Basics 3. User output 4. Variables and types 5. Expressions 6. User input 7. Uninitialized Variables 0 This Course: Intro to Procedural

More information

I. Variables and Data Type week 3

I. Variables and Data Type week 3 I. Variables and Data Type week 3 variable: a named memory (i.e. RAM, which is volatile) location used to store/hold data, which can be changed during program execution in algebra: 3x + 5 = 20, x = 5,

More information