Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!aramis.rutgers.edu!paul.rutgers.edu!brushfire.rutgers.edu!gaynor From: gaynor@brushfire.rutgers.edu (Silver) Newsgroups: comp.object Subject: Re: Functions without side effects (was Old confusion) Message-ID: Date: 22 Jun 91 21:23:59 GMT References: <130242@tut.cis.ohio-state.edu> <4888@osc.COM> <72893@microsoft.UUCP> <4116@ssc-bee.ssc-vax.UUCP> <4907@osc.COM> <1991Jun19.173 <1991Jun21.013944.23970@netcom.COM> Organization: Rutgers Univ., New Brunswick, N.J. Lines: 61 Excerpt from jls@netcom.com: > Print (This_Comment => "I love named parameter names", > With_This_Spacing => 5, > On_This_Device => Devices.Laserprinter, > In_This_Font => Fonts.Helvetica); > > [vs] > > prnt("I love named parameter names",5,lsptr,hlvtca); Or print("I love named parameter names", 5, laserprinter, helvetica) > > [One should have the option to have named parameters, to clean up the > understandability of complex calling sequences. It is best used with > discretion to avoid unnecessary verbosity.] Often one hears claims that whitespace is `cheap' or `free'. This is NOT true. Strunk & White's Little Book stresses brevity's importance to clarity, a lesson we should not forget. Too much whitespace can be as detrimental to readability as too little. For instance, let's add some context to the calls above. It is not far-fetched to suppose that they might be part of a string of similar statements, perhaps a report generator. NOW which one is more readable, when written with a little flair? Print (This_Comment => "I love named parameter names", With_This_Spacing => 5, On_This_Device => Devices.Laserprinter, In_This_Font => Fonts.Helvetica); Print (This_Comment => "My kingdom for a comment", With_This_Spacing => 5, On_This_Device => Devices.Laserprinter, In_This_Font => Fonts.Helvetica); Print (This_Comment => "Self-documenting code? Hah!", With_This_Spacing => 5, On_This_Device => Devices.Laserprinter, In_This_Font => Fonts.Helvetica); Print (This_Comment => "Pork bellies are looking good", With_This_Spacing => 5, On_This_Device => Devices.Laserprinter, In_This_Font => Fonts.Helvetica); vs # Comment Spacing Device Font print("I love named parameter names", 5, laserprinter, helvetica); print("My kingdom for a comment", 5, laserprinter, helvetica); print("Self-documenting code? Hah!", 5, laserprinter, helvetica); print("Pork bellies are looking good", 5, laserprinter, helvetica); The latter is 25% shorter in vertical space, 25% longer horizontally, 50% the number of characters, and a hundredfold more readable because the statements are short enough to be written in a tabular fashion. The only expense, as far as I can tell, is that the latter version is less tolerant to changes in the function. This might be alleviated by spelling out the formal parameters in the first call as a check, and leave the remaining calls tabular. There's a better example I'd love to harp on, the common practice of devoting an entire line to compound statement delimiters. What a silly waste of space. But this discussion isn't really on comp.object's beaten tracks, so I'll cut it off here. Regards, [Ag] gaynor@paul.rutgers.edu