Code refactoring is not specific to .NET 2.0 but in VS 2005 onwards there is a Refactor menu short cut menu, its a way of writing code.
Lets understand this by example.
You have a Page_Load method and you have to populate 4 GridView into it. In this case instead of writing all code into Page_Load method, divide the functionality of populating every GridView into 4 different method and call those methods into Page_Load.
Code without Refactoring
protected void Page_Load(object sender, EventArgs e)
{
// Donot write all code to populate GridView1
// Donot write all code to populate GridView2
// Donot write all code to populate GridView3
// Donot write all code to populate GridView4
}
instead write method for them and call inside Page_Load
Code after Refactoring
protected void Page_Load(object sender, EventArgs e)
{
PopulateGridView1();
PopulateGridView2();
PopulateGridView3();
PopulateGridView4();
}
private void PopulateGridView1()
{
// write your code to populate GridView1
}
private void PopulateGridView2()
{
// write your code to populate GridView2
}
private void PopulateGridView3()
{
// write your code to populate GridView3
}
private void PopulateGridView4()
{
// write your code to populate GridView4
}
Hope this will help you understand Refactoring.
Thanks
Regards,
Raja, USA
Rajansvdotnet, if this helps please login to Mark As Answer. | Alert Moderator