Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refactoring exercises in Java

I have just been through the following paper and I found it extremely useful: http://www.objectmentor.com/resources/articles/Clean_Code_Args.pdf

I am looking for similar papers/books/tutorials/etc. that provide step-by-step practice on refactoring and/or correct class design. I have read Fowler's “Refactoring”, but I was looking for more substantial examples.

like image 228
kms333 Avatar asked Mar 21 '12 09:03

kms333


People also ask

What is refactoring in Java?

Refactoring is the process of restructuring code, while not changing its original functionality. The goal of refactoring is to improve internal code by making many small changes without altering the code's external behavior.

What are the best practices for refactoring?

The best time for refactoring is before adding new features or updates to existing code. Doing so can help improve the product's quality. By cleaning the code base before adding new features or updates, it helps to make the product more robust and easier to use in the future.

Is refactoring an XP practice in agile?

To deliver business value with well-designed software in every short iteration, XP teams also use refactoring. The goal of this technique is to continuously improve code. Refactoring is about removing redundancy, eliminating unnecessary functions, increasing code coherency, and at the same time decoupling elements.


2 Answers

You probably won't find much resource about refactoring large examples step by step. Because you can never cover all types of example.

The reason Martin Fowler use small and easy example in "Refactoring", is because almost every large chunk of bad code are a combination of different bad smell. By learning how to recognize particular bad smell, you can fix the code gradually.

I will recommend you check Working Effectively with Legacy Code. It's a book that focus on the strategies to improve large legacy code. For class design, you probably want to read some books about design pattern.

Most important, try to apply things you learn in the book to your code.

like image 60
Rangi Lin Avatar answered Sep 24 '22 14:09

Rangi Lin


The proof of the pudding is in the eating. Apply the principles you've learnt to the codebases you're working on.

like image 44
Sahil Muthoo Avatar answered Sep 25 '22 14:09

Sahil Muthoo