Programming practices (20)

14 Name: #!/usr/bin/anonymous : 2007-01-10 14:03 ID:01B9SFxA

>>12
Contractions aren't cryptic. Ask any linguist. Ask any weeaboo, for that matter. I bet you Obj-C advocates use printf() without whining, too, unless you've caught the Java AIDS.

Generally people working with a program are familiar with the application programming interfaces (i.e. POSIX-y open(2), which has O_RDONLY and friends) and so something like the open_file above wouldn't be at all strange. Well, it might be on the first day on the job... but if that's a barrier then perhaps the guy ought to get the boot instead? Most of this stuff has manuals, you know.

The point I was making was that long names don't make things any easier to understand (if they did, then WOO HOO we could use those to paper over dumb coworkers!). A function called openFileOnTheFileSystemLikeWithArgumentsAndForReadingByName("name", ReadMode|ReadOnlyMode|ReallyNotForWritingMode) not only doesn't make anything more understandable, but also takes a whole lot more space on the screen, longer to read and (worse) longer to look up! Worse, when you try to use that function again, you'll likely need to look up the flag names for the second parameter, since they're written out like that and cannot be rememered as a simple O_RDONLY or some such.

Call frequency has nothing to do with it. Neither does describing the arguments. It's perfectly common for something that has to do with the filesystem (as hinted by the "file" bit, and the "open" bit) to take a name, which identifies the path to operate on, and a set of flags in an integer. It's what we call an idiom. It might be a bit "difficult" for those who had trouble understanding how an integer variable can be used as a 31-item set of boolean values, but seriously if one has trouble with that sort of thing then perhaps they should be in school studying the topic rather than employed and not putting something as fundamental as that into practice!

This thread has been closed. You cannot post in this thread any longer.