From the course: Java Refactoring Best Practices

Unlock this course with a free trial

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

Refactoring incorrect object-oriented programming

Refactoring incorrect object-oriented programming - Java Tutorial

From the course: Java Refactoring Best Practices

Refactoring incorrect object-oriented programming

- [Instructor] Object-oriented programming comes with great benefits, but it's not the easiest thing to do, especially understanding all the long-term implications of a chosen design, and mistakes happen. If we continue to build on these mistakes, the foundation of our application is built on mistakes. We call this incorrect object-oriented programming, and this incorrect object-oriented programming is a code smell that indicates a misuse of OOP concepts such as inheritance, polymorphism, and interfaces. It can make the code harder to understand, and again, harder to maintain. It can result in duplicate code as well. Let's talk about an example in real life. Let's say we work at a pet insurance company and we have a class hierarchy that represents different types of animals such as cats, dogs and birds. Each class has some common behavior and some specific behavior, but there's a lot of duplicated code and a lack of…

Contents