Should Class Helpers be used in developing new code?

前端 未结 10 1621
眼角桃花
眼角桃花 2021-02-14 10:51

Delphi 8 introduced Class Helpers for the purposes of mapping the VCL/RTL to the .NET object hierarchy. They allow injecting methods into an existing class without overriding t

10条回答
  •  迷失自我
    2021-02-14 11:18

    Before embracing class helpers as a new tool for fancy code, I think you have to understand the limitations is includes. There is only possible to provide one class helper for one class. So what will happen if you provide class helpers for your classes, and your classes derives from a common class that some other have provided a class helper for?

    CodeGear introduces class helpers as 'a hack' to prevent breaking things, not as a cool design feature. When you design code, design it without class helpers. I know you can. When dealing with existing code that you can control, use refactoring. When there is no other way, reach for class helpers.

    Thats my opinion any way...

提交回复
热议问题