Introduction IS 313 4.1.2003. Outline Goals of the course Course organization Java command line ...

26
Introduction IS 313 4.1.2003

Transcript of Introduction IS 313 4.1.2003. Outline Goals of the course Course organization Java command line ...

Page 1: Introduction IS 313 4.1.2003. Outline  Goals of the course  Course organization  Java command line  Object-oriented programming  File I/O.

Introduction

IS 3134.1.2003

Page 2: Introduction IS 313 4.1.2003. Outline  Goals of the course  Course organization  Java command line  Object-oriented programming  File I/O.

Outline Goals of the course Course organization Java command line Object-oriented programming File I/O

Page 3: Introduction IS 313 4.1.2003. Outline  Goals of the course  Course organization  Java command line  Object-oriented programming  File I/O.

Business Application Development Business process analysis Systems analysis Systems integration Change management Information systems planning COTS procurement Project management Programming

Page 4: Introduction IS 313 4.1.2003. Outline  Goals of the course  Course organization  Java command line  Object-oriented programming  File I/O.

Goals of course Increase breadth of Java exposure Increase depth of programming

experience

Page 5: Introduction IS 313 4.1.2003. Outline  Goals of the course  Course organization  Java command line  Object-oriented programming  File I/O.

Breadth Collections JDBC GUI Threads Networking Distributed computing XML

Page 6: Introduction IS 313 4.1.2003. Outline  Goals of the course  Course organization  Java command line  Object-oriented programming  File I/O.

Characteristics of business applications Need for adaptability Part of larger systems Large and complex

Page 7: Introduction IS 313 4.1.2003. Outline  Goals of the course  Course organization  Java command line  Object-oriented programming  File I/O.

Emphasis Good program design Good programming style Building flexibility and maintainability into

the code Vectors of change!

Page 8: Introduction IS 313 4.1.2003. Outline  Goals of the course  Course organization  Java command line  Object-oriented programming  File I/O.

Resources Office hours

CST 453 12 noon – 3 pm Tuesday

COL web site http://dlweb.cti.depaul.edu/

Course resource site http://josquin.cti.depaul.edu/~rburke/s03/is313/

Page 9: Introduction IS 313 4.1.2003. Outline  Goals of the course  Course organization  Java command line  Object-oriented programming  File I/O.

Syllabus Alternating

Quizzes Assignments

Pre-test “homework #0”

Final 6/11

Page 10: Introduction IS 313 4.1.2003. Outline  Goals of the course  Course organization  Java command line  Object-oriented programming  File I/O.

Grading rubric Knowledge

Program shows that you know the important Java concepts

Reasoning Program shows good design decisions

Communication Program is readable

Page 11: Introduction IS 313 4.1.2003. Outline  Goals of the course  Course organization  Java command line  Object-oriented programming  File I/O.

Homework #0 Pre-test Simple Java class Main method that tests it New?

jar

Page 12: Introduction IS 313 4.1.2003. Outline  Goals of the course  Course organization  Java command line  Object-oriented programming  File I/O.

Java command line Running DOS command shell Navigating to the location of your files Running JDK programs

Page 13: Introduction IS 313 4.1.2003. Outline  Goals of the course  Course organization  Java command line  Object-oriented programming  File I/O.

JDK programs javac

java compiler .java -> .class

java java virtual machine class name

jar java archive

Page 14: Introduction IS 313 4.1.2003. Outline  Goals of the course  Course organization  Java command line  Object-oriented programming  File I/O.

jar Create an archive

jar cvf jar-file files

Page 15: Introduction IS 313 4.1.2003. Outline  Goals of the course  Course organization  Java command line  Object-oriented programming  File I/O.

Issues “current” directory

in DOS shell classpath

-classpath for javac -cp for java

wildcards multiple files

Page 16: Introduction IS 313 4.1.2003. Outline  Goals of the course  Course organization  Java command line  Object-oriented programming  File I/O.

Object-oriented programming Class

template for an object associates data structure with data

manipulation Object

instance of a class Methods

“program” part of the object Constructor

special method called at creation time

Page 17: Introduction IS 313 4.1.2003. Outline  Goals of the course  Course organization  Java command line  Object-oriented programming  File I/O.

Method signature Consists of

method name parameter types return type

Example public Baz toBaz (Bar b, Foo f)

Signature Baz toBaz (Bar, Foo)

Page 18: Introduction IS 313 4.1.2003. Outline  Goals of the course  Course organization  Java command line  Object-oriented programming  File I/O.

Inheritance Class is a subclass of another class

All (non-private) methods and instance variables from superclass belong to subclass

programmer gets computational power for “free”

Overriding Supply subclass method with same signature

as superclass method

Page 19: Introduction IS 313 4.1.2003. Outline  Goals of the course  Course organization  Java command line  Object-oriented programming  File I/O.

Interfaces Collection of method signatures

no implementation Use

establish how objects will interact without specifying what they do

A class “implements” an interface Interfaces can inherit from others

Page 20: Introduction IS 313 4.1.2003. Outline  Goals of the course  Course organization  Java command line  Object-oriented programming  File I/O.

Why use interfaces? Single inheritance

but multiple interfaces Efficiency

inheritance is expensive “Loose coupling”

Page 21: Introduction IS 313 4.1.2003. Outline  Goals of the course  Course organization  Java command line  Object-oriented programming  File I/O.

Example class C1 implements I1 class C2 extends C1 implements I2 Which are legal?

C1 o1;o1 = new I1 (); o1 = new C1 ();o1 = new I2 ();o1 = new C2 ();I1 o2;o2 = new C1 ();o2 = new C2 ();C2 o3;o3 = new C1 ();o3 = new C2 ();I2 o4;o4 = new C1 ();o4 = new C2 ();

Page 22: Introduction IS 313 4.1.2003. Outline  Goals of the course  Course organization  Java command line  Object-oriented programming  File I/O.

Input and Output Sources

files network strings keyboard

Streams input output

Page 23: Introduction IS 313 4.1.2003. Outline  Goals of the course  Course organization  Java command line  Object-oriented programming  File I/O.

Text input Reading from the keyboard

String s = new BufferedReader (new InputStreamReader(System.in)).readLine();

Reading from a fileString s = new BufferedReader (

new FileReader(“data.txt”)).readLine();

Page 24: Introduction IS 313 4.1.2003. Outline  Goals of the course  Course organization  Java command line  Object-oriented programming  File I/O.

Text output Writer Output to file

BufferedWriter w = new BufferedWriter (

new FileWriter (“output.txt”));

w.println (“foo”);

Page 25: Introduction IS 313 4.1.2003. Outline  Goals of the course  Course organization  Java command line  Object-oriented programming  File I/O.

Actual examplepublic void load (String filename){ BufferedReader in = null; try { in = new BufferedReader (new FileReader (filename)); } catch (IOException e) { System.err.println ("Error opening file: " + filename + " Exiting."); System.exit(-2); } String line; try { while ((line = in.readLine()) != null) { try { ... do something with the line ...; } catch (java.text.ParseException e) { System.err.println("Couldn't parse date: " + line); } } } catch (IOException e) { System.err.println ("Error reading file " + filename + "."); }}

Page 26: Introduction IS 313 4.1.2003. Outline  Goals of the course  Course organization  Java command line  Object-oriented programming  File I/O.

StringTokenizer Takes a string apart

String text = “Whatever you want, you’ll get it.”;

StringTokenizer st = new StringTokenizer (text);

while (st.hasMoreTokens())

{

String word = st.nextToken ();

... process token ...

}