From the course: Java Refactoring Best Practices

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Challenge: Refactor the legacy code

Challenge: Refactor the legacy code - Java Tutorial

From the course: Java Refactoring Best Practices

Challenge: Refactor the legacy code

(gentle upbeat music) - [Instructor] It's time to get some practice with refactoring code smells. This challenge will consist of four challenges, one for each code smell we've seen. The first one is a checkout controller. This is part of a fictional legacy eCommerce application, and it's a bloater. It contains a method process order that handles the checkout process, including calculating the total amount, applying discount, and processing the payment. The method is way too large and has too much functionality. We need to refactor the method and make it more concise. Here, you can see the method. Let me present to you the second challenge. It's about primitive obsession. Here, we have a class patient that is having a lot of strengths for things that should probably not be kept in strengths, such as address, bloat type, et cetera. We need to refactor this class to use objects instead of primitives for these types. And…

Contents