Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 1553: Extract Method not correct
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

enigma
Senior Member

49 Posts

Posted - Apr 22 2007 :  11:41:32 PM  Show Profile  Reply with Quote
  • Create a c# project, put the below method into a class:
    private static void ShowBarData()
    {
    string afile = Path.GetDirectoryName(Assembly.GetExecutingAssembly().FullName)+"\\\\great.txt";
    FileStream fs = File.Create(afile);
    BinaryWriter g = new BinaryWriter(fs);
    try
    {

    g.Write("");
    g.Write("Heading 3");
    g.Write("Reinforcement Data");


    g.Write("Normal 1");
    g.Write(" Nos of Steel Bar = " + " unit");
    g.Write("");

    g.Write("Table Title 1");
    g.Write("\\tTable 1 : Reinforcement coordinate, diameter and area");

    g.Write("Table Text 1");

    int BarNo = 1;
    int rowno = 1;
    for (int i = 0; i < 10; i++)
    {
    for (int j = 0; j < 20; j++)
    {
    g.Write("Bar " + i.ToString()+j.ToString());
    g.Write("Bar k" + rowno.ToString());
    g.Write(BarNo.ToString());
    rowno++;
    BarNo++;
    }
    }
    }
    finally
    {
    g.Close();
    fs.Close();
    }
    }


  • Highlight the line int BarNo=1 to the end of the for loop

  • Select "Extract Method", choose the default name. A method with the name "MyMethod" will appear as follows:
    private void MyMethod( ref BinaryWriter g )
    {
    int BarNo = 1;
    int rowno = 1;
    for (int i = 0; i < 10; i++)
    {
    for (int j = 0; j < 20; j++)
    {
    g.Write("Bar " + i.ToString()+j.ToString());
    g.Write("Bar k" + rowno.ToString());
    g.Write(BarNo.ToString());
    rowno++;
    BarNo++;
    }
    }
    }


  • Here are a couple of observations:

    • The method is not correctly indented

    • Although the method correctly identifies the BinaryWriter as the argument, but there is no need for the ref keyword, putting in ref causes a compilation error.

    • A static keyword is missing for MyMethod




http://itscommonsensestupid.blogspot.com/

feline
Whole Tomato Software

United Kingdom
18943 Posts

Posted - Apr 23 2007 :  10:32:54 AM  Show Profile  Reply with Quote
I am seeing the same effect here. Thank you for the clear description.

Formatting / indenting is wrong:

case=6149

the missing static keyword is:

case=5647

Using "Ref" on the function, but not on the function call is:

case=6154

zen is the art of being at one with the two'ness
Go to Top of Page

support
Whole Tomato Software

5566 Posts

Posted - Jul 07 2007 :  12:27:45 AM  Show Profile  Reply with Quote
case=6154 is fixed in Build 1559
Go to Top of Page

support
Whole Tomato Software

5566 Posts

Posted - Oct 29 2007 :  02:29:28 AM  Show Profile  Reply with Quote
case=6149 is fixed in Build 1614
Go to Top of Page

support
Whole Tomato Software

5566 Posts

Posted - Sep 10 2009 :  3:17:32 PM  Show Profile  Reply with Quote
case=5647 is fixed in build 1734

Whole Tomato Software, Inc.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000