COP-4338, Programming III Lectures
Note: Links will not be alive until a day or two before class.
- Jan 8 and 10: Opening remarks, the Object class, Reflection,
and the Proxy Pattern
- Remarks PDF slides
- Object class PDF slides
- Reflection PDF slides
- Examples
- Illustration of the correct way to override
equals, hashcode, toString,
and clone
ObjectDemo.java
- Illustration of using reflection to invoke main
InvokeMain.java
- Using accessible fields to get private data
Spy.java
- Illustration of the proxy pattern.
Shows generation by hand, generation by using Java 1.3 dynamic proxies,
and an approximation of what
the dynamic proxy is actually producing for you behind the scenes
TestProxy.java
- Jan 15, 17, 22: Threads and Synchronization
- PDF slides
- Examples:
- Illustrates basics of getting threads to run:
ThreadDemo.java
- Illustrates threads corrupting data:
NoSync.java
- Series of examples using an Account.
Some threads do deposits, some do withdraws on shared account.
- Two examples with multiple monitors
- Static methods have different monitors than instance methods:
StaticsAndThreads.java
- Jan 24: Networking
- Jan 29 and 31: Server-side Programming
- PDF slides
- The JSDK 2.1 download for Windows (375K)
- This material is not in the text. Additional references:
- Examples:
- For all Java examples, save the HTML in main folder, place the
class files in your WEB-INF/servlets directory, and start the servletrunner.
The links will not run directly from my web page because
our web server is not running servlets.
- CGI program in C++ to print out what a form transmits.
program1.cpp,
prog1.html (uses POST), and
prog1b.html (uses GET).
- CGI script can be invoked from a Java program, so you cannot
assume the form has done verification:
SubmitGetForm.java,
SubmitPostForm.java,
- Findmax program using a servlet:
findmax.html and
FindMax.java,
- Program to render PDF files (assumes get, so include
name of file, minus .pdf extension after a ? in the URL):
RenderPDF.java.
- Cookie example from slides:
login.html and
CookieExample.java.
- Session example from slides:
sessionlogin.html and
SessionExample.java.
- February 5, 7, and 12: Swing and Applets
- Feb 14: Serialization
- Feb 19 and 21: Garbage Collection
- Java Developer Connection Article
- Examples
-
TestBlob.java
shows that soft references don't stay around for a long time.
-
TestFactory.java
shows a factory class that hands out Foo objects
(from a pre-allocated pool),
but requires that the client release the objects back to the pool.
-
TestPoolFactory.java
shows a factory class that hands out Foo objects,
but does not require that the client release the objects.
Instead it uses weak references to detect orphaned Foo objects,
and reclaims those orphans for the pool.
- Feb 26: Security
- February 28: C++ Basics, arrays, strings, files
- vector class.
- Parameter passing: call by constant reference.
- resizing and push_back
- string class.
- Basics of files.
- March 5: Structs and Classes: Part I
- Sample C++ code
- Classes: interfaces, member functions, visibility
- Separation of interface and implementation
- Constructors
- Default parameters
- Accessor/Mutator
- Scope :: operator
- ifndef/endif and separate compilation
- Const and non-const methods
- Implicit type conversions
- Explicit constructors
- Initializer lists
- March 7: Classes: Part II
- Static members
- *this
- Operator overloading
- Friends
- The big three: destructor, operator= and copy constructor
- Constant and reference data member
- Example: The Rational class
- March 12: Templates
- Why templates
- Function templates
- Class templates: interface
- Illustration of the MemoryCell class
- Specifying the requirements of the template type
- Class templates: implementation
- A Set class (uncommented):
Set.h
Set.cpp
TestSet.cpp
Set_int.cpp
(the last file is for separate compilation of templates).
- March 14: Templates: Part II; Mostly other stuff
- Separate compilation issues
- Exceptions
- Reference return types
- vector and operator[]
- matrix
- Linked data structures
- Aliasing and this
- March 19, 21: SPRING BREAK
- March 26 and (part of) 28: STL
- Pointer variables and their relation to primitive arrays
- Primitive strings
- STL Basic ideas
- Iterators
- Lists vs Vectors
- The Pair pattern
- Sets and maps
- (Rest of) Mar 28 and April 2: Inheritance
- Implementing a derived class
- Constructors
- Defaults for the Big Three in the derived class
- Protected members
- Slicing
- Static vs. dynamic binding
- virtual keyword
- The virtual destructor
- Various C++ differences from Java
- April 4, 9: Programming in C
- April 11: Native Methods in C and C++
- PDF slides
- Examples
- Hello World:
HelloNative.java,
HelloNative.h, and
HelloNative.cpp.
- Visual C++ setup
-
To compile:
cl -GX /GR -IC:\jdk1.3\include -IC:\jdk1.3\include\win32 HelloNative.cpp -LD -FeHelloNative.dll
- Accessing fields of Date class:
Date.java,
TestDate.java,
Date.h, and
Date.cpp.
- Accessing methods of Date class:
Date.java,
TestDate.java,
Date.h, and
Date.cpp.
- Accessing strings in Date class:
Date.java,
TestDate.java,
Date.h, and
Date.cpp.
- Using arrays:
NativeSumDemo.java,
NativeSumDemo.h, and
NativeSumDemo.cpp.
- Using exceptions:
NativeSumDemo.java,
NativeSumDemo.h, and
NativeSumDemo.cpp.
- Creating a Java VM from C++:
ReadMe.txt,
InvokeHello.cpp, and
Hello.java.
- April 16: Intro to RMI