1
00:00:00,240 --> 00:00:03,400
Here's one problem we can solve with the

2
00:00:03,400 --> 00:00:05,710
facade pattern. You may have heard of the

3
00:00:05,710 --> 00:00:07,820
big ball of mud class, made famous by

4
00:00:07,820 --> 00:00:10,020
Martin Fowler. This is one that tries to

5
00:00:10,020 --> 00:00:12,440
solve all the world's problems. It's

6
00:00:12,440 --> 00:00:14,430
bloated, it's too big, missing the point

7
00:00:14,430 --> 00:00:17,400
of object‑oriented programming altogether.

8
00:00:17,400 --> 00:00:19,790
In this case, my program only needs to

9
00:00:19,790 --> 00:00:22,120
call four methods. But we'll likely need

10
00:00:22,120 --> 00:00:24,570
to examine and dig around in the internals

11
00:00:24,570 --> 00:00:26,470
of class A to the determine which four

12
00:00:26,470 --> 00:00:30,780
they are. I can place a facade between my

13
00:00:30,780 --> 00:00:33,460
program and the giant ball of mud class

14
00:00:33,460 --> 00:00:36,210
being called. In this case, the facade has

15
00:00:36,210 --> 00:00:38,950
an internal reference to the giant class

16
00:00:38,950 --> 00:00:41,290
and orchestrates calls on behalf of the

17
00:00:41,290 --> 00:00:44,520
program. We're using a facade class to

18
00:00:44,520 --> 00:00:47,320
contain the big class and only expose the

19
00:00:47,320 --> 00:00:50,750
methods needed by the program. We can use

20
00:00:50,750 --> 00:00:52,950
more meaningful method names, and the

21
00:00:52,950 --> 00:00:55,540
program now talks to the facade without

22
00:00:55,540 --> 00:00:59,620
knowing about the big class at all. Here's

23
00:00:59,620 --> 00:01:01,810
an example of what the resulting program

24
00:01:01,810 --> 00:01:04,630
code might look like. Note we're only

25
00:01:04,630 --> 00:01:11,000
calling two methods on the facade, but the facade may well be orchestrating calls.

