O'Reilly logo
live online training icon Live Online training

Refactoring in Java

Mastering the Tools and Techniques of a Software Craftsperson

Topic: Software Development
Victor Rentea

No matter what language, framework, deployment strategy or devops pipeline you have in place, understanding code written by someone else remains one of the most difficult challenges for programmers in our industry. Whether you’re adding new features, patching over bugs or rushing to meet the deadlines, completing tasks can become difficult for teams. Frustration can grow, bugs can spread, and deadlines can be missed. Refactoring is the solution that, so much so that developers are becoming addicted to the process, and they can’t even imagine writing code without continuously improving the structure. This is the story for hundreds of thousands of teams out there. Join this training to see some of the best automated refactorings at hand.

What you'll learn-and how you can apply it

  • The key features of Refactoring
  • Split Variable to Improve Semantics
  • Replace Temp with Query Function
  • Guard Clauses and Early Returns
  • Split Loop
  • Avoiding Boolean Parameters
  • Parameterize and Extract Method
  • Util Methods to Value Objects
  • Introduce Parameter Object
  • Designing Immutable Classes, and their benefits

This training course is for you because...

  • Developers looking to craft simple, elegant, easy to understand code
  • Any experience levels, from 0.1 to 20+ years
  • Not only Java: only basic Java language syntax will be used
  • Not only IntelliJ users: with a few exceptions, all refactorings employed are available in both Visual Studio, Eclipse and NetBeans; however, we will cover some more advanced IntelliJ-only features (5-10 minutes)

Prerequisites

Course Set-up

  • Download and install IntelliJ (Community Edition is enough): https://www.jetbrains.com/idea/download/
  • All starting code will be available at this GitHub: https://github.com/victorrentea/clean-code-java
  • During each class I will commit to a dedicated branch for that session, so that you will be able to inspect the commits later on
  • You might want to clone this repo, switch to the branch that I will mention at the start and then keep pulling changes to inspect them locally on your machine.

Recommended Follow-up

  • Refactoring 2nd edition by Martin Fowler: https://learning.oreilly.com/library/view/refactoring-improving-the/9780134757681/

About your instructor

  • Victor Rentea is a Java Champion and Associate Professor at Politehnica University of Bucharest. He has been writing code for over two decades in many programming languages, and has lead 7 projects at IBM.

    Since 2012 he helped thousands of developers become better via training sessions day-to-day coding topics, assembling an extensive curricula that cover most of the software best practices and technologies of a typical Java application. Today, over 40 companies throughout the world call him for training sessions for their employees. You can read their opinion on LinkedIn, his Facebook page, and on victorrentea.ro. Recently, key parts of his courses became accessible to anyone on Teachable.

    Victor is best known for the energy and depth of his top-rated talks at renowned conferences. You will feel the same energy in any of his training sessions. To share his passion for Clean Code and Unit Testing, he founded the Bucharest Software Craftmanship Community, one of the largest developer communities today in Romania. You can also find him posting regularly on Twitter, LinkedIn and Facebook.

Schedule

The timeframes are only estimates and may vary according to how the class is progressing

Segment 1: Intra-function (10 min)

  • The key features of Refactoring

Segment 2: Intra-function Refactorings (30-40 min)

  • Split Variable to Improve Semantics
  • Replace Temp with Query Function
  • Guard Clauses and Early Returns
  • Split Loop

Break: 10 minutes

Segment 2: Function API Refactorings (40 min)

  • Avoiding Boolean Parameters
  • Parameterize and Extract Method
  • IntelliJ Advanced Coding Features

Break: 15 minutes

Segment 3: Refactoring to Clean Classes (45 min)

  • Util Methods to Value Objects
  • Introduce Parameter Object
  • Designing Immutable Classes, and their benefits

Segment 4: Retrospective & Conclusions (10 min)

  • Recap of all refactorings
  • Discussion pros/cons/risks of each.

Course wrap-up