O'Reilly logo
live online training icon Live Online training

Refactoring in Java

Mastering the Tools and Techniques of a Software Craftsperson

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 is one of the best known independent technical trainers in Bucharest, well-known for the passion he puts in every minute of his classes. His training experience is impressive: he trained 1.2K+ developers of 30+ companies over 200+ days of in-house sessions. Today, he is regularly called by companies of all sizes to help bring Software Craftsmanship ideology and eXtreme Programming practices to their technical culture. Victor is the founder of the Bucharest Software Craftsmanship Community in which he shares his ideas (for now, in Romanian). After 14 years of professional career, Victor is currently Lead Architect at IBM, where he practices eXtreme Programming, crafting code and coaching others each day. He is Associate Professor at Politehnica University of Bucharest (UPB), and a key community member, after organizing the largest 3 Bucharest JUG meetups in history. Victor has become internationally renowned for his passion for Clean Code and is now frequently invited to speak at many conferences around the world. His personally commitment is helping other developers grow their passion for code. On victorrentea.ro you can find out more about him, watch his best talks, slides, articles, and other goodies.

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