joachim,
@joachim@drupal.community avatar

Is there a concept in #programming for whether an #API is inward or outward? For example, suppose I have an interface whose intention is that other code can implement it, but it's only supposed to be called by the internals of my code: it's public for implementation, but internal for callers.

rupertj,
@rupertj@mastodon.social avatar

@joachim You can document that concept with https://docs.phpdoc.org/2.9/references/phpdoc/inline-tags/internal.html . I don’t know of anything OTOH that can enforce it though.

joachim,
@joachim@drupal.community avatar

@rupertj @internal is the total opposite of API though - it means the whole thing can change at any time. A plugin interface isn't internal, it's a one-sided API.

aaronfc,
@aaronfc@mastodon.social avatar

@joachim that's a good question! I've to admit I have always called them API. It was always in the context of a Third Party and we later referred always to the spec (swagger/openapi/wsdl...).

This also reminded me of webhooks (https://en.m.wikipedia.org/wiki/Webhook).

joachim,
@joachim@drupal.community avatar

@aaronfc APIs can go in both directions as well though - for example, a service that you can call and whose class you can replace is an API that's both inward and outward. You can call it and you can implement it.

aaronfc,
@aaronfc@mastodon.social avatar

@joachim not sure I am following that part. An API is an interface (obviously haha), then you can implement it yourself or offer that API for others. It's still an interface. I thought you were looking for a name for the ones that you define but expect others to implement.

joachim,
@joachim@drupal.community avatar

@aaronfc Some interfaces are meant to be called and implemented. Some are only meant to be implemented and not called. There might be cases (I can't think of any) that are only meant to be called and not implemented.

aaronfc,
@aaronfc@mastodon.social avatar

@joachim do you have an example of an API that is supposed to be implemented but not called? Can't think of any useful case.

joachim,
@joachim@drupal.community avatar

@aaronfc Yes, plugins. You implement them to extend them, but the inventing module is in charge of calling them.

jbutz,
@jbutz@hachyderm.io avatar

@joachim Sounds a little like a plugin interface. You define what the interface looks like for a plugin and someone elsewhere implements it to extend your application's capabilities.

joachim,
@joachim@drupal.community avatar

@jbutz Yes, Drupal plugins is where I've encountered this. My module consumes the plugins, but other modules can implement further plugins to extend functionality.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • programming
  • DreamBathrooms
  • mdbf
  • ethstaker
  • magazineikmin
  • GTA5RPClips
  • rosin
  • thenastyranch
  • Youngstown
  • osvaldo12
  • slotface
  • khanakhh
  • kavyap
  • InstantRegret
  • Durango
  • JUstTest
  • everett
  • cisconetworking
  • Leos
  • normalnudes
  • cubers
  • modclub
  • ngwrru68w68
  • tacticalgear
  • provamag3
  • anitta
  • tester
  • megavids
  • lostlight
  • All magazines