• 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: newbie questions about objective-c, ruby, python, groovy and cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: newbie questions about objective-c, ruby, python, groovy and cocoa


  • Subject: Re: newbie questions about objective-c, ruby, python, groovy and cocoa
  • From: Andy Lee <email@hidden>
  • Date: Thu, 10 Jun 2004 05:56:08 -0400

On Jun 10, 2004, at 4:06 AM, KlunkyRobot wrote:
To be honest Objective-C syntax is ugly from a Java syntax point of view, I hope that it is just a lack of familiarity on my part.

Other Java programmers have described a similar reaction to Objective-C syntax. I think you are right about familiarity. Over time, you may come to like what other programmers like about it, but who knows, maybe not.

Personally, I would be much, much fonder of Java if it used the same messaging syntax as Objective-C. When a method has multiple arguments, it seems natural to me for the method name to indicate the purpose of each argument. This is natural to do with Objective-C syntax, which breaks up the method name with an identifier plus a colon for each argument. It's less easy in Java or C++, where you have to express a method's intention in a single identifier that prefixes a parade of arguments. And in Java you have even less flexibility when the thing you are naming is a constructor. The name of the constructor has to be the name of the class. It can't contain any hints to the reader of your code.

Because I consider myself spoiled on Objective-C/Smalltalk messaging syntax, part of me grumbles whenever I have to switch to Java, even though I do appreciate the overwhelmingly many good things about it. Again, this is just my personal feeling.

On 10/06/2004, at 4:54 PM, Allan Odgaard wrote:

On 10. Jun 2004, at 6:11, KlunkyRobot wrote:
2- Method Overloading - Is it true that this is not supported in
Objective-c [...]?

It supports it only when the number of arguments differ.

If the number of arguments differ, then the method names *have* to differ (by at least one colon, since method names have exactly one colon per argument), so technically you don't have method overloading.

Method overloading is a convenience provided by the compiler so you don't have to think of a different name when you have two methods that are conceptually the same but take different arguments. But in Objective-C, when you have different arguments, the *natural* thing to do is to name the method accordingly. I see this as a good thing because it makes code more readable. If a method is well named, you don't have to refer to the documentation to see the meanings of its arguments, or figure out which version of the method foo(,,,) the compiler will choose based on the argument types. In Objective-C, the method name itself will tell you.

--Andy
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: newbie questions about objective-c, ruby, python, groovy and cocoa
      • From: Allan Odgaard <email@hidden>
References: 
 >Re: newbie questions about objective-c, ruby, python, groovy and cocoa (From: "KlunkyRobot" <email@hidden>)

  • Prev by Date: Re: NSOutlineView Problem
  • Next by Date: Re: How to create a easy of use Installer?
  • Previous by thread: Re: newbie questions about objective-c, ruby, python, groovy and cocoa
  • Next by thread: Re: newbie questions about objective-c, ruby, python, groovy and cocoa
  • Index(es):
    • Date
    • Thread