Inline Class
As an application evolves, new classes are introduced as new features are added and existing code is refactored. Extract Class⭐ will help to keep existing classes maintainable and make it easier to add new features. However, features can also be removed or simplified, and you’ll inevitably find that some classes just aren’t pulling their weight. Removing dead-weight classes is just as important as splitting up large classes, and inlining a class is the easiest way to remove it.
Inlining a class is straight forward:
- For each consumer class that uses the inlined class, inline or move each method from the inlined class into the consumer class.
- Remove the inlined class.
Note that this refactoring is difficult (and unwise!) if you have more than one or two consumer classes.
Xóa bỏ các class không cần thiết, move code về class chính.