Not see how we can refactor source code using Eclipse refactoring is nothing but restructuring of source 2
code so that it looks much more cleaner and modular and it should not affect the external behavior of 3
the source core. 4
OK so let's just go out and do some refactoring here in our student test class. 5
So if you recall we have this student Ari and the size of the arrays for. 6
So this has been hardcoded such hard coding is not good. 7
So let's just go ahead and refactor this. 8
So let's just collect this going to refactor here and say extract local variable and just name the local 9
variable as let's say student count 10
and you can see that the student count variable has been auto created uninitialized with 4. 11
And you can see the student count variable being used here. 12
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
then do the same thing. 14
Extract local variable. 15
Now let's just go ahead. 16
And another thing that you can do as. 17
Change back to 4. 18
So let me go here. 19
Reflektor let's say ex-black constant earlier it was X-type local variable. 20
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
you do this it's going to create student content has a global variable here and initialize it at four 22
. 23
So that's how you do it. 24
And let's say we want to move this code into a separate method. 25
This bent method. 26
So let's just highlight the bar code that we want to move. 27
And once again right click going to refactor and say extract extract method. 28
So just give them a third name as print name and gender. 29
And it has two parameters name and gender. 30
So let's just go ahead and hit. 31
OK. 32
And you can see the method in location here. 33
And if you go down you can see the method. 34
It has two parameters name and gender and this system Redmond's been don't Prindle and statements have 35
been moved into the method now. 36
So that's it. 37
So that's extracting local variable extracting constant and extracting methods and you can do it from 38
either from here or but I clicking on those items and that's it