How to refactor a Delphi unit with 10000 lines with no documentation?

后端 未结 8 1991
醉话见心
醉话见心 2021-02-02 00:28

I have been assigned the task to refactor a Delphi unit. Wow. 10000 lines of code, no documentation, tons of copy and paste code.

THere are many methods made with copy a

8条回答
  •  借酒劲吻你
    2021-02-02 00:49

    Does the interface section contain a bunch of class definitions? If so, create a new unit for every class and move each class to it's own unit.
    If you use Delphi 2007 or better, you can use the "refactor/Move" option to move those classes to the new (namespace) units.
    The next step is splitting the large classes into smaller classes. That's just a lot of manual work.
    Once your code is divided over multiple units, you can examine each unit, detect identical code and generate base classes that would be used as parent for the two classes that share similar functionality.

提交回复
热议问题