Lecture thumbnail 0:04 / 3:09 All right.

We’re now going to talk about the facade design pattern.

And before you ask that thing under the letter, C is a Cedilla and that’s what makes it pronounced

as S instead of K.

So facade is a design pattern which may end up you having to write a Unicode character in some of the

identifiers if you want to be 100% correct because that is what you would need to to properly specify

the name.

If you want the name as part of your identifier, which is a bit of a Java way to be honest.

So essentially the facade is all about exposing several components through a single interface, making

things convenient for the end user.

So let’s talk about the motivation.

I’m going to use the example of a house here.

So essentially a house is a system which tries to balance complexity on the one hand, because to be

honest, a house is a building is a fairly complicated system.

But on the other hand, it has to have both presentation and usability, which means when I’m buying

the house, I’m actually buying the way the house looks as well as how usable it is for my liking.

I’m not trying to measure, you know, the cross section of the wiring being used in house necessarily

or any of the details.

So if you think about a typical home, then, you know, it has many subsystems.

Like for example, you need to have electricity in the house, you need to have plumbing and sanitation

functionality in the house and so on.

You also have fairly complex internal structures in the house, like, for example, the way the floor

is built is actually kind of multi-layered and everything, but you don’t want to worry about this.

And indeed the end user, when you go and you buy a house, you are not really exposed to the internals.

There might be really unpleasant bugs in the flooring, for example, but you’ll never see them because

you don’t actually open up the floors.

When you buy a house, you don’t go in that deep, so you give it a superficial look.

You know that the area of the house and where it’s positioned and so on is what you enjoy and then you

buy the house.

That’s how it typically works.

And the same goes with software in the sense that sometimes the consumers of your API just want something

simple to work with.

And sure, you have many systems and they’re all working together as a well-oiled mechanism and they’re

doing something very complicated.

But the thing is the API consumers want it to just work.

You just want a couple of simple function calls and get the system running.

So a typical example would be something like the console that we use throughout all the demos.

The console is actually a complicated piece of machinery.

It has buffers, it has plenty of settings, but I can just do console dot write line and I’ve been

doing that throughout the entire course and that’s my API essentially.

That’s all that I am using.

So I don’t need to worry about all the different buffers and reallocations and buffer overruns and whatnot.

So all of this is kind of hidden from me and I’m just working with a public interface of what’s essentially

a system or indeed sets of systems working together.

So the facade design pattern is all about providing a simple, easy to understand interface over a large

and sophisticated body of code.

Stop Play Start Play information alert