Pregunta

Ok, I have this human here, but what can it do, how would you discover its special abilities? And when you find out what kind of expert you've got then how would you actually make use of its unique responsibilities?

An example for this architectural pattern question:

Base Interface with Characteristics Common to All

interface IHuman {
    DateTime GetDoB();
}

Extended Interface 1

interface ICivilian : IHuman {
    string GetEmail();
    void SendEmail();
}

Extended Interface 2

interface IAccountant : IHuman {        
    double CalculateProfits();
}

Extended Interface n+

interface IAnotherSpecializedHuman : IHuman {
    void DoSomethingExpert();
}

Specialized API Discovery and Usage

How would you design

  • a highly pluggable and loosely-coupled system
  • with which you can carry out all the common human operations (e.g. get age),
  • but also carry out any specialized operations that are available,
  • depending on which modules are incorporated
    • e.g. you can send email, because ICivilian module is provided
    • but you cannot calculate profits, because IAccountant plug-in is not provided
  • and the question is not so much about providing different implementations but about providing different specialized APIs (and APIs that have a common parent with shared functionality)

No hay solución correcta

Licenciado bajo: CC-BY-SA con atribución
scroll top