Pregunta

The facade pattern is to provide a simplified interface for complex code.

Therefore, it is correct to use it as a wrapper for a system? That would be like a translation map for facilitating the understanding hiding the complexity?

Is it correct then call all Facade as API?

¿Fue útil?

Solución

Well the programming interface into any application is the Application Programming Interface, so yes it would be an API, in the same way that your OS has an API keeping you from fiddling with too much memory or abstracting the hard drive - or a game engine has an API acting as a facade for graphics and audio code.

So yes, the implementation of a Facade is an API, but so is any other code which you use as an interface into a more complicated system. (I guess you could ask the question as "are all APIs a facade that just provides a layer of abstraction?" - and you could probably make the argument that it's true).

It's a bit of an odd question to consider however, because depending on who you talk to, these terms may change - we only really use them to represent the idea of abstraction, as we see fit.

Otros consejos

Remember that design patterns are not hard fast rules. A Facade is an API that reduces the complexity of using some system. That system may be a single library, multiple libraries, various network clients, etc.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top