Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!spool.mu.edu!uunet!visix!ip2020!adamksh From: adam@visix.com Newsgroups: comp.object Subject: Re: named parameters and verbosity [was: Functions without side effects] Message-ID: <1991Jun26.185707.26149@visix.com> Date: 26 Jun 91 18:57:07 GMT References: <130242@tut.cis.ohio-state.edu> <4888@osc.COM> <72893@microsoft.UUCP> <1991Jun21.013944.23970@netcom.COM> <20445@alice.att.com> <1991Jun26.001847.24239@netcom.COM> Sender: news@visix.com Reply-To: adam@visix.com Organization: Visix Software Inc., Reston, VA Lines: 53 In article <1991Jun26.001847.24239@netcom.COM>, jls@netcom.COM (Jim Showalter) writes: > argl (4.5, 8, INCR, "bargl"); > Even with a more readable name for the function, the arguments remain > essentially content-free without a lot of surrounding context. The whole > point of named parameter association is to provide the missing semantics > at the point of call, to wit: > argl (Azimuth => 4.5, Inclination => 8, Mode => INCR, Options => "bargl"); I almost never put raw constants in my code, both because of the thin semantics and because changing the constants becomes a ridiculous hunt-and-kill exercise. ("Search-and-replace: 5 [CR] with: 6 [CR]"). I would write the above in C as follows: In a header file, perhaps argl.h: #define STANDARD_AZIMUTH 4.5 #define STANDARD_INCLINATION 8 #define STANDARD_OPTIONS "bargl" In the code: argl( STANDARD_AZIMUTH, STANDARD_INCLINATION, INCR_MODE, STANDARD_OPTIONS ); Other common parameter sets might be called SECONDARY_AZIMUTH and so on. Derived or continuous values would necessarily be stored in variables, which I could then name accordingly. The primary motivation for all this is actually to provide a single maintenance point (the header file) for parametrizing the behavior of the code. The semantics part is simply choosing appropriate names. > Look, I'm not saying the advent of named parameter association will > feed all the world's children, but I do tend to get a little hot under > the collar when people--the very people you accuse me of inventing as > straw men, by the way--respond to every advance in code readability with > the "verbose" label. I've said it before and I'll say it again--there > is nothing wrong with most hackers that couldn't be fixed with a remedial > course in touch typing... Some people who complain about verbosity are hackers. Some people who complain about verbosity have given the matter a lot of thought and have useful points to make. Sometimes it's easy to confuse the two. Adam