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

[REBOL] [ A world of words ] naming convention, namespace, namespace pollution,

From: rebol::meurrens::org at: 28-May-2003 11:40

Hello, [ A world of words ] naming convention, namespace, namespace pollution, good practises, coding styles + multiple inheritance in the example As things are going on, I feel the necessity to organize a little bit the names I use. I mean, as well, names for script *files* and names for *words* used to store my values. I did not find on the web or by reading existing scripts something like a "convention", a "tradition" { tradition may be incompatible with rebolution -:) ??? } The need arises from several reasons --- avoid clashes, namespace pollution, etc in my own works --- avoid clashes in a cooperative/collaborative process as permitted by REBOL do --- readability/documentation/sharing knowledge --- deal with "no private/public in REBOL objects" (as for PHP, etc) { I allways prefix all private things with "_" (underscore) } --- deal with "no object strong typing in REBOL" (as for PHP, etc) --- deal with "no return type in function signature" --- deal with "case insensitive in REBOL" {no camelBack convention, but we may still decide to use it on a voluntary basis} {no ALL_UPPER_CASE convention, but we may still decide to use it on a voluntary basis} --- existing scripts show an extensive use of "-" (minus) but not "_" (underscore) Any reason ??? --- availability in the names of "special" characters such as "?" "!" "#" that have/should have/receive a "universal conventional" meaning. Below are some of my current ideas/practises. Together with a short example. But before deciding/publishing/re-inventing the wheel/etc, I'll like to know if there exists already some "good practises". ?????????? When do you use *.r or *.reb or even *.rebol ??? (*.rip is for archives) Do you use some other extensions ??? (a part of *.exe for Win32 executables of course) e.g. to store images converted to REBOL binaries, etc, etc ??? as %rebol-logo_83x31.jpg.r Do you use prefixes for your script names ??? such as %i-my-script.r ;;; defines a unique value : i-my-script , an interface definition block %o-my-script.r ;;; defines a unique value : o-my-script , an implementation definition block %my-script.r ;;; defines a set of values %v-my-script.r ;;; a so-called events driven "application" using REBOL/VIEW %c-my-script.r ;;; a so-called "application" using REBOL/CORE my-script.exe ;;; compilation of %v-my-script.r for WIN32 Special names for files holding data ??? preferences ??? configurations ??? a part from the well known %user.r %preferences.r something like ??? %my-script.ini.r How do you define an "application" ??? How do you define a "reblet" ??? Do you have conventions to let know that a given file is just a set of values, or is a "reblet" ??? an application ??? Do you use special conventions for naming your words ??? such as ?my-object ;;; help function ?my-object-my-value ;;; help function my-word? ;;; returns a logic (boolean) what about other special characters, such as "# " and "!" ??? when used as the first letter??? as the last??? Is there a consensus in the community on how/when to use them ??? Do you use something like an hungarian prefix ??? such as in the following script { demonstrating also so-called "multiple inheritance" and the " interface v. body" pattern we initially developped for JAVA in an anterior and still parallel life } Do you use "multiple inheritance" ??? (does not replace "composition"...!) Do you use upper/lower cases for documentation purposes ??? such as A_NOT_SO_GOOD_PI: 3.14 ;; constant Do you use indentation conventions and some other coding syles ??? === REBOL[] ;;;; in file i-browser.r ;;; just to show interface v. implementation + show multiple inheritance i-browser: [ ?browser: function [/all][][ print "smart browser" if found? all [ ?browser-run ?browser-msg-bye ] ] ; ?browser-run: does [ help browser-run ] browser-run: function ["browse an url" u [url!]][][ browse u ] ; default implementation ?browser-msg-bye: does [ print "browser-msg-bye: ; message displayed when leaving the application"] browser-msg-bye: "bye bye" ] ;;;; in file o-browser.r ;;; just for the fun; not very smart indeed o-browser: [ browser-run: function ["browse an url" u [url!]][][ either connected? [ alert browser-msg-bye browse u ] [ alert "you are not connected to internet" ] ] ] ;;;; in file i-pretty-script.r i-pretty-script: [ ?pretty-script: function [/all][][ print "a funny example" if found? all [ ?pretty-script-run ?pretty-script-col-black ?pretty-script-col-white ] ] ; existence of ?pretty-script is also a way to test if an object "IS" a i-pretty-script ?pretty-script-col-black: does [ print "pretty-col-black: ; black is beautifull"] pretty-col-black: 10.10.10 ; nearly black ?pretty-script-col-white: does [ print "pretty-col-white: ; white is never really white"] pretty-col-white: 245.245.245 ; nearly white ?pretty-script-run: does [ help pretty-run ] pretty-run: function ["just try it"][][] ; dummy here ; to ovrdn ] ;;;; in file o-pretty-script.r ;;;; dependencies : i-pretty-script.r i-browser o-pretty-script: [ pretty-col-black: does [ random 20.20.20 ] ; ovrdn as a function, just for the fun. _pretty-col-marc: 33.66.99 ; the blue used in this implementation _pretty-laydef-1: [ style sty-but button 80x20 bold _pretty-1-but-black: sty-but pretty-col-black "black" [ alert join "nearly black " face/color ] sty-but _pretty-col-marc "home" [ browser-run ] sty-but pretty-col-white "close" [ unview ] sty-but _pretty-col-marc "quit" [ quit ] ] pretty-run: function ["just try it"][][ view layout _pretty-laydef-1 ] ] ;;;; in my applic file random/seed now my-specific: [ pretty-col-black: random 255.0.0 ; black becomes red pretty-col-white: request-color/color 233.234.235 ; let the user choices the white browser-msg-bye: {Ce n'est qu'un "Au Revoir", mes fr=E8res} ?: does [ print "===" ?browser/all print "===" ?pretty-script/all print "===" ] ] my-obj: make make make make make object! ; 5 make's expect 5 def's : i-pretty-script i-browser o-pretty-script o-browser my-specific ; open the console... my-obj/? ; do some job... my-obj/pretty-run my-obj/browser-run ==== As you see, there are many questions and I certainly forgot a lot... I'll appreciate your feedback. Regards </marc> Prof. Ir Marc Meurrens, Brussels (be) TEL: +32 (0)2 537 2812 FAX: +32 (0)2 537 7645 EMAIL: [marc--meurrens--org] URL: REB: PGPKEY: Please don't mail me attached files, instead, use my 'exchange area' : EXCHANGE AREA: (HTTP/FTP upload/download of temporary/persistent files)