From charlesreid1

No edit summary
 
(72 intermediate revisions by the same user not shown)
Line 1: Line 1:
See [[CSC 142 Checklist]]
=Chapter 1: Intro to Java=
=Chapter 1: Intro to Java=


Sections:
[[CSC 142/Chapter 1]]


1.1 Basic computing concepts
=Chapter 2: Primitive Data and Definite Loops=


1.2 And now, Java
[[CSC 142/Chapter 2]]


1.3 Program errors
=Chapter 3: Parameters and Objects=


1.4 Procedural decomposition
[[CSC 142/Chapter 3]]


1.5 Case study: DrawFigs
=Chapter 4: Conditional Execution=


Note: the first chapter is definitions-heavy.
[[CSC 142/Chapter 4]]


==Section 1.1: Intro to Java==
=Chapter 5: Program Logic and Indefinite Loops=


===Definitions===
[[CSC 142/Chapter 5]]


* Algorithm
=Chapter 6: File Processing=
* Program
* Hardware ("Hardware: the part of the computer that you can kick")
* Software
* Digital
* Binary
* Program execution
* Compiler
* Java Virtual Machine (JVM)
* Java Runtime Environment (JRE)


===Material===
[[CSC 142/Chapter 6]]


Things to cover:
=Chapter 7: Arrays=
* Java class libraries (standard library)
* Java programming environment
* Java Hello World program
* Eclipse editor ("Why can't Java programmers see well?" "Because of the Eclipse.")
* Console window/command line


===Quotes===
[[CSC 142/Chapter 7]]


1995: Oracle: "Java: A simple, object-oriented, network-savvy, interpreted, robust, secure, architecture-netural, portable, high-performance, multithreaded, dynamic language."
=Chapter 8: Classes=


===Life Skills===
[[CSC 142/Chapter 8]]


Life skills track:
=Outline=
* Pay attention and FOCUS
* RTFM
* Follow directions and read carefully
* Whether it's your compiler, or your instructor, or your fellow students - pay attention to what's being said
* Skill will pay off when you start to compile your Java programs


==Section 1.2: Java==
==Midterm A==


===Materials===
Midterm A Outline
* Chapter 1: Intro to Java
** Java basics
** Program errors
** Procedural decomposition
** Case Study: DrawFigs
* Chapter 2: Primitive Data and Definite Loops
** Basic data
** Variables
** For loop
** Managing complexity
** Case Study: Hourglass figures
* Chapter 3: Parameters and Objects
** Parameters
** Methods returning values
** Using objects
** Case Study: Projectile trajectory
* Chapter 4: Conditional Execution
** If/else statements
** Logic statements
** Object equality and operators
** Refactoring to use if/else logic
** Cumulative algorithms
** Equality with floats and roundoff error
** Text processing
** Printf
** Methods and conditional execution
** Case Study: BMI


Class
==Midterm B==
* Every program, all Java code, lives in a class
* Class header
* Class methods
* Statements
* String literals
* System.out.println
* Escape sequences
* print vs println


Complex example: draw figures
Midterm B Outline
* ASCII diamond, X, rocket
* Chapter 5: Program logic, conditional execution
** While loops
** Random numbers
** Fencepost algorithms
** Boolean type
** User input and dealing with errors
** Assertion and program logic
** Case Study: NumberGuess
* Chapter 6: File processing
** File reading basics
** Token based processing
** Reading numbers from a file
** Paths and directories
** Line based processing
** Line/token combinations
** Advanced file processing
** Removing whitespace
** Case Study: Zip code lookup
* Chapter 7: Arrays
** Array basics and initialization
** Comparing arrays
** Array traversal
** Reference semantics and memory, and null
** Advanced array techniques
** Shuffling, shifting, reversing
** Multidimensional arrays
** Rectangular multidimensional arrays
** Jagged multidimensional arrays
** Case Study: Benford's Law
* Chapter 8: Object oriented programming
** Object state and behavior
** Accessor methods
** Object initialization and constructors
** Data encapsulation
** Private fields
** Mutable/immutable
** Case Study: Stock class


Code comments, white space, readability:
=Flags=
* Comments
 
===Profiles===
 
* James Gosling - Oracle, tech companies, open source vs. enterprise, hackers vs suits
 
==Section 1.3: Syntax Errors==
 
===Material===
 
Different types of errors:
* Where the errors happen - the normal process - (code) --> (compiler) --> (bytecode)
* Errors at compiler level - syntax errors - book lists common syntax errors
* Errors at code level - bugs - errors in the logic of the program (wrong idea, or right idea but implemented wrong)
 
