Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 1553: Extract Method not correct

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
enigma Posted - Apr 22 2007 : 11:41:32 PM
  • 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



4   L A T E S T    R E P L I E S    (Newest First)
support Posted - Sep 10 2009 : 3:17:32 PM
case=5647 is fixed in build 1734
support Posted - Oct 29 2007 : 02:29:28 AM
case=6149 is fixed in Build 1614
support Posted - Jul 07 2007 : 12:27:45 AM
case=6154 is fixed in Build 1559
feline Posted - Apr 23 2007 : 10:32:54 AM
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

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000