RE: namespace coflicts: local vs private symbols
- Posted by Al Getz <Xaxo at aol.com> Feb 09, 2003
- 406 views
Derek Parnell wrote: > > I kinda do this renaming as a naming convention of mine. > ... Variables scoped to a routine begin with 'l' (local) > ... Variables scoped to the file begin with 'v' (variable) > ... Varaibles scoped to global begin with 'g' (global) > > I've been using this convention for about 15 years with some success. > Thus I'd code... > > sequence vx > vx = {0,0,0,0} > > function Get_x() > return vx > end function > > procedure p () > sequence lx > lx = Get_x() + 1 > ? lx > end procedure > ? vx > p () > ? vx > > That's a pretty good idea. I started doing some of the global vars Global_VarName myself, and although it takes a bit longer to type "Global" with the "_" too it sure does clarify a program when you go to read it over again a year or two later so i know what you are talking about there. My biggest problems with variable naming conventions comes in with some seemingly simple tasks: sequence FileName or Filename, or even filename ? I always want to type Filename, when FileName is probably most appropriate. I tryed once to reserve the first letter as upper case to indicate a sequence (and lower case to indicate an atom or integer) but it's just too hard to do that when other naming priorities come up. I usually reserve the underscore "_" for more important things especially things like buttons, windows, edit controls, etc. : atom Button_LoadFile, Window_MainWin, Edit_Amount, Edit_Balance, etc. Although it does take longer to type the full name like "Button_" it always tells me immediately what kind of thing im accessing. I've stuck with this even when im in a hurry because it's just too handy when you go to read the code over several years later. I do like the (rather) new naming convention for include files, such as include myclass.ew as ClassOne This is going to be MOST beneficial to most of the programming i do in the future with Euphoria, especially with 'plug in' type files. The only thing i have to get used to is that the 'as' name isnt visible to any other file, it's only visible to the file it's declared in. I guess this is a good thing though, because it allows one to restrict the visibility much better, rather then be stuck with having the names automatically visible throughout the whole program. It's only a little inconvenience to have to include them in all the other files in case you do want to use them there also. Would be interesting to have a 'global include x as y' i guess. When you want to give a second party access to your 'class' this would make it much easier for them. Take care, Al