Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Compiler/Delphi/Interfaces    [ Add a report in this area ]  
Report #:  82464   Status: Open
Horrible interface declaration
Project:  Delphi Build #:  14.0
Version:    14.0 Submitted By:   János Janka
Report Type:  Suggestion / Enhancement Request Date Reported:  2/25/2010 5:31:04 AM
Severity:    Serious / Highly visible problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   275212
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
5.00 out of 5
Total Votes: 8
Description
I'd like to use interfaces everywhere, but this is awesome:

type
   IMyInterface = interface
      function GetName: string;
      procedure SetName(const Value: string);
      property Name: string read GetName write SetName;
   end;

   MyClass = class(TRemotable, IMyInterface)
   private
      FName: string;
   protected
      function GetName: string;
      procedure SetName(const Value: string)
   published
      property Name: string read GetName write SetName;  
   end;

Sorry, but it is horrible. I have to write 200 lines for a simple name property.

type
   IMyInterface = interface
      property Name: string;
   end;

   MyClass = class(TRemotable, IMyInterface)
   published
      property Name: string protected read protected write; notify;
   end;

In addition, I have to do an own property notification mechanism. It is very very painful.

Version 2.

You can give code DOM support for the Delphi Win32 compiler. We can create an own code generator for this task. But the current solution is no good now. I have a headache because of it


Steps to Reproduce:
None
Workarounds
None
Attachment
None
Comments

Erik van Bilsen at 2/25/2010 9:33:26 AM -
Another alternative that doesn't require a compiler change is to add Code Completion to interfaces.
There could be 2 levels of Code Completion:

1. In the interface definition, Code Completion code write the Getters and Setters for properties automatically.

2. In the class that implements the interface, Code Completion could automatically add the members of the interface.

János Janka at 2/27/2010 7:16:31 AM -
That's ok, but if you have twenty entity classes with twenty interfaces (+ 20 properties/interface, 20 getter/interface, 20 setter/interface, 20 property/class, 20 getter/class, 20 setter/class, 20 field/class), then why you need to implement getters/setters for accessing simple fields. It is an abnormal thing. Classes supports "inline" field read/write operations. It should be the compiler's task.

Server Response from: ETNACODE01