What is the difference between an Abstraction and a Facade?
Asked Answered
R

5

6

What is the difference between an 'Abstraction' and a 'Facade'?

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

Raguelragweed answered 18/2, 2010 at 12:45 Comment(0)
K
13

The facade pattern is an simplified interface to a larger, possibly more complex code base. The code base may be a single class, or more. The facade just gives you a simple interface to it.

Abstraction, is used to represent a concept, but not to be bound to any specific instance. (Ie: An abstract class). This doesn't imply simplifying (like the facade pattern does), but rather making a 'common' interface or representation.

Kesterson answered 18/2, 2010 at 12:53 Comment(0)
B
5

Facade is a specific design pattern, meant to hide the internal stuff inside a package / module from its clients behind a well-defined interface. It usually hides several interfaces/classes behind a single common one, hence its name.

'Abstraction' is a general term, meaning to hide the concrete details of something from the outside world.

So these two are not interchangeable terms.

Bin answered 18/2, 2010 at 12:52 Comment(0)
G
1

Facade is a GoF design pattern, very specific. In essense, it's about hiding over-complex functionality from the main body of your application.

Abstraction is a more vague term related to hiding functionality of a service from its client.

Grady answered 18/2, 2010 at 12:52 Comment(0)
A
1

Abstract to me means taking the common parts of a collection of things and creating a base thing from them, which the collection can then draw on, sort of like a parent class.

A façade is a face (literally speaking), so they analogy of a base class doesn't quite hold. A façade is more of an interface, so it wouldn't have to be related to the things that use it. I think of it more like a mask. My class will have a "disposable" mask, for example.

So the difference, in my mind, is that an abstract pattern allows a hierarchy to be built, where as a façade pattern allows classes look similar.

Aspergillus answered 18/2, 2010 at 12:55 Comment(0)
E
0

All good answers here already. Just want to add something that helped me think about it. A facade is just a design pattern that creates a level of abstraction for the client. So, thinking of it as a relationship, a facade is a type of abstraction. Different things and certainly not used interchangeably.

Exchequer answered 28/6 at 13:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.