Wish for the day: Add generating a wrapper class for a given class or interface as a refactoring option. -- Having to manually generate a wrapper for a sizeable interface -- not fun delegating every method by hand. :(

Wish for the day: Add generating a wrapper class for a given class or interface as a refactoring option.  -- Having to manually generate a wrapper for a sizeable interface -- not fun delegating every method by hand.  :(

It'd have been nice if I was allowed to use the "property p0 : I0 read getter implements I0;" style of delegation while still being allowed to then override specific methods manually using the "procedure I0.i0p0 = proc0;" approach, but sadly this not allowed and considered an error by the compiler.

Comments

  1. Strange, as the documentations says: By default, using the implements keyword delegates all interface methods. However, you can use methods resolution clauses or declare methods in your class that implement some of the interface methods to override this default behavior.
    http://docwiki.embarcadero.com/RADStudio/XE6/en/Using_Implements_for_Delegation

    ReplyDelete
  2. I used this functionality before. The difference is to declare the property type not as the interface to implement, but as the class type providing the implementing methods. It is even not necessary that this class names the interface in the declaration. It is sufficient when it provides the methods. In that case you can re-implement part of these methods in the outer class.

    ReplyDelete
  3. Lars Fosdal Hmmm... I'll check again, perhaps I've made a stupid mistake.

    ReplyDelete
  4. Uwe Raabe Thanks for responding, I'll check again.  :)

    ReplyDelete
  5. For reference, this is the error/Help page I ran into originally: ms-help://embarcadero.rs_xe/rad/E2264_Cannot_have_method_resolutions_for_interface_'%s'_(Delphi).html

    ReplyDelete
  6. ie E2264 on the docwiki
    http://docwiki.embarcadero.com/RADStudio/XE6/en/E2264_Cannot_have_method_resolutions_for_interface_%27%25s%27_(Delphi)
    which appear to indicate that the reason it fails, is  because the method that match the arguments of the interface method, has a different name than the method defined in the interface.  Since implements is used, the override method must have the same name as the method defined in the interface.  If implements was not used, the methods would be matched on argument and result types.

    ReplyDelete
  7. I think ModelMaker Code Explorer can do this. Need to check this out next weekend.

    ReplyDelete

Post a Comment