3 ms·
I like Ruby but keywords arguments are the solution to a problem which shouldn't exist in the first place. Namely functions like.. myFunction(something, 23,23,
by copx 14y ago
I like Ruby but keywords arguments are the solution to a problem which shouldn't exist in the first place. Namely functions like..
myFunction(something, 23,23,100, somethingElse, true)
People should write smaller, more specialized functions instead (less arguments). That makes software both: more efficient and more maintainable.
If you start thinking: "Damn I wish I had keyword arguments to make this function call more comprehensible!" .. the problem is elsewhere.
- TylerE 14y ago100% disagree. For some use cases they are very useful. Like, imagine a function that generates an HTML snippet, and can optionally assign some specific class names/ids to some of the elements.
- MBCook 14y agoAs much as many people seem to hate the way Objective-C does things, I really like how it intersperses the arguments in the function name. It makes it so easy to identify parameters. Most languages: someObject.throwProduce(apple, myEnemy, 14, 17); Objective-C: [someObject throwProduce:apple at:myEnemy withForceInN:14.0 maxDisanceInM:17.0]; As long as you name the function appropriately, it's clear what each parameter does without having to look up the name. Many people complain about the long names (in this case throwProduce:at:withForceInN:maxDistanceInM:thenWaitInMS:), but it avoids the situation you have in other languages where there are 4 functions with the same name but different signatures. In Obj-C the naming conventions discourage such ambiguity and encourage self-documenting names.