The brainiest courses
for IT brainiacs.

The brainiest courses
for IT brainiacs.

Refactoring to Immutability (Changing Code to Reduce Changes in State)

Course description

It has been said that immutability changes everything. But what does that mean in
practice? What does it mean for existing code that looks more like the mutant apocalypse than an elegant application of mathematical thinking? Mainstream programming languages and architectures are typically grounded in imperative styles — from updating local variables to updating records in databases. But although they have grown from imperative roots, many mainstream languages are expressive enough and have evolved enough that they can embrace many different approaches. Indeed, trends in the development of many languages have made immutability and the reduction of mutability easier to support.

Immutability is attractive because it makes code easier to reason about, reduces the
possibility of many classes of bug, improves the testability of code, reduces the amount of validation and error-handling code, makes code more scalable when threaded and makes code more thread-safe. However, immutability can be an ideal that is hard to reach, and much advice doesn’t cover enough of the situations developers find in their codebases. Refactoring, on the other hand, is all about the art of the possible.

In Kevlin Henney’s Refactoring to Immutability course, you will learn about reducing data mutability and control-flow state in mainstream code. You will also be given guidance on how to apply refactoring as a long-term code and design practice, not simply a set of renaming shortcuts. You will put these ideas into practice and review what you learn during the course.

Structure:

  • Understand the benefits of reducing or eliminating mutability of state in objects
  • See control-flow state as a source of state change
  • Learn patterns for transforming common and less common coding idioms to a less mutable style
  • Put these patterns into practice in test-based, refactoring-oriented hands-on
    exercises
  • Appreciate how to write new code in a less mutable style
  • Identify when and when not to refactor existing code

Materials:

Course slides (PDF) are made available to course attendees during and after
the course · Slides are updated as the course progresses, including new
material created in response to questions · Slides include code samples that
Kevlin creates during lectures and in the hands-on sessions, which Kevlin also
undertakes alongside attendees to include discussion points and variations

Target audience

The course is suitable for developers looking to improve their code and who are
comfortable working in the language chosen for the course (usually Java or C#). Any
previous exposure to refactoring, unit testing and declarative programming concepts is
beneficial but not essential.

Prerequisites

  • PCs with internet access
  • All hands-on labs use an online code-and-test environment, so no special software is required

Course details

Duration: 2 days
Location: Online or in person
Trainer:

Contact us

Get in touch to find out more about this course