Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: [ A world of words ] naming convention, namespace, namespace pollut

From: greggirwin:mindspring at: 28-May-2003 12:20

Hi Marc, Lots of good questions here. Others have given you good advice, so I'll just add a few opinions from my perspective. Bear in mind that I've only been REBOLing for a couple years; I'm still adjusting my mindset and still trying new things. MM> --- avoid clashes, namespace pollution, etc in my own works Yes, Meyer's thoughts on Linnaean naming conventions are very applicable to REBOL I think. MM> --- readability/documentation/sharing knowledge This is most important of all to me. MM> --- deal with "no private/public in REBOL objects" (as for PHP, etc) MM> { I allways prefix all private things with "_" (underscore) } You *can* actually create private words, with a USE block, but I haven't used this technique much myself in real applications. o: make object! [ get-a: set-a: get-b: set-b: none use [_a _b] [ _a: _b: none get-a: does [_a] set-a: func [value] [_a: value] get-b: does [_b] set-b: func [value] [_b: value] ] ] It adds a lot of code compared to: o: make object! [a: b: none] I keep thinking that I'll use it for larger things, or where I explicitly want to protect private items, but only time will tell. MM> --- deal with "case insensitive in REBOL" MM> {no camelBack convention, but we may still decide to use it on a MM> voluntary basis} MM> {no ALL_UPPER_CASE convention, but we may still decide to use it on a MM> voluntary basis} I go for readability first. I came from a VB - which is case insensitive - and I've *never* understood the appeal of case sensitive languages. I'm particularly confused by the Smalltalk/Ruby rule about the *first* letter's case defining the scope. Very strange to me. In Ruby it's a language rule, in Smalltalk it's just a convention IIRC. In any case, I've moved away from CamelBack, using dashes to separate words in REBOL. MM> --- existing scripts show an extensive use of "-" (minus) but not "_" MM> (underscore) MM> Any reason ??? I think it's easier to type and more natural looking. Other languages don't allow it or they would probably have used it too. :) MM> When do you use *.r or *.reb or even *.rebol ??? .r for REBOL files, .txt for most other things (using make-doc formatting for most things). I'm still playing with what to do about files that are really data, compressed or otherwise, but are also valid REBOL code. It's fuzzy sometimes so it's hard to say if something is treated more like data than code or vice-versa. MM> Do you use prefixes for your script names ??? No, but I've never done that. Under VB I used a modified Hungarian notation, but I use *very* little of it under REBOL; just for words that refer to VID faces at this point, and still playing with it. MM> Special names for files holding data ??? preferences ??? configurations ??? MM> a part from the well known MM> %user.r MM> %preferences.r MM> something like ??? MM> %my-script.ini.r I avoid names with multiple dots in them (e.g. xxx.ini.r) because you never know when something might get tripped up over it. For some archive versions of files, I've included the version in the file name and, while I like using dots in that case, I haven't decided if it's worth the risk. MM> How do you define an "application" ??? MM> How do you define a "reblet" ??? MM> Do you have conventions to let know that a given file MM> is just a set of values, or is a "reblet" ??? an application ??? I'll often put a "tail" on file names that tells me what they are. E.g. my-app.r my-app-lib.r my-app-test.r my-app-defs.r Other types of files get a prefix. E.g. build-my-app.r All my Windows library modules (for API defs and interfaces) start with "win-". Ultimately, I try to make the names read well, so they match how I would say them. MM> Do you use special conventions for naming your words ??? ... MM> what about other special characters, such as "# " and "!" ??? MM> when used as the first letter??? as the last??? MM> Is there a consensus in the community on how/when to use them ??? There is no consensus AFAIK. I use a trailing "?" for logic values. You can't use "#". I use * or ! sometimes, to denote a special word that is, for example, a (duplicate) reference to a value that gets modified. I usually prepend !, so it isn't confused with datatype values. MM> Do you use something like an hungarian prefix ??? Not much, as I said above. REBOL is meant to be readable, and Hungarian isn't. :) There are places I'm still playing with it, like using "ctx" for objects/contexts which may not be referenced directly in much code. MM> { demonstrating also so-called "multiple inheritance" MM> and the " interface v. body" pattern MM> we initially developped for JAVA in an anterior and still parallel life } ... MM> Do you use "multiple inheritance" ??? MM> (does not replace "composition"...!) I've only toyed with the concept in REBOL. It's a different mindset because it doesn't have to be set at design time. You could easily aggregate them at runtime. Makes for interesting possibilities. MM> Do you use upper/lower cases for documentation purposes ??? MM> such as MM> A_NOT_SO_GOOD_PI: 3.14 ;; constant I've gotten away from that convention as a general rule. I tend to treat it like underlined text now. It's only appropriate occasionally, and it's disruptive when you're reading. -- Gregg