• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Why can't I Run > Fix?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why can't I Run > Fix?


  • Subject: Re: Why can't I Run > Fix?
  • From: Markian Hlynka <email@hidden>
  • Date: Thu, 21 Jan 2010 23:31:46 -0700


On 21-Jan-10, at 13:38 , Fritz Anderson wrote:

Xcode 3.1.2, Mac OS X 10.6.2

I find that when I edit a function that is paused in the debugger, the Run > Fix menu item is inactive. I don't understand why.

Here is the function (abbreviated):

===
void doRegression(void)
{
   int             nScanned;
   int             n;
   double          sumX, sumY;
   double          sumX2, sumY2;
   double          sumXY;

   n = 0;
   //  Replace this:
   sumX = sumX2 = sumY2 = sumXY = 0.0;
   //  With this:
   //  sumX = sumY = sumX2 = sumY2 = sumXY = 0.0;
   do {
       double      x, y;
       nScanned = scanf("%lg %lg", &x, &y);
       // ...
   } while (nScanned == 2);
   //  ...
}

To my eye, this is a terrible method of initialization, and poor read-/ maintain-ability as well; Initializations for simple functions should be done in the declaration (unless it's a class/struct and you use a proper initializer list):
double sumX = 0.0;


If you need to initialize them in the code, just because you CAN run them together doesn't mean you should. Will your terminal run out of vertical lines? :-) If you write the more painful:
sumX = 0.0;
sumY = 0.0;
sumY2 = 0.0;
sumXY = 0.0;


it takes a couple lines and is WAY easier to read. Plus, when you discover in 3 months that you need different initial values you aren't going to THEN break it into separate lines and introduce a typo that takes you a week to track down.

Am I off base, or do the rest of you agree?

Markian
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Why can't I Run > Fix?
      • From: Fritz Anderson <email@hidden>
References: 
 >Why can't I Run > Fix? (From: Fritz Anderson <email@hidden>)

  • Prev by Date: Re: Including different debug and release frameworks in a .app
  • Next by Date: Re: Why can't I Run > Fix?
  • Previous by thread: Re: Why can't I Run > Fix?
  • Next by thread: Re: Why can't I Run > Fix?
  • Index(es):
    • Date
    • Thread