1

00:00:00,990  -->  00:00:08,100
Not see how we can refactor source code using Eclipse refactoring is nothing but restructuring of source

2

00:00:08,100  -->  00:00:15,630
code so that it looks much more cleaner and modular and it should not affect the external behavior of

3

00:00:15,630  -->  00:00:16,870
the source core.

4

00:00:17,360  -->  00:00:22,980
OK so let's just go out and do some refactoring here in our student test class.

5

00:00:23,100  -->  00:00:28,740
So if you recall we have this student Ari and the size of the arrays for.

6

00:00:28,740  -->  00:00:32,580
So this has been hardcoded such hard coding is not good.

7

00:00:32,580  -->  00:00:34,730
So let's just go ahead and refactor this.

8

00:00:34,770  -->  00:00:44,610
So let's just collect this going to refactor here and say extract local variable and just name the local

9

00:00:44,610  -->  00:00:46,620
variable as let's say student count

10

00:00:50,580  -->  00:00:55,630
and you can see that the student count variable has been auto created uninitialized with 4.

11

00:00:55,920  -->  00:00:58,810
And you can see the student count variable being used here.

12

00:00:59,130  -->  00:01:08,400
OK now you can do that or you can also do a right click here and you can go in Gouri factor here and

13

00:01:08,400  -->  00:01:09,510
then do the same thing.

14

00:01:09,510  -->  00:01:11,400
Extract local variable.

15

00:01:11,400  -->  00:01:12,630
Now let's just go ahead.

16

00:01:12,720  -->  00:01:16,040
And another thing that you can do as.

17

00:01:16,260  -->  00:01:18,190
Change back to 4.

18

00:01:18,870  -->  00:01:21,960
So let me go here.

19

00:01:21,990  -->  00:01:27,750
Reflektor let's say ex-black constant earlier it was X-type local variable.

20

00:01:27,750  -->  00:01:36,060
Now let's name it as since it's a constant let's name it a student underscore Gaunt's don't know when

21

00:01:36,060  -->  00:01:44,950
you do this it's going to create student content has a global variable here and initialize it at four

22

00:01:44,980  -->  00:01:45,440
.

23

00:01:45,900  -->  00:01:47,280
So that's how you do it.

24

00:01:47,490  -->  00:01:52,730
And let's say we want to move this code into a separate method.

25

00:01:52,920  -->  00:01:54,280
This bent method.

26

00:01:54,330  -->  00:01:57,950
So let's just highlight the bar code that we want to move.

27

00:01:58,260  -->  00:02:06,620
And once again right click going to refactor and say extract extract method.

28

00:02:06,810  -->  00:02:14,500
So just give them a third name as print name and gender.

29

00:02:14,970  -->  00:02:17,680
And it has two parameters name and gender.

30

00:02:17,700  -->  00:02:18,860
So let's just go ahead and hit.

31

00:02:18,870  -->  00:02:20,050
OK.

32

00:02:20,730  -->  00:02:23,800
And you can see the method in location here.

33

00:02:24,050  -->  00:02:26,120
And if you go down you can see the method.

34

00:02:26,130  -->  00:02:32,250
It has two parameters name and gender and this system Redmond's been don't Prindle and statements have

35

00:02:32,250  -->  00:02:34,250
been moved into the method now.

36

00:02:34,410  -->  00:02:35,100
So that's it.

37

00:02:35,100  -->  00:02:40,530
So that's extracting local variable extracting constant and extracting methods and you can do it from

38

00:02:40,560  -->  00:02:45,930
either from here or but I clicking on those items and that's it
