Java · Advanced level

Advanced level · Module 2 of 6 · 20 guided hours

Modern Java Language and Design

Use records, enums and sealed types, design with immutability and SOLID principles, apply common patterns, and use concurrency safely.

Learning objectives

  • Model data with records, enums and sealed types
  • Apply SOLID principles and common design patterns
  • Run tasks concurrently with executors without data races

Topics

  • records and compact constructors
  • enums with fields
  • sealed interfaces and pattern matching for switch
  • immutability
  • SOLID
  • strategy and factory patterns
  • ExecutorService and thread safety

Lessons

  1. Lesson 1 Records, Enums and Sealed Types

    Model data concisely with records, fixed sets of values with enums, and closed hierarchies with sealed interfaces.

    recordcompact constructorenum with fieldssealed interfacepattern matching for switch

  2. Lesson 2 Design Principles: SOLID and Immutability

    Apply the SOLID principles and immutability to make code easier to change, test and reason about.

    single responsibilityopen/closeddependency inversionimmutabilitydefensive copy

  3. Lesson 3 Common Design Patterns

    Recognise and apply the strategy, factory, builder and observer patterns where they solve a real problem.

    strategyfactorybuilderobserverpattern misuse

  4. Lesson 4 Concurrency Fundamentals

    Run independent tasks in parallel with executors and CompletableFuture, and avoid race conditions on shared data.

    threadExecutorServiceCompletableFuturerace conditionAtomicInteger

Practical activity

Refactor a pricing module that uses long if/else chains into a strategy-based design with records and an enum, keeping all tests green.

Expected outcomes

  • Simpler, safer data classes
  • Designs that are easy to extend and test
  • Awareness of concurrency risks

Assessment

Refactoring exercise with a test suite: the design must pass all tests and add a new pricing rule without modifying existing classes.

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.