about summary refs log tree commit diff
path: root/usth/ICT2.7/P4L5 Software Refactoring Subtitles/17 - Extract Method Refactoring Quiz Solution - lang_en_vs4.srt
blob: 6545de0fdf7dbbf94f416b88bee3cb0875cfdea5 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
1
00:00:00,110 --> 00:00:03,000
The first scenario is the typical case in which it is

2
00:00:03,000 --> 00:00:07,040
recommended to use the extract method refactoring, when there is duplicated code

3
00:00:07,040 --> 00:00:09,190
in two or more methods and we want to take this

4
00:00:09,190 --> 00:00:12,420
code and factor is out, and basically have the two methods called

5
00:00:12,420 --> 00:00:14,960
a third method, which is the one we create using the

6
00:00:14,960 --> 00:00:18,060
refactoring. When a class is too large, normally we don't want to

7
00:00:18,060 --> 00:00:21,330
apply the extract. Extract method. Instead, in this cases, it is

8
00:00:21,330 --> 00:00:22,900
usually more appropriate to use the

9
00:00:22,900 --> 00:00:26,420
extract class or extract subclass refactorings.

10
00:00:26,420 --> 00:00:29,750
Analogously, when the names of two classes are too similar, extracting a

11
00:00:29,750 --> 00:00:32,729
method will normally not help much. And all we need to do

12
00:00:32,729 --> 00:00:35,810
in case having too similar names is actually a problem. Is to

13
00:00:35,810 --> 00:00:39,600
rename one of the two classes, or both, if we wish. Finally,

14
00:00:39,600 --> 00:00:42,530
it is definitely appropriate to apply the extract method of refactoring in

15
00:00:42,530 --> 00:00:45,900
cases in which a method is highly coupled with a class other

16
00:00:45,900 --> 00:00:48,330
than the one where it is defined. In this case, which we

17
00:00:48,330 --> 00:00:51,740
will discuss also later in the lesson, the extract method of refactoring

18
00:00:51,740 --> 00:00:55,710
allows us to extract part of the metal to With the other class.

19
00:00:55,710 --> 00:00:58,690
Then we can take the matter that we just extracted and move it

20
00:00:58,690 --> 00:01:01,880
to the class where it actually belongs. So the extract method is one

21
00:01:01,880 --> 00:01:05,560
of the two refactorings that it is appropriate to apply in these cases.