Xref: utzoo comp.software-eng:2596 comp.misc:7560 Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!ucsd!ucsdhub!hp-sdd!apollo!perry From: perry@apollo.HP.COM (Jim Perry) Newsgroups: comp.software-eng,comp.misc Subject: Re: Coding standards (was Re: Programmer productivity) Keywords: One function per file? Message-ID: <473a9700.20b6d@apollo.HP.COM> Date: 4 Dec 89 18:52:00 GMT References: <34796@regenmeister.uucp> <2226@jato.Jpl.Nasa.Gov> <128179@sun.Eng.Sun.COM> <546@sagpd1.UUCP> <4727@netcom.UUCP> <4290@pegasus.ATT.COM> Sender: root@apollo.HP.COM Reply-To: perry@apollo.HP.COM (Jim Perry) Distribution: na Organization: Hewlett-Packard Apollo Division - Chelmsford, MA Lines: 40 In article <4290@pegasus.ATT.COM> dmt@pegasus.ATT.COM (Dave Tutelman) writes: >In article <4727@netcom.UUCP> hue@netcom.UUCP (Jonathan Hue ) writes: >>>In article dopey@sun.UUCP (Can't ya tell by the name) writes: >>>>(e.g. IMHO a. few if any globals, b. one routine per file... >> >>My $0.02: I don't agree with (b) at all. In practice, (a) and (b) are > I'm glad you posted that; I was thinking of doing so. Right on! > >There IS one argument, in some cases a compelling one, for "one function >per file". In general, linkers aren't smart enough to link just >PART of a binary file (.OBJ or .o), when that file contains a function >needed by the link. Consider, therefore, developing a library of functions ... >The linker wouldn't be able to separate out the bash() function from >the binary file, and the application would carry the memory burden >of all the widget functions. > >The alternative is to put each of the the four public widget functions >in its own file, compiling to its own binary, and use a librarian >program to combine them into a library file. Decent linkers can >easily link part of a library file, in quanta of the original object >files. > >How do we deal with the shared data? There are two ways, one ugly >and one clean (but more effort, and a little bigger which partially ... > >I've occasionally had to write libraries where this sort of thing >was important. Instead of having zillions of programmers standing on their heads like this in order to get their jobs done, how about a couple of people smarten up the linkers to do the job right? I'm not familiar with the particular linkage conventions used by the compilers/linkers that affect this group (presumably unix and popular-PC ones), but there's nothing fundamental keeping linkers from separating out the bash() function from the binary file, because I've used such linkers/loaders. Jim Perry perry@apollo.com HP/Apollo, Chelmsford MA This particularly rapid unintelligible patter isn't generally heard and if it is it doesn't matter. Brought to you by Super Global Mega Corp .com