Re: [newb] Allowing error-prone code line to persist in app

2009-08-18 Thread I. Savant
On Aug 18, 2009, at 1:12 PM, Chris Paveglio wrote: BTW This is a corporate-internal application only, so the format of phone numbers doesn't need to handle multiple locales. Did you miss Alastair's second point about the possibility of a user in the US inputting an international customer'

Re: [newb] Allowing error-prone code line to persist in app

2009-08-18 Thread Chris Paveglio
OK Thanks everyone for the very helpful input. I've never had any formal computer-science training and take the ease of Applescripting for granted. Moving to Cocoa is going slowly but well. These are the kinds of things I didn't learn in Cocoa Boot Camp (great, but so much yet so little in 7 day

Re: [newb] Allowing error-prone code line to persist in app

2009-08-18 Thread Alastair Houghton
On 18 Aug 2009, at 17:35, I. Savant wrote: On Aug 18, 2009, at 12:25 PM, Alastair Houghton wrote: Also, PLEASE remember that there are people who don't live in the United States! WHAT?! Oh, those poor dears! ;-) In seriousness, yes, very valid point. There are, however, no good localiz

Re: [newb] Allowing error-prone code line to persist in app

2009-08-18 Thread Nick Zitzmann
On Aug 18, 2009, at 10:35 AM, I. Savant wrote: In seriousness, yes, very valid point. There are, however, no good localized (localised?) "phone number formatters" built into the system so rolling your own is no small task. And in case anyone needs this, then please join me in filing a bug

Re: [newb] Allowing error-prone code line to persist in app

2009-08-18 Thread I. Savant
On Aug 18, 2009, at 12:11 PM, Chris Paveglio wrote: But if there is not a second phone/fax number, I don't really care if this line fails. I certainly *could* write a check like "if (originalFax != @"") then... continue with function". But would that take more time to process? Look up t

Re: [newb] Allowing error-prone code line to persist in app

2009-08-18 Thread Alastair Houghton
On 18 Aug 2009, at 17:11, Chris Paveglio wrote: *** -[NSCFString substringWithRange:]: Range or index out of bounds [snip] So SHOULD I write the check to make sure the data is valid or not? Or just let the function fail because its faster and has no lasting impact? Is it OK if this line q

Re: [newb] Allowing error-prone code line to persist in app

2009-08-18 Thread Nick Zitzmann
On Aug 18, 2009, at 10:11 AM, Chris Paveglio wrote: So SHOULD I write the check to make sure the data is valid or not? Do you want your program to work correctly or not? Or just let the function fail because its faster and has no lasting impact? Is it OK if this line quietly (to the user)

Re: [newb] Allowing error-prone code line to persist in app

2009-08-18 Thread Kyle Sluder
On Aug 18, 2009, at 9:11 AM, Chris Paveglio wrote: NSString *formattedFax = [NSString stringWithFormat:@"%...@-%@-%@", [originalFax substringWithRange:NSMakeRange(0,3)], etc... *** -[NSCFString substringWithRange:]: Range or index out of bounds This is an error. You must fix it. But

Re: [newb] Allowing error-prone code line to persist in app

2009-08-18 Thread bryscomat
There would be NO performance impact to impose the check. Always perform range-checking as it will most likely break under circumstances outside of your development environment. It's not just a matter of style. On Aug 18, 2009, at 11:11 AM, Chris Paveglio wrote: This is a question of style

[newb] Allowing error-prone code line to persist in app

2009-08-18 Thread Chris Paveglio
This is a question of style. My app has text fields to display a number, and with a command I format it like a phone number. So for the second phone number, sometime there is not a second phone (or fax). So my command to format the 2nd phone number logs an error to the console when I run it: NS