1
00:00:00,740 --> 00:00:02,850
Let's make this more tangible. Let's see

2
00:00:02,850 --> 00:00:04,950
how some of these situations play out to

3
00:00:04,950 --> 00:00:07,980
make things a bit more clear in our minds.

4
00:00:07,980 --> 00:00:11,920
And let's do that with real code. Here's a

5
00:00:11,920 --> 00:00:14,420
very simple program that instantiates one

6
00:00:14,420 --> 00:00:16,460
of those big balls of mud classes we were

7
00:00:16,460 --> 00:00:19,690
talking about, BigClass. In BigClass, we

8
00:00:19,690 --> 00:00:22,910
set a value for I, we suppose that must be

9
00:00:22,910 --> 00:00:25,120
something on the inside of the class, and

10
00:00:25,120 --> 00:00:28,090
we set it to 3. So we then increment I

11
00:00:28,090 --> 00:00:30,410
three times and then we decrement it once,

12
00:00:30,410 --> 00:00:33,670
and so we have finally a Console.WriteLine

13
00:00:33,670 --> 00:00:36,320
that should give us whatever the output of

14
00:00:36,320 --> 00:00:40,380
GetValueB is. Let's see that run. And it

15
00:00:40,380 --> 00:00:43,420
looks like the output of that function

16
00:00:43,420 --> 00:00:46,360
gives us Ball of Mud, probably not what we

17
00:00:46,360 --> 00:00:48,040
were looking for. We're going to have to

18
00:00:48,040 --> 00:00:50,740
go into our BigClass and search for it.

19
00:00:50,740 --> 00:00:53,630
It's kind of difficult to see all of the

20
00:00:53,630 --> 00:00:56,650
functions that are in here. So let's go to

21
00:00:56,650 --> 00:00:58,500
our Structure view and we can look at

22
00:00:58,500 --> 00:01:02,100
BigClass and all of its available methods.

23
00:01:02,100 --> 00:01:04,600
It turns out, if we were to go through and

24
00:01:04,600 --> 00:01:06,925
look, we would find that GetValueA returns

25
00:01:06,925 --> 00:01:08,980
the value that we're actually looking for

26
00:01:08,980 --> 00:01:12,050
in our class. So let's go back over and

27
00:01:12,050 --> 00:01:16,660
change our method to GetValueA, rerun our

28
00:01:16,660 --> 00:01:21,220
class, and this time we get that number 5

29
00:01:21,220 --> 00:01:24,830
we were looking for. Let's take a deeper

30
00:01:24,830 --> 00:01:27,340
look at our program, our base program. I

31
00:01:27,340 --> 00:01:29,400
shouldn't have to live this way, right?

32
00:01:29,400 --> 00:01:32,640
So, let's do something about it. Let's not

33
00:01:32,640 --> 00:01:36,470
have to look into our BigClass, let's only

34
00:01:36,470 --> 00:01:38,670
call methods on it that we really need to

35
00:01:38,670 --> 00:01:42,450
call. So, I'm going to add a class here,

36
00:01:42,450 --> 00:01:45,190
and we're going to call it, of course,

37
00:01:45,190 --> 00:01:48,320
BigClassFacade. You knew that's what we'd

38
00:01:48,320 --> 00:01:51,880
call it. And I'll just paste the

39
00:01:51,880 --> 00:01:53,660
implementation in here so you don't have

40
00:01:53,660 --> 00:01:57,840
to watch me type it out. Now over here in

41
00:01:57,840 --> 00:01:59,300
BigClassFacade in our structure, you can

42
00:01:59,300 --> 00:02:02,950
see that all we've got is GetCurrent,

43
00:02:02,950 --> 00:02:06,640
DecreaseBy, IncreaseBy, and a constructor.

44
00:02:06,640 --> 00:02:09,070
We also happen to have an instance, a

45
00:02:09,070 --> 00:02:13,170
field instance, of our BigClass. So, what

46
00:02:13,170 --> 00:02:15,850
we're doing is selecting what to call, but

47
00:02:15,850 --> 00:02:18,880
in the facade. So, you can see here that

48
00:02:18,880 --> 00:02:20,860
we're making two calls to BigClass, we're

49
00:02:20,860 --> 00:02:22,670
instantiating it and then we're setting an

50
00:02:22,670 --> 00:02:24,970
initial value, and we call the various

51
00:02:24,970 --> 00:02:27,630
BigClass methods that do the things we

52
00:02:27,630 --> 00:02:31,060
want it to do. All right, great. So, now

53
00:02:31,060 --> 00:02:34,510
we need to look at our program and not use

54
00:02:34,510 --> 00:02:36,970
our BigClass anymore. Instead, we're going

55
00:02:36,970 --> 00:02:40,150
to use our BigClassFacade, as I'm sure you

56
00:02:40,150 --> 00:02:42,060
guessed. And now we're down to an

57
00:02:42,060 --> 00:02:44,920
instantiation of our BigClassFacade. We

58
00:02:44,920 --> 00:02:48,330
increased by 50, decreased by 20. And

59
00:02:48,330 --> 00:02:50,130
hopefully when we write out the current

60
00:02:50,130 --> 00:02:54,040
value, we'll see something like 30. And

61
00:02:54,040 --> 00:02:56,880
there's our 30. So we successfully put a

62
00:02:56,880 --> 00:03:02,000
facade on top of some of the methods that are provided by the BigClass type.

