Xref: utzoo comp.software-eng:2592 comp.misc:7555 Path: utzoo!attcan!uunet!aplcen!uakari.primate.wisc.edu!uflorida!mephisto!mcnc!duke!romeo!crm From: crm@romeo.cs.duke.edu (Charlie Martin) Newsgroups: comp.software-eng,comp.misc Subject: Re: Coding standards (was Re: Programmer productivity) Message-ID: <16316@duke.cs.duke.edu> Date: 4 Dec 89 03:27:49 GMT References: <34796@regenmeister.uucp> <2226@jato.Jpl.Nasa.Gov> <128179@sun.Eng.Sun.COM> <546@sagpd1.UUCP> <4727@netcom.UUCP> <9157@hoptoad.uucp> Sender: news@duke.cs.duke.edu Reply-To: crm@romeo.UUCP (Charlie Martin) Organization: Duke University CS Dept.; Durham, NC Lines: 26 the problem with (do/do not) use one file per function is that it's an optimization. I'll assume that we're talking about C, not Ada or Fortran,say. There are some really good reasons to use more than one function per file in C; one of the best is to take advantage of C's feature(?) of file scope. You could, for example, implement a stack object of a hidden type by having the stack itself declared static in file stack.c, then implementing push, pop, etc as functions that access this static stack. The type of the stack representation and the details of storage are hidden from the user. This same trick can be done in, say, fortran, using functions and a BLOCK DATA subprogram, but fortran doesn't care much about how many files used. (Does anyone know of any other languages than C -- other than C++ etc -- that have this file scope mechanism?) On the other hand, there are real good reasons not to put a whole 10KSLOC program into one file: editing and compilation time strike me. What the optimum is between one function per file and only one file is probably determined by the problem and program architecture. Charlie Martin (crm@cs.duke.edu,mcnc!duke!crm) Brought to you by Super Global Mega Corp .com