In addition to Bill's comments, which covered most things I think...

On 6 Oct 2009, at 22:26, Mick Walker wrote:

   int g = Year % 19;
   int c = Year / 100;
int h = h = (c - (int)(c / 4) - (int)((8 * c + 13) / 25) + 19 * g + 15) % 30; int i = h - (int)(h / 28) * (1 - (int)(h / 28) * (int)(29 / (h + 1)) * (int)((21 - g) / 11));
        
day = i - ((Year + (int)(Year / 4) + i + 2 - c + (int)(c / 4)) % 7) + 28;

You *do* know that in C the "/" operator will do *integer* division unless one of the quantities is floating point, right? So there's no need for all of those "(int)" casts.

And I'd be inclined to give my variables meaningful names, rather than "g", "c", "h" and "i"...

Oh, and since I'm in the dot-syntax-is-evil camp, s/self.year/[self year]/g in Bill's code :-D :-D

Of course, not everyone agrees with me on that (there are many respected developers on both sides of the argument), but I *intensely* dislike the fact that the syntax looks like member variable access (though if you look closely, of course, it becomes apparent that it isn't) while simultaneously sending messages---which can in general have side effects.

(As you've probably realised by now, a lot of the changes being suggested are stylistic.)

Kind regards,

Alastair.

--
http://alastairs-place.net




_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to