Intro To Programming

jetmorebrisketΛογισμικό & κατασκευή λογ/κού

15 Αυγ 2012 (πριν από 5 χρόνια και 3 μήνες)

212 εμφανίσεις

Intro To Programming

The Big Picture


Program /Code


Software /Application


Algorithm


Development Cycle


Java


Programming language


Syntax


Features


Safe


Simple


Platform
-
independent


Object oriented

Drawbacks & Solutions


Complexity


Gradual reveal


Abstract ideas


Analogies


Concrete examples


Details, details, details


Leaning toward concepts


Asking big questions

Getting Started


Log in


Launch BlueJ


Wait for it


Create or open a project

Importance of Naming


Naming


CamelCase


Sensible


A 'human', not a 'computer' requirement


Convention rather than a rule


Organization


Network drive


USB drive


Absolute Minimum

class Greeter

{


public static void main(String[] args)


{



}

}

Code


AKA program or portion thereof


Governed by rules and conventions


Statement


syntactic unit of a program

Rules and Conventions


Rules


Defined by language
syntax


Strict


Enforced by the compiler


Violations result in
syntax errors



Conventions


Less strict


Enforced by people


Violations may lead to:


Syntax errors


Run
-
time errors


Poor design


Formatting


Java is case sensitive


Generally, whitespace is ignored by the
compiler


Code is vertically aligned, for easier reading

Methods & Parameters


Methods are similar to functions in
mathematics


Parameters are things that get operated on
(usually by a method)


Parameters are enclosed in parens ( )


Math example: x = sine(theta)


theta is a parameter


sine is a function


Strings


A strings is a sequence of characters


Must be enclosed in quotation marks


“this is a valid string”


“So is this list: 1,2,3,4!”


“This is not a valid string (unclosed)


Neither is this”


Comments on Comments


Comments are


Used to document code, leave notes or
explanations


Ignored by the compiler, but may be used by other
utilities like
Javadoc


Used by humans to understand code


// single line comment


/*
muliple

line comment */

Errors


Types


Syntax errors


Logic errors


Bugs


Debuggers

Syntax Errors


Compile time errors


Must be fixed before the program can run


Compiler flags as many errors as possible


One error may mask other errors


Logic Errors


Run time errors


Program
does not operate
as intended


Cannot be detected by the compiler


Can be found by testing


Typically, testing cannot prove complete
correctness


Defensive programming


Programming style that tries to keep errors from
becoming disastrous


Common Syntax Errors


Unbalanced


parens ( )


braces { } [ ]


quotes “ “


multi
-
line comment blocks /* */


Forgetting to end statements with a semicolon

Common Syntax Errors


Capitalization


Java is case sensitive


Misspellings


File & class names must match


Missing keywords

Typical


Dev


Cycle

Begin

Edit
Program

Compile
Program

Compiler
Errors?

Test
Program

Run
-
time
Errors?

End

true

true

false

false

Outside the Clusters


Download and install the JDK


Download & install one or more IDE


BlueJ


Netbeans


Eclipse


Technically, you don't
have

to use an IDE


Determine where to store your files