Re: The Elements of Informix-4gl Style?
Posted in 1992
Path: emory!swrinde!cs.utexas.edu!sun-barr!male.EBay.Sun.COM!exodus.Eng.Sun.COM!appserv.Eng.Sun.COM!sun!amdcad!weitek!pyramid!infmx!dranney From: dranney@informix.com (David Ranney) Newsgroups: comp.databases.informix Keywords: 4gl style Message-ID: <1992Mar12.205350.8117@informix.com> Date: 12 Mar 92 20:53:50 GMT References: <1992Mar5.021035.18374@StarConn.com> Sender: news@informix.com (Usenet News) Organization: Informix Software, Inc. In article <1992Mar5.021035.18374@StarConn.com> pmahler@StarConn.com (Paul Mahler) writes: } } }Looking at most informix programs makes me want to puke. }... } }Most 4gl programs look like they were written by stupid BASIC }programmers. This seems to be an artifact of the very first }examples that came out of Informix where all the key words }were in upper case and lots of extra blank lines were inserted. } }There doesn't seem to be a pleasant style to most of the }4gl programs out there. }... The only grousing I have heard about a beautifier }was from Tony Heskett who was trying to figure out how to }capitalize the key words, which is, of course, backwards and >stupid to boot. } }So now that I've pissed off all the 4gl programmers out there }and you have your flame throwers on, what about this style }question? } }Here is a fragment of code I stole from dbgen by David }Snyder. This is a wonderful program written by a superb 4gl programmer. }I have changed it a bit for the purposes of discussion. } } SAMPLE ONE [sample of 4gl code with capitalized keywords and macro substitution deleted] } SAMPLE TWO } }Here is much the same program with various stylistic changes. [sample of 4gl code without capitalized keywords or macro substitution deleted] }Please note that spaces have been changed into tabs in the second }version. I also added a few lines. In particular there is }a line that uses a value of TRUE. This is beacuse I think that }capitalizing macro names or built-in constants (like NOTFOUND) }makes the program more readable. } }So what do you folks think? What makes for an attractive, }legible, practical 4gl style? Well, I'd like to know what you think first. It seems like you contradict yourself here. First you make the capitalization of keywords sound backwards, then you praise it. I'm not at all sure what you were getting at with the two samples of code other than complaining about the use of tabs for indentation. >Paul Mahler internet: pmahler@StarConn.com As always, style is in the eye of the beholder. C has been around longer and is more widely used than 4GL, so it has a better defined "official" style than 4gl. I'm sure that if 4GL had such a defined style which everyone used, it would seem just fine once everyone got used to it. Personally, I like the capitalization of keywords. It helps my eye to separate statements in logical units. I also use three spaces for every level of indentation. That provides enough whitespace to show the indent without causing the code to scroll off the end of the screen. I try very hard to never make a single line greater than 80 characters. This avoids printing and readability problems for other programmers. In any major piece of code, I preface every function with a header describing the function, its arguments and outputs, and what it is supposed to do. Like anyone, when I see code written in a different style I break out in hives and grumble about the programmer's ability to code. While it is a natural reaction, it isn't really legitimate to feel that way since I don't hold the monopoly on coding style. The only way to get over this syndrome is to have a commonly accepted 4GL coding style to which all reputable 4GL programmers abide, similar to C style standards. I don't think it's written down anywhere, but everyone seems to teach it.