gombo@tharr.UUCP (Alun Jones) (05/22/91)
Hi. I've reached the stage in my conversion of a large suite of Fortran that I feel it would be useful to inform my bosses of where I feel their program is 'badly' written. Although I don't have any syntax problems with their code, there are one or two things that I feel are bad style - using too many implicit variables, assuming variables are initialised to zero, mixing and matching variable types in common blocks, that kind of thing. Now, most compilers will quite happily accept these as valid, although I know at least one is against ANSI standards. But I'm fairly sure they're 'bad' style. Now, I can't really say that to my bosses without some convincing arguments, so I'm looking for a Fortran programming style guide. Where can I get one, please? TIA. Alun. ~~~~~ -- Alun Jones - Unix Development Engineer - Welcom Software Technology Int'l. My sweatshirts are nothing whatsoever to do with the company I work for. They may be loud and obnoxious, but I feel morally superior to Gyles Brandreth. <-- tharr *free* public access to Usenet in the UK 0234 841503 --> "All the best freaks are here - please stop looking at me." - Marillion.
roth@oasys.dt.navy.mil (Pete Roth) (05/23/91)
In article <2167@tharr.UUCP> gombo@tharr.UUCP (Alun Jones) writes: >Hi. >I've reached the stage in my conversion of a large suite of Fortran that I >feel it would be useful to inform my bosses of where I feel their program is >'badly' written. Although I don't have any syntax problems with their code, >there are one or two things that I feel are bad style - using too many >implicit variables, assuming variables are initialised to zero, mixing and >matching variable types in common blocks, that kind of thing. >[...] How about 3 for the price of 1: 1. Kernighan, Brian W & P.J. Plauger, THE ELEMENTS OF PROGRAMMING STYLE, 2nd Edition, McGraw-Hill, 1978 (!) - a little dated now, but _still_ applicable. Even 1st edition is worth reading (1974! egads this stuff is old). 2. Kernighan, Brian W & P.J. Plauger, SOFTWARE TOOLS, Addison-Wesley, 1976. - the documentation for Ratfor, a whole bunch of algorithms for text processing, sorting, macro processing, etc. Seminal. 3. Ledgard, Henry, & possibly others, PROGRAMMING PROVERBS, can't find my copy... These books are really exercises in common sense. They give examples of good and bad code, and the reader can _see_ that one is "better" than the other, but there's some difficulty convincing others without a numerical quality measure. You might want to check into some of the literature on software complexity. Names to look for: McCabe, T Capers Jones. regards, pete - - - - - - - - - - - - - - - - - - - - - - - - - - Peter N Roth roth@oasys.dt.navy.mil Objects in this office are closer than they appear.
turner@ssdt-tempe.sps.mot.com (Robert Turner) (05/24/91)
In article <7920@oasys.dt.navy.mil> roth@oasys.dt.navy.mil (Pete Roth) writes: > >3. Ledgard, Henry, & possibly others, PROGRAMMING PROVERBS, >can't find my copy... > "Programming Proverbs for FORTRAN Programmers" by Henry F. Ledgard, Hayden Computer Programming Series, Hayden Book Company, Rochelle Park, New Jersey. My copy is a pink paper back dated Christmas 1976. Good Book. Robert -- Robert Turner (602) 897-5441 Semiconductor Systems Design Technology, Motorola turner@ssdt-tempe.sps.mot.com OR ...!uunet!dover!turner "Most Americans do not know or appreciate the fact that citizenship is the primary political office under a constitutional government." Mortimer Adler
orville@weyrich.UUCP (Orville R. Weyrich) (05/24/91)
In article <2167@tharr.UUCP> gombo@tharr.UUCP (Alun Jones) writes: >I've reached the stage in my conversion of a large suite of Fortran that I >feel it would be useful to inform my bosses of where I feel their program is >'badly' written. Although I don't have any syntax problems with their code, I did that once, and my boss took it as a personal attack. [He had written much of the code himself, in FORTRAN-II]. I lost my job. Hope you fare better. >there are one or two things that I feel are bad style - using too many >implicit variables, assuming variables are initialised to zero, mixing and >matching variable types in common blocks, that kind of thing. Avoiding implicit variables doesn't help style much, unless your compiler has an "IMPLICIT NONE" statement that will trap unexpected implicit variables arising due to typos. Assuming variables to be initialized to zero is definitely non-portable. What hardware platform are you using? It is non-standard to expect unitialized variables to be zero. Using COMMON to purposely overlay variables of different types is non-standard and will cause trouble porting to machines with different word sizes. The standard does permit defining different sets of variables in different (unnamed) COMMON statements, but only in the case that the intent is to overlay working storage usage by different routines [an obsolete usage that is not necessary in virtual-storage systems]. It is definitely against the rules to do this to accomplish type-conversions, etc. >Now, most compilers will quite happily accept these as valid, although I know >at least one is against ANSI standards. But I'm fairly sure they're 'bad' >style. Now, I can't really say that to my bosses without some convincing >arguments, so I'm looking for a Fortran programming style guide. I would suggest "FORTRAN Poisons and Antidotes" by Brian T. Smith, in the book "Portability of Numerical Software". It is Springer-Verlag Lecture Notes in Computer Science #57 (1977). The whole book is good reading. -------------------------------------- ****************************** Orville R. Weyrich, Jr., Ph.D. Certified Systems Professional Internet: orville%weyrich@uunet.uu.net Weyrich Computer Consulting Voice: (602) 391-0821 POB 5782, Scottsdale, AZ 85261 Fax: (602) 391-0023 (Yes! I'm available) -------------------------------------- ******************************
ccfj@hippo.ru.ac.za (F. Jacot Guillarmod) (05/24/91)
In <2167@tharr.UUCP> gombo@tharr.UUCP (Alun Jones) writes: >style. Now, I can't really say that to my bosses without some convincing >arguments, so I'm looking for a Fortran programming style guide. >Where can I get one, please? "The Elements of Programming Style" by Brian W Kernighan and P.J. Plauger, Mcgraw Hill, 1974, ISBN 0.07-034199-0 "Program Style, Design, Efficiency, Debugging and Testing" by Dennie van Tassel, Prentice Hall, 1974, ISBN 0-13-729939-7 I don't know if either is still in print, but you may be able to get hold of copies through inter-library loan. -- F.F. Jacot Guillarmod - Computing Centre - Rhodes University Artillery Road - P.O Box 94 - Grahamstown - 6140 - South Africa Internet: ccfj@hippo.ru.ac.za Phone: +27 [0]461 22023 xt 284 uucp: ..!uunet!m2xenix!quagga!hippo!ccfj Fax: +27 [0]461 25049