Re: Using LIKE to define records in 4GL
Posted in 1995
In <3vacu3$4i3@cssun.mathcs.emory.edu> Mark.Denham@bbc.co.uk (Mark Denham) writes: > > >Ok all, > >I feel like an argument. Has anyone got any views on the use of LIKE to define >RECORDS in 4GL, or any limitations on how you use it based on personalexperience? > >To start the ball rolling I hate it and where I can insist that it is not used. I particularly >dislike its use in GLOBALS files! > >Here are my reasons: > >1) When used in the globals file, it results in the runtime app opening the db and >attempting to locate the tables of interest. In an enviroment where you have multiple >copies of the db, not necessarily with the same name, this method forces you to have >to recompile the programs for each db, or to have a dummy db that is used to >compile and is left in existance in each db enviroment. > >2) The db table and record become tightly coupled. Using LIKE tends to lead to the >widespread use of select *, input by name record.*, display by name and so forth. >These statements become very dependant on the layout of the table, and in an >evolving db environment, become a pain to maintain because you end up having >to test entire programs completely to check the affedt of inserting a column instead of >only the sections of programs that use it. > >I prefer to define the record structures explicitly, and use LIKE (if at all) to define >individual fields. I don't use it at all in a globals file and certainly not in an environment >where there are multiple copies of the database with different names. > >Heres looking forward to an interesting debate. > >Mark Denham >BBC >London, UK >Mark.Denham@bbc.co.uk I couldn't agree more. Going in to fix code because a programmer used LIKE instead of taking a couple of extra minutes to make sure that the code was more portable is one of my pet peeves. There is no good reason for not being explicit. John Prideaux alastl@ix.netcom.com