===Pofiles===
 
* Grace Hopper
 
==Section 1.4: Procedural Decomposition==
 
===Materials===
 
Decomposing complexity:
* Decomposition concept: split into functions, tasks, subtasks
 
C is very verb-oriented, action-oriented
 
Java is very noun-oriented, object-oriented
 
Procedural programming:
* Function-based, action-based programming
* How to decompose task of baking a cake
* Static methods (help serve function of.......... functions)
 
Object oriented programming version:
* c = new Cake(); c.make()
* Encapsulating complexity of the object
* Example in book: drawBox, drawTopX, drawBottX
 
Flow control
* How control changes with function calls
* Objects: with OOP it becomes more complicated to follow the flow of the program
* Procedural programs and interpreted languages: you just start at the top and go from there
* Objects: "when is this code actually used?" (have to dive in to see)
* Learning to follow program flow control
* Flow control allows you to abstract away detail
* Example runtime error
 
===Definitions===
 
* Decomposition
* Iterative enhancement
* Static method
* Method call
* Flow control
 
===Life Skills===
 
Life skills track:
* Cover non-word representations of programs
 
(Give them a crypto puzzle, but we haven't introduced any crypto or codes just yet)
 
==Section 1.5 : Case Study with DrawFig==
 
===Material===
 
Modularization of drawing program
* Breaking int pieces - not just the box, or the x, or the rocket
* but breaking down into common components, common to all parts of the program
* Take hello world program...
* Modularize it, make it reusable...
 
==Chapter 1 Summary==
 
Worksheet: definitions from book on one side (quiz material)
 
Source code for a procedural program (fizz baz foo bar buzz bam) on the other
 
There are N bugs, find the N bugs (self-work)
 
Discuss the program flow with a partner (group work)
 
How do we represent this program in a clear and concise way?
 
Transform foo bar into get ready for school - proper names can help clarify understanding
 
Lecture: broken up into 1.5 parts
* Broad brush-stroke over chapter 1
* Memorize definitions
* Know XYZ for quiz
* Spend a majority of time on in-class exercises
* FOCUS: KNOW HOW TO RUN/SET UP HELLO WORLD
* FOCUS: KNOW DEFINITIONS
* FOCUS: KNOW FUNCTIONS AND PROGRAM FLOW
* FOCUS: KNOW ERRORS/EXCEPTIONS
 
Quiz/exam/assessment material:
* Hello world, basics, public static void main, syntax
* Definitions matchup
* Functions questions
* Program flow questions
* Exceptions: spot the bug... spot logical errors... spot syntax errors...


Need to make beginnings of class difficult, to send the message that they can't let it slide
{{CSC142Flag}}


===Deliverables===
The short list of topics:


Intro to Java
Intro to Java
* Know how to set up and run hello world
* How does it work, role of compliler vs editor
* JRE vs JVM vs JDK
* Public static void main
* EEverything is a class
* Filename = class name
* Correct syntax, protected keywords


Definitions
Primitive Data and Definite Loops
* algorithm, program, hardware/software, digital, binary, program execution, compiler, JVM, JDK, JRE, class header, class methods, statements, string literals, system.out.println, escape chars, print vs println, exception, decomposition, flow control, iterative enhancement, static method


Functions and program flow
Parameters and Objects
* How to follow the flow of a program through multiple (nested) function calls
* When to use a static method or static class
* How to follow a nested program
* How to break up a task into less complex parts, with reusability
* Translate between procedure and function


Errors and logical problems
Conditional Execution
* Spotting the error
* Red herring: error, plus (unclear) compiler output


Program Logic and Conditional Execution


=Chapter 2: Primitive Data and Definite Loops=
File Processing


Sections:
Arrays
 
2.1 Basic data concepts
 
2.2 Variables
 
2.3 The for loop
 
2.4 Managing complexity
 
2.5 Case study: Hourglass figure
 
Note: this chapter has two halves. The first half examines expressions, particularly for numerical data and variables. The second half examines control structures, used to perform repetitive actions.
 
The goal here is pattern-finding - what repeated actions will lead to the desired outcomes? This loop will cover definite loops (loops that repeat a predetermined number of times). Next chapter will cover indefinite loops.
 
==Section 2.1: Basic data concepts==
 
===Material===
 
Java primitive types:
* int
* double
* char
* boolean
 
Why important? because computers represent data and numbers in memory, and we need to understand how (rules)
 
How we input data and operations:
* literals (literal values, 2.19)
* expressions (assembling stuff, related by operators)
 
Operators:
* Mix of computer science and math
* Operators mean, performing a set of tasks (or, a task)
* Some operators require 2 things, e.g., 2+3
* Some operators require 1 thing, e.g., inverse(A) or d/dx( x^2 )
 
Literals
* Different data types
* Decimals vs integers (especially with operations)
* Booleans: true/false (keywords)
 
Arithmetic
* Division weirdness
* Remainder operator
* Goldfish analogy - small memory capacity - 2 digits - what happens after 99? start over
 
Precedence and order of operations
* Grammar connection
* Be explicit in what you're asking computer to do
 
Casting and file types
* can deal with int/float differences by casting
* Again, be explicit: (int)( ......... )
 
===Definitions===
 
Definitions:
* Data type
* Expression
* Evaluation
* Operator
* Precedence
* Casting
 
===Profiles===
 
Charles Babbage - digital representation
 
==Section 2.2: Variables==
 
===Materials===
 
You have to declare it available in order to use it
 
You have to declare what ''kind'' of variable it is
 
Can combine declaration and assignment
 
Can declare multiple variables on one line
 
Concat:
* To combine strings, use plus operator
* But be careful with number/string types
* Example: <code>2 + 3 + " hello " + 7 + 2*3</code>
* Multiplication first
* Then only addition is left, so evaluate left to right
* 2+3 first becomes 5
* Then the remaining plus operators turn into string concatenation operators
* Better: be explicit about what types are being added to what, and in what order.
 
Increment/decrement:
* Useful shorthand operators
 
===Definitions===
 
Definitions:
* Variable
* Declaration
* String concatenation
* Increment/decrement
 
==Section 2.3: For Loop==
 
===Material===
 
Purpose:
* Replace redundant tasks
 
Syntax of for loops
* Initialize a loop variable, create a condition
* Body of for loop is executed if condition is true
* Tracing loops
* Curly braces are important
 
Some patterns:
* If we want to execute a loop N times, can use two patterns: i=0, or i=1
* Nested for loops
* Print vs println with nested for loops
 
===Definitions===
 
Definitions:
* Control structure
 
==Section 2.4: Managing Complexity==
 
===Material===
 
Scope:
* Helps to manage complexity of variable space
* Curly braces represent scope
* Variable defined inside braces is not defined outside those braces
 
Examine examples, errors, why it crashes, and how it crashes
 
Tracing a for loop:
* Initialization
* Test
* Body
* Update
* End
 
Pseudocode:
* Part of communicating about code
* Simple examples to give them an idea
* More complex pattern-finding, indices (2(i-1)), etc...
* Constants (for drawing patterns, e.g., number of lines)
* Public static final type name = (...) <-- permanently, same value, accessible by static methods
* We are still thinking PROCEDURALLY
 
===Definitions===
 
Definitions:
* Scope
* Localizing variables
* Infinite loop
* Pseudocode
* Class constant
 
===Profiles===
 
Carl Freidrich Gauss
* Adding up the sum of all integers from 1-100
* First approach: don't manage the complexity, just dive in and have at it
* Gauss: found an alternative pattern
* By adding last and first, then second last and second first, and so on, got same number for each
* Utilizing this turned a sum problem into a multiplication problem
* Lesson: by changing your pattern of thinking/problem solving, can open up new, better, faster approaches
 
==Section 2.5: Case Study: Hourglass Figure==
 
Detailed example of how to work out a pattern and translate it into modular code
 
==Chapter 2 Summary==
 
Deliverables:
* Primitive type expressions and literals
* Casting
* Assigning/changing variable values
* For loops, for loop patterns
* Scope
* Pseudocode
* Constants
 
===Assessment Material===
 
Dealing with primitive types in expressions, and order of operations, etc.
* How to interpret incrementing and other assignment operators
* For loops:
** Know how to follow control
** Syntax
** Curly braces
* Scope
* Pseudo code to describe how to draw a pattern
* Constants
** Syntax
** Explaining the purpose (e.g., which of the following would be a good variable to program as public static final z)
* 99 bottles of root beer
 
 
=Chapter 3: Parameters and Objects=
 
Sections:
 
3.1 Parameters
 
3.2 Methods returning values
 
3.3 Using objects
 
3.4 Projectile trajectory
 
==Section 3.1: Parameters==
 
===Definitions===
 
Definitions:
* Parameter/parametric/parameterize
* Formal parameter
* Actual parameter
* Method signature
* method overloading
* Parameters = arguments (language)
 
Parameterization:
* Form of abstraction
* What we are doing is generalizing a task
* Not just solving x2 + 4x + 2 = 0, solving ax2 + bx + c = 0
* Example code for parameterizing print statements
* How do you use/declare parameters in a class method?
* How not to declare parameters - not writeSpaces(int numLines)
* Differentiating betwen TYPE DECLARATION/DEFINITION, and the ACTUAL METHOD CALL
* Parameters: data --> method
* Each method is defined to have its own scope, as denoted by <code>{}</code>. So how to pass data through the scope?
 
Scope:
* Scope means, all variables from outside the function are unknown
* Data is passed in as fresh
* Parameters are variables that are predefined in that fresh variable space
* Scope ties in with return values - once you do a calculation, how do you get the result ''out''?
* Return values/return variables.
* Overloading methods: so that we can handle variations in the input data.
 
==Section 3.2: Methods that Return Values==
 
===Definitions===
 
Definitions:
* Return
* Object
* class
 
===Material===
 
Example of when you need to return a value: square root function
* Method syntax: how to declare a function's return type (void --> int/double/etc)
 
Real life example: Java Math (static class, static methods)
* Math constants E and PI
* Casting and math functions
* How to explore the Java API
* Just focus on Math, don't get overwhelmed
* Hands-on math example: Gauss, sum of first 100 integers
** Excellent example of how different ways of tackling problems (different algorithms) can lead to vast speedups
** Formula:
 
<math>
\sum_{i=1}^{n} i = \dfrac{ n(n+1) }{2}
</math>
 
To program this formula:
 
<pre>
public static int sum(int n) {
    return (n * (n+1)) / 2;
}
</pre>
 
=Flags=


[[Category:Teaching]]
Classes

Latest revision as of 16:05, 24 September 2016

See CSC 142 Checklist

Chapter 1: Intro to Java

CSC 142/Chapter 1

Chapter 2: Primitive Data and Definite Loops

CSC 142/Chapter 2

Chapter 3: Parameters and Objects

CSC 142/Chapter 3

Chapter 4: Conditional Execution

CSC 142/Chapter 4

Chapter 5: Program Logic and Indefinite Loops

CSC 142/Chapter 5

Chapter 6: File Processing

CSC 142/Chapter 6

Chapter 7: Arrays

CSC 142/Chapter 7

Chapter 8: Classes

CSC 142/Chapter 8

Outline

Midterm A

Midterm A Outline

  • Chapter 1: Intro to Java
    • Java basics
    • Program errors
    • Procedural decomposition
    • Case Study: DrawFigs
  • Chapter 2: Primitive Data and Definite Loops
    • Basic data
    • Variables
    • For loop
    • Managing complexity
    • Case Study: Hourglass figures
  • Chapter 3: Parameters and Objects
    • Parameters
    • Methods returning values
    • Using objects
    • Case Study: Projectile trajectory
  • Chapter 4: Conditional Execution
    • If/else statements
    • Logic statements
    • Object equality and operators
    • Refactoring to use if/else logic
    • Cumulative algorithms
    • Equality with floats and roundoff error
    • Text processing
    • Printf
    • Methods and conditional execution
    • Case Study: BMI

Midterm B

Midterm B Outline

  • Chapter 5: Program logic, conditional execution
    • While loops
    • Random numbers
    • Fencepost algorithms
    • Boolean type
    • User input and dealing with errors
    • Assertion and program logic
    • Case Study: NumberGuess
  • Chapter 6: File processing
    • File reading basics
    • Token based processing
    • Reading numbers from a file
    • Paths and directories
    • Line based processing
    • Line/token combinations
    • Advanced file processing
    • Removing whitespace
    • Case Study: Zip code lookup
  • Chapter 7: Arrays
    • Array basics and initialization
    • Comparing arrays
    • Array traversal
    • Reference semantics and memory, and null
    • Advanced array techniques
    • Shuffling, shifting, reversing
    • Multidimensional arrays
    • Rectangular multidimensional arrays
    • Jagged multidimensional arrays
    • Case Study: Benford's Law
  • Chapter 8: Object oriented programming
    • Object state and behavior
    • Accessor methods
    • Object initialization and constructors
    • Data encapsulation
    • Private fields
    • Mutable/immutable
    • Case Study: Stock class

Flags





The short list of topics:

Intro to Java

Primitive Data and Definite Loops

Parameters and Objects

Conditional Execution

Program Logic and Conditional Execution

File Processing

Arrays

Classes