refactoring java video series

comprehension refactoring (coffee machine part 3)

I am doing a little bit of comprehension refactoring on the model of the coffee machine. When doing comprehension refactoring, we study the code and keep our eyes open for design smells. We start renaming things and move stuff around so the code becomes more reasonable for us.

The code on my GitHub

refactoring to mvc (coffee machine part 2)

I am refactoring the Coffee Machine Cli App that i tested in the last episode towards Model View Controller Pattern.

The code on my GitHub

testing a legacy cli app (coffee machine part 1)

Adding characterization tests to a legacy java code command line application. Running into the legacy code dilemma because of dependencies to the System global.

The code on my GitHub

I found the code thanks to Ted Young, check out his quality coding twitch stream.

Where the code originates from: stackexchange post

Recommended book: Working Effectively With Legacy Code

Recommended talk: Michael Feathers - the deep synergy between testability and good design.

The 3rd party lib i used for Characterization Testing: Seamer.

Post about Preparatory Refactoring.

embellishment to decorator

Moving a cross cutting concern to a decorator can improve flexibility and at the same time reduce complexity of the subject.

the code on my GitHub

lift up conditional

The lift up conditional refactoring is useful for complex and deeply nested conditionals, where related parts are scattered all over the place. I am using the Gilded Rose Kata, which is a perfect example, as it consists of a really complex conditional.

the code on my GitHub

conditional to polymorphism

A conditional, like a switch statement can sometimes be fraudulent. It appears to be a nice and simple solution when it is in fact hiding and provoking duplication. By refactoring to polymorphism we adhere to the ‘Tell Don’t Ask’ principle and get rid of the duplicated parts.

the code on my GitHub

split phase

In a split phase refactoring, we split a tangled piece of code that does more than one thing into distinguished phases that only do a single thing. As a result we can more easily and independently change each of the resulting phases.

the code on my GitHub

extract value object

A value object is a reusable, immutable object that does not only encapsulate a primitive value, but also its behaviour. Identifying and extracting those value objects improve the cohesion in our code, and avoids duplication. Suppose i created a new component that consumed an already existing value object, i would be able to reuse the values methods instead of implementing duplicated code by accident.

the code on my GitHub