objective c: first difference
January 24 2004 11:19 PM

i'm going to try my hand at writing apps for my shiny powerbook so i am now reading a book on objective c. one interesting thing - which i like - compared to java is that each method parameter is named both in the definition of the method and also when you call the method.

for example:

[anObject methodName: value aParameter: value]

so technically, only the second parameter is named... but generally the method name would imply the name of the first parameter. an example from the book i am reading for a class to handle fractions:

[aFraction setTo: 1 over: 4]

is a method to set the numerator and denominator to 1 and 4 respectively. an alternative name could be:

[aFraction setNumerator: 1 andDenominator: 4]

what would it look like in java?

aFraction.set(1, 4)

you may argue that this is equivalent:

aFraction.setNumeratorAndDenominator(1, 4)

but try extending that to something with more than a few parameters...

Comments (0), Add Comment