about summary refs log tree commit diff
path: root/usth/ICT2.7/P4L5 Software Refactoring Subtitles/10 - Consolidate Conditional Expression Solution - lang_en_vs3.srt
blob: 89f2722951a20a20f59e624c95bab16840384078 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
1
00:00:00,080 --> 00:00:03,230
So the resulting code will be like this. As you can see here,

2
00:00:03,230 --> 00:00:06,602
now I don't have the conditionals any longer, but I just have a call to

3
00:00:06,602 --> 00:00:09,938
this notEligibleForDisability method. And this makes the code so

4
00:00:09,938 --> 00:00:14,092
much clearer, because if I just need to understand how disabilityAmount works,

5
00:00:14,092 --> 00:00:17,945
I can clearly see there is an initial check that is actually checking whether

6
00:00:17,945 --> 00:00:22,030
an employee's eligible for disabilities or not. And if the check is false, so

7
00:00:22,030 --> 00:00:26,180
if the employee's eligible, then I'll just perform the rest of the computation.

8
00:00:26,180 --> 00:00:27,710
Otherwise I'll simply return zero.

9
00:00:27,710 --> 00:00:30,500
So if I don't need to understand the details of this check,

10
00:00:30,500 --> 00:00:33,630
I can simply look at this method and understand it all. And if I need to look at

11
00:00:33,630 --> 00:00:36,990
the details I can just go, and look at the implementation of this method,

12
00:00:36,990 --> 00:00:39,600
and I will get exactly the same information that I have here. But I'm sort of

13
00:00:39,600 --> 00:00:43,220
separating the concerns, and making the code overall more understandable, and

14
00:00:43,220 --> 00:00:46,160
therefore more maintainable, which is the main goal of refactoring.