2

I have example code like this

IExample=interface
   procedure Test;
end;

TBaseClass=class
   function Check:boolean;abstract;
end;

TExampleObject=class(TInterfacedObject,IExample)
end;

TAnotherObject=class(TBaseClass)
end;

My question is, how I can implement interface method and abstract method from ancestor?

I use Visual Studio and C#, very simple to make implementation from abstract method and interface method, I just right click on my class, and Implement method.

Does RAD Studio XE2 have similiar tool or third party tool that have same function? because is annoying if I must write down all abstract and interface method manually

navirius
  • 209
  • 1
  • 7
  • 14
  • Dont be that lazy, programmers are supposed to write code manually after all ;) – OnTheFly May 14 '13 at 15:02
  • 1
    I don't mean lazy, but to minimize error or syntax error on my code, so I can focus on my software logic, if abstract method or interface method is few...I dont mind, but if you have many abstract method or interface method, my time will much consume to write and make sure my implementation is correct.. – navirius May 14 '13 at 15:16
  • I see neither any significant time consumption nor disposition toward errors. Just copy-paste method prototypes and return back to the logic. This task is too trivial to worry about automation. – OnTheFly May 14 '13 at 16:08
  • 1
    possible duplicate of [Delphi: keystroke or IDE option to populate interface elements on a class](http://stackoverflow.com/questions/5770200/delphi-keystroke-or-ide-option-to-populate-interface-elements-on-a-class) – Rob Kennedy May 14 '13 at 17:10
  • I dont see why this shouldnt be automated. It's just boiler plate code. – thomas Mar 04 '15 at 09:39

2 Answers2

8

I suppose there are IDE plugins out there that offer the functionality you want.

I use this method every day:

Copy the methods from your interface to the public section of your class, set cursor on one of these methods and execute shortcut CTRL-SHIFT-C. Delphi will automagically create the functions/procedures in the implementation section for you!

This works for all classes...

whosrdaddy
  • 11,720
  • 4
  • 50
  • 99
2

Yeah, it would be nice if this worked for functions inherited through Interfaces too and it would be nice if it worked in Interfaces themselves for creating Getter / Setters for Interface Properties!

That said, I will log it with QC (if its not already) as its a good suggestion.

Update: Here you go :) - http://qc.embarcadero.com/wc/qcmain.aspx?d=121748

Steve Childs
  • 1,832
  • 2
  • 20
  • 26
  • 1
    Note that [QualityCentral has now been shut down](https://community.embarcadero.com/blogs/entry/quality-keeps-moving-forward), so you can't access `qc.embarcadero.com` links anymore. If you need access to old QC data, look at [QCScraper](http://www.uweraabe.de/Blog/2017/06/09/how-to-save-qualitycentral/). – Remy Lebeau Jun 09 '17 at 17:43