Refactoring into Chain of Responsibility from Legacy Code

Replace nested & messed-up if-else statements with Chain of Responsibility using Refactoring Pyramid & Clean Code rules.

4.75 (76 reviews)
Udemy
platform
English
language
Programming Languages
category
518
students
2 hours
content
Apr 2020
last update
$39.99
regular price

What you will learn

Refactoring

Clean Code

Design Patterns

SOLID Principles

Working with Legacy Code

Description

This is the second module of series dedicated to turning Legacy Code into Clean Code

Although Refactoring to Chain of Responsibility is not mentioned in the core refactoring books ("Refactoring" & "Refactoring to Patterns") the techniques described in these books allow to create a plan for such a refactoring journey.

The goal of the course is to disentangle the codebase from a set of deeply nested conditional if/else statements. It is a very common case - and if it is left for a long time - then it leads to a very complex legacy code after subsequent code extensions.

We use refactoring techniques and perform all the changes live. The particitants download the source code and performs all the changes together with the trainer - step by step. In this sample we make use of Chain of Responsibility Design Pattern as goal of our refactoring journey.

The journey into Chain of Responsibility allows the attendees to practice code transformations like :

  • Merge If Statements

  • Merge Nested

  • If Statements

  • Extract Methods

  • Replace Temp with Query

  • Move Methods

  • Inline Methods

  • Extract Class / Extract Delegate

  • Extract Interface- Rename Methods & Variables

The course ends up with Homework, where the participants can experience the difference between implementing additional requirements within Clean Code and within Legacy Code. This is the difference between skipping and applying Preparatory Refactoring.


Content

Introduction to the course

Why this couse?
Refactoring facilitates earning money
Chain of Responsibility Pattern

First refactoring activities

Business domain explained
Java sources explained
Duplicated code extracted into first methods
First methods made cohesive

FInalize building blocks of the core logic

Third method extracted and made cohesive
Fourth of the core methods extracted
Fourth method made generic and reusable

Single Responsibility Principle - Classes

Composed Methods
Single Responsibility Principle Classes
Fasten Classes into a Chain of Responsibility

Summary

Recap of Refactoring Pyramid
Homework

Screenshots

Refactoring into Chain of Responsibility from Legacy Code - Screenshot_01Refactoring into Chain of Responsibility from Legacy Code - Screenshot_02Refactoring into Chain of Responsibility from Legacy Code - Screenshot_03Refactoring into Chain of Responsibility from Legacy Code - Screenshot_04

Reviews

Bartosz
September 26, 2022
The course starts with a nested if-else conditions code and ends with with cleaning it in an elegant way, called Chain of responsibility. Very well explained along with the features that IDE provides to perform refactoring. Great to see even more refactoring techniques than in the other course.
Vicky
May 21, 2022
This course is more like an art. It's like solving puzzle and instructor has explained it very well. I really recommend this course to every developer and would advise to apply this techique of refactoring in their industries. Best of luck & well done Włodek to bring this out . Hope to see more of your lectures.
Rodrigo
January 30, 2022
I have more than 20 years of software development and architecture. Włodek Krakowski is a master of refactorings. I would buy any of his courses on udemy on a spot. Totally recommend any of his materials, especially for devs who are just starting, to intermediate levels. Senior engineers will also learn to take 'that next step' in code quality and refactorings from his teachings. The refactoring pyramid model alone is a brain bomb that will make you understand the overall structure of refactorings. He has a beautiful way of seeing software. Totally worth of your time, especially in 2 hours of videos, only.
Vinicius
November 30, 2021
Never thought how a simple approach starting by removing else statements could become so powerful when it comes to refactoring! 5 star!
Ruben
May 28, 2021
The Trainer could explain in a simple manner how refactoring process does happen. He got very quickly rid from an ugly code to an elegant one. Nice.
March 15, 2021
I highly recommend taking this course on applying design patterns performing baby steps. All tests are always in green state and the refactorings are done using IntelliJ. Great course and useful tips and advices from a great teacher.
Alex
March 15, 2021
This course shows step by step how to improve code in a real application. Despite the short length of the course, the techniques shown in the course are very useful. I recommend it to everyone who wants to learn refactoring techniques in practice.
Joerg
February 13, 2021
Wlodek provides a very clear explanation of the single refactoring steps and the motivation behind it. With the sourcecode provided it is a wonderful handson experience. Thanx
Hamza
January 14, 2021
One of good course that I bought from Udemy. Helps me to understand the importance of refactoring code and some idea, I'll apply in my next mission Thank you and I hope you will publish other courses in the same domain and applying other pattern
Murat
May 5, 2020
Very nice course! it's purely practice-oriented. The instructor is trying to achieve an elegant solution by refactoring code step by step. Learning about refactoring theorically is not so difficult but applying them is little bit challenging. I think given 'Poker Hand' example is really good choise for 'chain of responsibility' to practise. Presentation and coding parts are very clear and easy-to-follow. Besides i learning some refactoring concepts, i started to use intellij more effectively thanks to him. I am very satisfied and also recommend the other course 'Pyramid of Refactoring (Java) - Cleaning Code Gradually'. Thank you so much. :)
Nacho
May 5, 2020
Very good course and very enjoyable! Step by step, very well explained and being able to see each of the refactor steps applied in a simple and easy to follow way ;-) I've really enjoyed it... and I want more!
Dusty
May 4, 2020
This course faces software complexity head-on. A small to larger refactoring strategy is followed to improve flow, methods, classes, patterns, and architecture. The result is an improved interface with neatly contained logic. I enjoyed watching the logic find a home. The chain of responsibility design pattern evaluates sets of conditions answering questions along the way. Seeing the Pyramid of Refactoring principles applied reinforces the need for daily practiced adoption. I recommend this course.
Jacek
May 4, 2020
This course presents a very nice, clean, gradual refactoring journey from a very nasty combination of if-else statements into a few concise single-responsibility classes. The follow-along format and clear explanations make it easy to understand and do yourself while watching, already putting the muscle memory in place. The fact that all the transformations are made using built-in IntelliJ features only makes everything easier. The trainer also makes sure to highlight the shortcuts you can use, to make the work progress even faster. Overall, I feel like it was a good use of my time! Will surely apply in everyday work.
Piotr
May 4, 2020
The course is engaging and fun. It shows how to transform the code in small steps, so there is no fear of getting lost. This material is a great presentation of how IntelliJ IDE can be used effectively - the code isn't as simplistic as in IntelliJ tutorials, but still small enough to understand the whole. Additionally there was a great explanation of the need of refactoring in the language of business.
Anna
May 3, 2020
Really nice course. Step by step you refactor the code to Chain of Responsibility, with great explanation WHY and how do we do it. The instructor shows us some very useful shortcuts in Intellij - I always forget about "inline" and it is super useful! During the course the instructor uses Linux/Windows shortcut but shows and repeats them for Mac. Also finally I understand Poker!

Charts

Price

Refactoring into Chain of Responsibility from Legacy Code - Price chart

Rating

Refactoring into Chain of Responsibility from Legacy Code - Ratings chart

Enrollment distribution

Refactoring into Chain of Responsibility from Legacy Code - Distribution chart

Related Topics

2733620
udemy ID
1/2/2020
course created date
9/22/2020
course indexed date
Bot
course submited by