• 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: Recommendation: Post *neat* code to this list
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Recommendation: Post *neat* code to this list


  • Subject: Re: Recommendation: Post *neat* code to this list
  • From: Mohsan Khan <email@hidden>
  • Date: Tue, 23 Nov 2010 20:08:36 +0100

Good post!

I hate reading badly formatted code...specielly code that follows standards from the 90's. Which evern language it is.



On v.47 tis 23 nov 2010, at 18:52:58, Jerry Krinock wrote:

> General recommendation: If you want people to read your code, please spend some time to make it neat and readable.  Stuff which is formatted like this:
>
> @interface ComboscAppDelegate : NSObject <NSApplicationDelegate> {
> 	IBOutlet NSComboBox *countryCombo;
> NSMutableDictionary *theCountries;
> 	NSMutableArray *myKeys;
> 	IBOutlet NSWindow *window;
> }
>
> or this:
>
> @synthesize window;
> - (void)applicationWillFinishLaunching:(NSNotification *)notif {
>   theCountries = [NSMutableDictionary dictionaryWithObjectsAndKeys:
> 					 [NSMutableArray arrayWithObjects:@"AAABBB", @"AABBB", @"AAACCC", nil], @"A",
> 					 [NSMutableArray arrayWithObjects:@"BBBAAA", @"BBBBBBBB", @"BBBCCC", nil], @"B",
> 					 [NSMutableArray arrayWithObjects:@"CCCDDD", @"CCFGGGFF", @"CCCDDDFFF", nil], @"C", nil];
>
> 	myKeys = [NSMutableArray arrayWithObjects: [theCountries allKeys], nil];
> }
> @end
>
> makes it look like like the author doesn't really care that much.  I've read that this list has thousands of subscribers; therefore when posting code you should value their time by spending little of yours, as though you were giving a presentation to thousands of people.
>
> Apple's Mail.app indents a tab character by 8 spaces, so that if you copy code from Xcode, which you have typically set for 3-4 spaces per tab, you end up with indentations that are too large, as in the bad example above.  Since I post alot of code here, long ago I wrote a little AppleScript which processes the text on the clipboard, converting each of the tab characters inserted by Xcode into 4 spaces.  I set it as a menu item in QuicKeys.  You can put it in your Dock or other favorite app launcher.
>
> <ClipboardTabsToSpaces.scpt.zip>
>
> (P.S.  If the clipboard has alot of text on a slow Mac, wait a few seconds before pasting.)
>
> Also, if some lines in the code are too long, shorten them by defining intermediate variables (and re-test before posting!).  I understand that modern compilers will remove such intermediate variables, so there is no performance penalty.
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Recommendation: Post *neat* code to this list (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Recommendation: Post *neat* code to this list
  • Next by Date: CFRunLoopRun() and processing posix signals
  • Previous by thread: Recommendation: Post *neat* code to this list
  • Next by thread: CFRunLoopRun() and processing posix signals
  • Index(es):
    • Date
    • Thread