Take it with a grain of salt. In particular, the use of property names without parens is generally a bad idea. And the recommended way to refer to Cocoa classes these days is to use the name as an identifier, rather than as a string. The suggestion that you can skip current application’s at the top level of a script by using me or my instead is plain bad advice.
(My favorite line from it is: “NSWindow has a bounds property”. Really?)
Sure. For properties, part of the reason is pragmatic: in some cases just using the identifier without parens simply fails. But in other cases there’s a subtle difference. Compare these two:
They return the same thing. But whereas the latter calls the value as a method, the former uses key-value coding – it’s like calling valueForKey:“lowercaseString”. And when a method is called, the scripting bridge performs appropriate translation of the result according to the method signature, whereas key-value coding always returns an object.
So if you compare, say, |length| and |length|(), the former will return an object – an NSNumber – whereas the latter returns an AppleScript integer. Similarly for something like a range – one will return the range as a record like {location:0, length:1}, whereas the other will return an NSValue.
As long as you understand and are happy to deal with the issue, it’s not a problem. But it does often mean another conversion is necessary, and it’s easy to forget. And as I said earler, it sometimes just doesn’t work, for reasons unknown.
The classes issue is simply that the last advice I’ve seen from one of the AS team was that the preferred form is current application’s NSString, rather than current application’s class “NSString”. I don’t know whether it makes any difference, although I can imagine they are resolved differently. Obviously in properties like the parent property the string method is generally needed.
You haven’t defined userDefaults. And to do that and keep them separate from your app’s defaults means creating a new defaults objects, so I reckon you might as well do it this way instead:
set theDefaults to current application's NSUserDefaults's alloc()'s initWithSuiteName:"com.apple.dock"
set theDict to theDefaults's dictionaryRepresentation()