COP-4338, Programming III Lectures
Note: Links will not be alive until a day or two before class.
- May 10, 12, and 17: C++ Basics, arrays, strings, files, pointers, reference variables
- Simple C++, and compiling functions
- vector class.
- resizing and push_back
- string class.
- Parameter passing: call by constant reference.
- Pointers
- new and delete
- Reference variables
- May 19 and 24: Classes
- 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
- Static members
- *this
- Operator overloading
- Friends
- The big three: destructor, operator= and copy constructor
- Constant and reference data member
- Linked data structures
- Aliasing and this
- Example: The Rational class
- Reference return types and operator[]
- May 26 and 31: 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
- June 2: Templates
- Why templates
- Function templates
- Class templates: interface
- Illustration of the MemoryCell class
- Specifying the requirements of the template type
- Class templates: implementation
- Separate compilation issues
- A Set class (uncommented):
Set.h
Set.cpp
TestSet.cpp
Set_int.cpp
(the last file is for separate compilation of templates).
- An LSet (linked list version) class (uncommented):
LSet.h
LSet.cpp
TestLSet.cpp
LSet_int.cpp
- Function Objects
- Exceptions
- Reference return types
- matrix
- June 7 and 9: STL
- Pointer variables and their relation to primitive arrays
- Primitive strings
- STL Basic ideas
- Iterators
- Lists vs Vectors
- The Pair pattern
- Sets and maps
- The concordance example
- String streams
- June 14 and 16: Programming in C
- June 28: Exam #1 C++ and C
- June 21: The Object class, Reflection, and the Proxy Pattern
- Remarks
- 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
- June 23, 30, July 5: 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
- July 7 and 12: Networking
- July 21: Exam #2: Reflection, Threading, Networking
- July 14 and 19: Serialization
- July 26 and 28: 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.
- August 2 and 4: JNI
- August 4: Review
- August 9: Exam #3: Threading, Networking, Serialization, Garbage Collection
- August 11: TBA