Comment
Personally I am very picky about learning new things unless it really pays well (he he) or has a bright future to it :)I agree! Yet there are so many things calling me, and I know their learning curves are deep. I wish I were younger and had my swifter mind, that there were more free hours in a day to explore, and that I knew of some compass for assessing true utility and potential in advance.
Martin Pilkington:I agree regarding positional params/args vs. named or interspersed. Named and interspersed params are more perspicuous. I've long advocated adding named parameters to Java. If they are ever added, they almost certainly will have statically discoverable names, so you wouldn't have to look them up. Also note that any modern IDE picks up positional param info from the code docs and provides this information as you type the arguments, but its still not as clear as named or interspersed params.x.intersectsArc(35.0, 19.0, 23.0, 90.0, 120.0);
You can't tell what any of those values mean, you either need comments or to look up in documentation. Compare this to what such a method would be like in Obj-C:
[x intersectsArcWithRadius:35.0 centeredAtX:19.0 Y:23.0 fromAngle:90.0 toAngle:120.0];
Which is infinitely more self documented. Named parameters does help a bit, but you still need to look them up to enter them.
Stuart Malin: To me, the language has two faces, its syntax, and its runtime. Yes, the syntax is "dated." The runtime has some nifty stuff. But I concur, not all so much that is any more remarkable. However, where I feel the love-of-Cocoa begins is with what the Foundation does with the runtime capabilities. As I wrote in an earlier post here in this thread, NSObject is quite a cool beast, and since most nearly everything inherits from NSObject, the power is dispersed to the masses. So, in a narrow sense, Objective-C is a tad tawdry. But what Cocoa does with it, and what Cocoa makes available, is powerful.I agree. Cocoa is an elegant framework. It makes excellent use of UI best practice design patterns, and NSObject utilizes runtime features in some very interesting ways. I'm sure I will learn more about the details as I go.
- (id) init { if ( self = [super init] ) { [self setFirstName:@"Joe"];From a "good" coding perspective, it is advised to not invoke setter methods in your instantiator, but refer directly to your iVars. I happen to use an old convention of prefixing my iVars with an "m" for "member", so if I were to write that, I'd write:
[self setLastName:@"Smith"];
}
return self;
}
- (id) init { if ( self = [super init] ) {Nonetheless, your point is well made.
mFirstName = @"Joe";
mLastName = "Smith";
}
return self;
}
That said, you can use [NSNumber numberWithFloat:1.0] to simplify it (technically you don't need the .0 either).Be careful there -- that's an autoreleased number object in a retain/release environment. That's why the factory method is often called a "convenience" method.
© 2024 Created by Daniel Leuck. Powered by
You need to be a member of TechHui to add comments!
Join TechHui