Complex classes like EditableFieldAdmin often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use EditableFieldAdmin, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 11 | private static $menu_title = 'Editable fields'; |
||
| 12 | private static $managed_models = [ |
||
|
|
|||
| 13 | 'Moo_EditableField', |
||
| 14 | 'Moo_EditableFieldGroup', |
||
| 15 | ]; |
||
| 16 | private static $menu_icon = 'editablefield/images/icon.png'; |
||
| 17 | |||
| 18 | public function getEditForm($id = null, $fields = null) |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Return a {@link ArrayList} of all the addable fields to populate the add |
||
| 47 | * field menu. |
||
| 48 | * |
||
| 49 | * @return array |
||
| 50 | */ |
||
| 51 | private function getCreatableFields() |
||
| 76 | |||
| 77 | } |
||
| 78 |
This check marks private properties in classes that are never used. Those properties can be removed.