The Elements of Informix-4gl Style
Posted in 1992
Path: emory!swrinde!zaphod.mps.ohio-state.edu!qt.cs.utexas.edu!cs.utexas.edu!uunet!psinntp!eco.twg.com!twg.com!cauhape From: cauhape@twg.com (Jeff KB6TDU Cauhape) Newsgroups: comp.databases.informix Summary: Let's move on to global variables vs. parameters... Keywords: structure, coding Message-ID: <10208@gollum.twg.com> Date: 12 Mar 92 20:31:48 GMT Organization: The Wollongong Group, Palo Alto, CA Well, I think we've taken the issue of capitalization and beaten it do death. Ditto with indentation. I'd like to bring up the topic of global variables, records and procedure parameters. Trying to understand the code left to me by my predecessor, and having to write some equally complicated applications of my own, has resulted in my formulating a few style guide lines. Most of these should be obvious, but the importance of them wasn't aparent to me until I dealt with code that didn't follow them! 1. Develope a consistent naming convention. A) Records which will be used to hold data for manipulation start with "r_". B) NULL records which are used to do a quick reinitialization of an r_ records start with "d_". let r_blah.* = d_blah.* Is faster than initialize r_blah.* to NULL 2. Use memnonic names. It's more clear what p_loop_counter does than p_k. 3. Name things with the same style in ALL programs. 4. Data items should be no more global than they need to be. 5. Begin writing procedures by writing a few lines documentation first. 6. Re-use your code whenever possible. Object code that gets used in more than one program can be put in a library. That's a start. Comments? ---------------------------------------------------------------------------- Jeff Cauhape cauhape@TWG.COM 415/962-7147 Room 224 (SneakerNet) "I haven't lost my mind. It's backed up on tape somewhere." ---------------------------------------------------------------------------- BTW, I have a C routine which I use to retrieve the values of environmental variables to my 4GL programs. If anyone wants it, ask and I'll email it to you.