Advanced Java Programming

Advanced Java Programming

Course Length: 5 days
Delivery Methods: Available as private class only
Course Benefits
  • Make effective use of Java generic types.
  • Understand the structure of streams in Java, and learn how to use streams to manage file I/O.
  • Learn how to use Java Serialization to internalize and externalize potentially complex graphs of objects.
  • Communicate between processes using network sockets.
  • Write multi-threaded Java applications that safely manage concurrent access to application state.
  • Use the Reflection API and dynamic proxies for highly generic tasks, discovery, or code-generation.
  • Use standard annotations and develop custom annotations to express meta-data in Java source files.
  • Build unit tests for Java classes using JUnit.
  • Write effective tests, and design classes for testability.
  • Understand test-driven development (TDD) and use dynamic mocking to support isolated testing.
Course Overview

This course provides advanced training in developing software using the Java Platform, Standard Edition, or Java SE. It is intended for students with solid experience in structured and object-oriented Java programming, including use of the Collections API and exception handling. Generic types should be understood, at least at a basic level; the course does begin with a refresher and then a more advanced treatment of generic types.

After a quick introduction to the Java Time API, students get familiar with the I/O streams model, file handling, and object serialization, and learn to use streams to communicate over network sockets. A two-chapter unit covers multi-threaded programming and concurrency techniques. We look at dynamic typing in Java, in the Reflection API and with dynamic proxies, and understand the underpinnings of source-code annotations.

Finally, several chapters at the end of the course introduce unit-testing and test-driven-development practices. Here for the first time we introduce external libraries -- JUnit, and the Mockito dynamic-mocking library -- and the study is not entirely about technology but leans more into design and good practice.

Course Outline
  1. Generics
    1. Using Generics
    2. Type Erasure
    3. Type Boundaries
    4. Wildcards
    5. Generic Methods
    6. Strengths and Weaknesses of Generics
    7. Legacy Code and Generics
  2. The Time API
    1. A History of Time ... in Java
    2. Limitations of Date and Calendar
    3. The Time API
    4. Temporal Types
    5. Accessors and Adjusters
    6. Formatting
    7. Decomposition Into Fields
    8. Date Arithmetic
    9. Managing Precision
    10. Duration and Period
    11. Time Zones and Offsets
    12. Converting Between Time Zones
  3. The Java Streams Model
    1. Delegation-Based Stream Model
    2. InputStream and OutputStream
    3. Media-Based Streams
    4. Filtering Streams
    5. Readers and Writers
    6. Byte-Array Streams
    7. String Readers and Writers
    8. Closing Streams, Readers and Writers
  4. Working with Files
    1. The File Class
    2. Modeling Files and Directories
    3. File Streams
    4. Working with File Systems
    5. The Path Interface
    6. The Paths and Files Utilities
    7. Processing with
  5. Delegating Streams
    1. Buffering
    2. Data Streams
    3. Push-Back Parsing
    4. Byte-Array Streams and String Readers and Writers
  6. Java Serialization
    1. The Challenge of Object Serialization
    2. Serialization API
    3. Serializable Interface
    4. ObjectInputStream and ObjectOutputStream
    5. The Serialization Engine
    6. Transient Fields
    7. readObject and writeObject
    8. Externalizable Interface
  7. Sockets
    1. The OSI Reference Model
    2. Network Protocols
    3. The Socket Class
    4. The ServerSocket Class
    5. Connecting Through URL Objects
    6. HTTP and Other TCP Servers
    7. Datagram Clients and Servers
    8. Non-Blocking Sockets
  8. Threads
    1. Java Thread Model
    2. Creating and Running Threads
    3. Manipulating Thread State
    4. Thread Synchronization
    5. Synchronized Blocks and Methods
    6. wait and notify
    7. join and sleep
    8. Multi-Threading in Servers
  9. Concurrency
    1. The Concurrency API
    2. Semaphore and Other Synchronizers
    3. Concurrent Collections
    4. Atomic Operations
    5. Executor and ExecutorService
    6. Thread Pools
    7. Parallel Processing
  10. Reflection
    1. Uses for Meta-Data
    2. The Reflection API
    3. The Class<T> Class
    4. The java.lang.reflect Package
    5. Reading Type Information
    6. Navigating Inheritance Trees
    7. Dynamic Instantiation
    8. Dynamic Invocation
    9. Reflecting on Generics
  11. Dynamic Proxies
    1. The Proxy Pattern
    2. Dynamic Proxies in Java
    3. Use Cases
    4. The InvocationHandler Interface
    5. Proxy Classes
  12. Annotations
    1. Aspect-Oriented Programming and Java
    2. The Annotations Model
    3. Annotation Types and Annotations
    4. Built-In Annotations
    5. Annotations vs. Descriptors (XML)
  13. Automated Unit Testing with JUnit
    1. Automated Testing
    2. JUnit and Related Tools
    3. The @Test Annotation
    4. The Assert Class Utility
    5. Test Runners
    6. Lifecycle Methods
    7. Expecting Exceptions
    8. Test Suites
  14. Writing Tests
    1. Test Granularity
    2. Reusing Test Logic
    3. Recording and Comparing Output
    4. Test Isolation
    5. Controlling the Test Environment
    6. Managing Dependencies
    7. Non-Invasive Testing
    8. Designing for Testability
    9. Factories
    10. Testing and Threads
  15. Test-Driven Development
    1. Writing the Test First
    2. The TDD Cycle
    3. Advantages of TDD
    4. Resistance to TDD
    5. A Case Study
  16. Mocking
    1. Mock Objects in Testing
    2. Mock Objects in Test-Driven Development
    3. Static vs. Dynamic Mocks
    4. Stubbing
    5. Verifying
    6. Matching and Capturing
    7. Using a Spy
    8. Partial Mocking
Class Materials

Each student will receive a comprehensive set of materials, including course notes and all the class examples.

Class Prerequisites

Experience in the following is required for this Java Fundamentals class:

  • Solid Java programming experience is essential
Prerequisite Courses