You are currently browsing the archives for the refactoring category.

Competition “Laugh or cry?”. Voting

It is time to tally up results of our competition. From all published examples, I have chosen five finalists, which can be found just below. Now you can vote for two examples of a smell code. You can vote up until August, 27.

What is the Worst Code?

COTOHA’s example (32%, 15 Votes)

Ikar’s example (36%, 17 [...]

Refactoring to Strategy. My example. Part 2

So… It’s time to finish refactoring the example. In part 1 I have prepared a class for extracting strategies. Let’s look at our code:

Refactoring to Strategy. My example. Part 1

I am writing about refactoring again. I found a class that has a code which is not so clean as I want. I researched it and understood that I could make it better. It’s a good chance to demonstrate how to refactor code using pattern Strategy. Let’s go.
We have following code:

Thinking in refactoring

Today I have read the article “10 Commandments for Java Developers“. I was confused when I read the third commandment. Author said that the code was more readable in second sample then in first one.