Question on Interface.

Andre Artus andre.artus at gmail.com
Wed Aug 7 02:35:37 PDT 2013


On Wednesday, 7 August 2013 at 08:18:43 UTC, SteveGuo wrote:
>> what? O_o
>> let me explain, abstract class requires its successors to 
>> implement all methods, but may have fields.
>> class successors *always* do something, either their methods 
>> has derived behavior or overridden ones. so does interface, if 
>> you has class derived from interface then its successors may 
>> or may not override its methods.
>
> Thanks for replying, I think I need read more online-docs.

As mentioned by evilrat earlier the 'string signature' should 
probably be made a readonly property, set in the constructor. I 
don't think D supports defining a constructor signature on 
interfaces (I could be wrong), so you want to define an invariant 
as part of the contract.


You may also want to protect the constructor and implement a 
factory method (or equivalent) pattern.
I will need to look it up, but if I recall it may be possible to 
define a 'final' function on the interface that can set the 
'signature'.

I regret that I cannot at this time give you a definitive answer 
as I'm not in my office where I could verify.


More information about the Digitalmars-d mailing list