Class, constructor and inherance.

Rikki Cattermole via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Oct 14 20:54:03 PDT 2015


On 15/10/15 4:45 PM, holo wrote:
>>
>> Just some ideas:
>>
>> interface RequestResult {
>>     ...
>> }
>>
>> RequestResult go(string[string] requestParameters)
>
> Basically it is same what you wrote in one of first posts. Interface is
> for declaration of methods which need to be implemented in class. How in
> that case is it possible to return RequestResult which is basically xml
> form as function/s and one of it will be go itself? Do you have any link
> to such solution which i can take as example? I was looking for it but
> didn't find such solution.
>
> One idea
>
> interface RequestResult
> {
>    string doSomethingWithXML(string xmlString);
>    RequestResult go();  //or just not put here that go?
> }
>
>
> Class SigV4 : RequestResult
> {
>    ...
>
>    go()
>    {
>      string xml;
>      ...
>      return doSomethingWithXML(xml);
>    }
>
>    doSomethingWithXML(string xmlString)
>    {
>      ...
>    }
> }
>
> but i still don't see how it could work like that.

SigV4 would not inherit from RequestResult. Credential interface 
provides a method to make the requests. RequestResult would be just an 
abstraction around what you expect to get back. The abstraction allows 
so that interface is what you will commonly need. You can cast to the 
specific implementation e.g. SigV4Result to get access to resulting data 
from the SigV4 process.


More information about the Digitalmars-d-learn mailing list