In order to improve software quality,the combination of refactoring techniques,software metrics,and meta-heuristic search can effectively improve the structure of software without affecting its function. In this paper,a class diagram refactoring method based on Whale Optimization Algorithm is proposed,and the quality model constructed by index coupling,inheritance and abstraction is empolyed to guide the search for the optimal refactoring sequence. Cetacean optimization method is used to refactor the class diagram in six different open source programs. The results show that the class diagram r...