Introduction IS
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
Goals of course Increase breadth of Java exposure Increase depth of programming experience
Breadth Collections JDBC GUI Threads Networking Distributed computing XML
Characteristics of business applications Need for adaptability Part of larger systems Large and complex
Emphasis Good program design Good programming style Building flexibility and maintainability into the code Vectors of change!
Resources Office hours CST noon – 3 pm Tuesday COL web site Course resource site
Syllabus Alternating Quizzes Assignments Pre-test “homework #0” Final 6/11
Grading rubric Knowledge Program shows that you know the important Java concepts Reasoning Program shows good design decisions Communication Program is readable
Homework #0 Pre-test Simple Java class Main method that tests it New? jar
Java command line Running DOS command shell Navigating to the location of your files Running JDK programs
JDK programs javac java compiler.java ->.class java java virtual machine class name jar java archive
jar Create an archive jar cvf jar-file files
Issues “current” directory in DOS shell classpath -classpath for javac -cp for java wildcards multiple files
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
Method signature Consists of method name parameter types return type Example public Baz toBaz (Bar b, Foo f) Signature Baz toBaz (Bar, Foo)
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
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
Why use interfaces? Single inheritance but multiple interfaces Efficiency inheritance is expensive “Loose coupling”
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 ();
Input and Output Sources files network strings keyboard Streams input output
Text input Reading from the keyboard String s = new BufferedReader ( new InputStreamReader(System.in)).readLine(); Reading from a file String s = new BufferedReader ( new FileReader(“data.txt”)).readLine();
Text output Writer Output to file BufferedWriter w = new BufferedWriter ( new FileWriter (“output.txt”)); w.println (“foo”);
Actual example public 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 + "."); }
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... }