Knowledge required for object-oriented refactoring
Introduction
We will continue to add things that we think are necessary for refactoring in Java.
The books I referred to are as follows.
Principles to be aware of
--DRY (Do n’t Repeat Your Self) Principle
- https://ja.wikipedia.org/wiki/Don%27t_repeat_yourself
--Avoid repetition (duplicate)
--KISS (Keep it simple, stupid) principle
- https://ja.wikipedia.org/wiki/KISS%E3%81%AE%E5%8E%9F%E5%89%87
--Design simplicity is important, and unnecessary complexity should be avoided
--YAGNI (You ain't gonna need it) Principle
- https://ja.wikipedia.org/wiki/YAGNI
--Features should not be added until they are actually needed
Prerequisite knowledge
--Basic understanding of OOP (Object Oriented Programming)
--Relationship between class and instance
--Access modifier
--Inheritance (abstract classes and interfaces)
--Override, overload
--Local variables, instance variables, static variables (class variables)
Definition of refactoring
- Improving the internal structure of a program without changing the behavior of the program as seen from the outside
About the test
Unit test definition
- Created by the developer himself
- Targeting code (usually a unit of class or method)
- Must be automated
Purpose of refactoring
- Make it easier to find bugs
- Make it easier to add features
- Make it easier to review
Tips
- Follow the refactoring catalog instead of fixing it with the senses
- Step by step (one at a time)
- First, sniff out the ominous smell
Ominous odor (possibility of refactoring)
An ominous odor is the part of the code that needs to be refactored.
The scent is a knack for sensuously feeling the "difficult to understand," "difficult to modify," and "difficult to expand" parts of a program.
See List of "Ominous Smell" Suggesting Refactoring Possibility
Refactoring Catalog
"Refactoring" by Martin Fowler
A catalog of refactoring methods published by ThoughtWorks, to which
- https://refactoring.com/catalog/
A partial excerpt from a frequently-used catalog
See Refactoring Catalog (Excerpt)