Code Refactoring for Java

Code Refactoring for Java

This course deals with the concept of refactoring as a way of preventing software rot. It describes various “smells” indicating that code needs refactoring, explains which refactoring types best suit specific situations, and describes the work of refactoring in detail through analysis of concrete real-life cases.

Duration
24 hours
Course type
Online
Language
English
Duration
24 hours
Location
Online
Language
English
Code
DEV-006_JVA
Training for 7-8 or more people? Customize trainings for your specific needs
Code Refactoring for Java
Duration
24 hours
Location
Online
Language
English
Code
DEV-006_JVA
€ 600 *
Training for 7-8 or more people? Customize trainings for your specific needs

Description

This course deals with the concept of refactoring as a way of preventing software rot. The course describes various “smells” indicating that code needs refactoring, explains which refactoring types best suit specific situations, and describes the work of refactoring in detail through analysis of concrete real-life cases.

The course examines the main strategies to refactor a Java application:  smells within classes; smells between classes; composing methods; moving features between objects; organizing data; simplifying conditional expressions; making method calls simpler; dealing with generalization; refactoring with Java 8; and refactoring / testing.

certificate
After completing the course, a certificate
is issued on the Luxoft Training form

Objectives

After the completion of the course, students will be able to:

  • know refactoring principles
  • explain the need for refactoring
  • implement refactoring activities in development processes
  • identify code smells
  • make decisions on refactoring the problem code
  • perform refactoring step-by-step
  • use automated code refactoring tools

Target Audience

  • Developers
  • Senior developers

Prerequisites

  • Know UML
  • DEV-001_JVA Design Patterns (GoF). For Java
  • Know basics of object-oriented programming
  • At least one year of work experience with object-oriented languages

Roadmap

1. [Theory – 2h: Practice – 0.5h] Introduction

  • What is Refactoring
  • Rules and Strategies
  • Refactoring and Design
  • Building tests
  • Bad smells
  • Refactoring tools
  • Refactoring books

2. [Theory – 1.5h: Practice – 1h] Smells within classes

  • Measured smells
  • Names
  • Unnecessary complexity
  • Duplication
  • Conditional logic

3. [Theory – 0.5h: Practice – 1h] Smells between classes

  • Data
  • Inheritance
  • Responsibility
  • Accommodating Change
  • Library Classes

4. [Theory – 1h: Practice – 1h] Composing methods

  • Extract Method
  • Inline Method
  • Inline Temporary Variable
  • Replace Temporary Variable with Query
  • Introduce Explaining Variable
  • Split Temporary Variable
  • Remove Assignments to Parameters
  • Replace Method with Method Object
  • Substitute Algorithm

5. [Theory – 1h: Practice – 1h] Moving features between objects

  • Move Method
  • Move Field
  • Extract Class
  • Inline Class
  • Hide Delegate
  • Remove the Middle Man
  • Introduce Foreign Method
  • Introduce Local Extension

6. [Theory – 2h: Practice – 2h] Organizing data

  • Encapsulate Field
  • Self Encapsulate Field
  • Encapsulate Collection
  • Replace Record with Data Class
  • Replace Data Value with Object
  • Replace Array with Object
  • Change Value to Reference
  • Change Reference to Value
  • Duplicate Observed Data
  • Change Unidirectional Association to Bidirectional
  • Change Bidirectional Association to Unidirectional
  • Replace Magic Number with Symbolic Constant
  • Replace Type Code with Class
  • Replace Type Code with Subclasses
  • Replace Type Code with State/Strategy
  • Replace Subclass with Fields

7. [Theory – 1h: Practice – 1h] Simplifying conditional expressions

  • Decompose Conditional
  • Consolidate Conditional Expression
  • Consolidate Duplicate Conditional Fragments
  • Remove Control Flag
  • Replace Nested Conditional with Guard Clauses
  • Replace Conditional with Polymorphism
  • Introduce Null Object
  • Introduce Assertion

8. [Theory – 1h: Practice – 1h] Making method calls simpler

  • Rename Method
  • Add Parameter
  • Remove Parameter
  • Separate Query from Modifier
  • Parameterize Method
  • Replace Parameter with Explicit Methods
  • Replace Parameter with Method
  • Introduce Parameter Object
  • Remove Setting Method
  • Hide Method
  • Replace Constructor with Factory Method
  • Encapsulate Downcast
  • Replace Error Code with Exception
  • Wrap Checked Exception into Unchecked
  • Replace Exception with Test

9. [Theory – 1h: Practice – 1h] Dealing with generalization

  • Pull Up Field
  • Pull Up Method
  • Pull Up Constructor Body
  • Push Down Method
  • Push Down Field
  • Extract Subclass
  • Extract Superclass
  • Extract Interface
  • Collapse Hierarchy
  • Form Template Method
  • Replace Inheritance with Delegation
  • Replace Delegation with Inheritance

10. [Theory – 0.5h: Practice – 1h] Refactoring with Java 8

  • Replace Anonymous Classes with Lambda Expressions
  • Use Method References
  • Use lambdas to implement the command pattern
  • Use lambdas to implement the strategy pattern
  • Process Collections Using Lambdas
  • Use streams for map/filter/reduce operations

11. [Theory – 1h: Practice – 1h] Refactoring and testing

  • Testing Fundamentals
  • Types of Software Testing
  • Test Driven Development
  • Refactoring with Tests
  • Java Testing Books

Total: theory 12,5h (52%), practice 11,5h (48%)

Courses you may be interested in
Java Advanced II: High Performance Java
This course focuses on improving the performance of Java applications: identifying bottlenecks, approaches / methods for improving performance, and tools / libraries to achieve high performance.
JVA-076
40 hours
Still have questions?
Connect with us