What is the difference between abstraction and facade?

What is the difference between Abstraction and Facade?

Is there any difference at all? Or are the terms interchangeable?

+4
source share
4 answers

facade scheme is a simplified interface to a larger, possibly more complex code base. A code base can be one class or more. The facade just gives you a simple interface.

Abstraction is used to represent the concept, but not to bind to any particular instance. (I.e.: abstract class). This does not mean simplification (for example, a facade template), but rather the creation of a “common” interface or view.

+11
source

Facade is a special design template designed to hide internal content inside a package / module from its clients behind a well-known design, a specific interface. It usually hides several interfaces / classes behind one common one, hence its name.

"Abstraction" is a general term meaning to hide the specific details of something from the outside world.

So these two are not interchangeable.

+3
source

Facade - GoF design template, very specific. In essence, it is about hiding complex functionality from the main part of your application.

Abstraction is a more vague term associated with hiding the functionality of a service from its client.

+1
source

To me, a summary means accepting the common parts of a collection of things and creating a basic thing from them that the collection can then draw, sort of like a parent class.

A façade is a face (literally), so the analogy of the base class is not quite fulfilled. A façade is more of an interface, so it should not be associated with things that use it. I think it looks more like a mask. For example, my class will have a “one-time” mask.

Thus, the difference, in my opinion, is that the abstract template allows you to build a hierarchy where the classes look the same as a facade template.

+1
source

Source: https://habr.com/ru/post/1301698/


All Articles