Should Class Helpers be used in developing new code?

前端 未结 10 1648
眼角桃花
眼角桃花 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条回答
  •  -上瘾入骨i
    2021-02-14 11:09

    I find myself using them more and more as a design construct.

    Situations in which I use them :

    • In a client/server setup, I extend shared base-classes with class helpers to provide server- or client-only functionality.
    • To complement VCL/RTL classes (and other third party code) with handy tooling functions.
    • To work around differences when classes don't share the same inheritance tree (using helpers makes it possible to have have generic Count and Items properties, for example).

    In fact, I wish Delphi would accept multiple helpers for the same base class - I've even filed a request for this if I'm remembering correctly.

提交回复
热议问题