naming_conventions
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| naming_conventions [2020/11/21 11:42] – [Functions] sahl | naming_conventions [2024/02/29 12:56] (current) – [Functions] sahl | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Naming conventions ====== | ====== Naming conventions ====== | ||
| - | ===== Objects ===== | + | This is the internal naming convention for Platform. |
| - | When refering to [object name] below, object names are always lowercase and in singular form. //user// not //Users// | + | ===== PHP ===== |
| - | ===== File names ===== | + | ==== Classes and Objects |
| - | ^File type^Naming^Example^ | + | Classes are named with CamelCase and in singular case, so we have //User// and not //Users// |
| - | |Form|[object name]_[action].frm|user_edit.frm| | + | |
| - | |Data loader|load_[object name].php|load_user.php| | + | |
| - | |Data saver|save_[object name].php|save_user.php| | + | |
| - | |Data load+save|io_[object name].php|io_user.php| | + | |
| - | |Table data provider|table_[object name].php|table_user.php| | + | |
| - | ===== HTML ===== | + | |
| - | ==== Elements ==== | + | Objects are named in lowercase and with _ between words, so: |
| - | ^Element^Form^Example^ | + | $user_property |
| - | |Action|[object name]_[action]|user_edit| | + | |
| - | |Button|[object name]_[activity]_button|user_edit_button| | + | |
| - | |Dialog|[object name]_[activity]_dialog|user_edit_dialog| | + | |
| - | |Form|[object name]_form|user_form| | + | |
| - | |Menu|[object name]_menu|user_menu| | + | |
| - | |Table|[object name]_table|user_table| | + | |
| - | + | ||
| - | ==== Forms (and other actions) ==== | + | |
| - | + | ||
| - | The property which determines what to do, should be named // | + | |
| - | + | ||
| - | ===== Javascript ===== | + | |
| ==== Functions ==== | ==== Functions ==== | ||
| - | Functions | + | Functions are dromedaryCase |
| - | + | ||
| - | ===== PHP ===== | + | |
| - | + | ||
| - | ==== Classes ==== | + | |
| - | + | ||
| - | Classes | + | |
| - | + | ||
| - | ==== Functions ==== | + | |
| - | + | ||
| - | Functions should be dromedaryCase | + | |
| - | + | ||
| - | Class functions should be named according to what they do: | + | |
| - | ^calculate|Calculates | + | ^add...|Add further information to an object, meaning that nothing is replaced but something |
| - | ^can|Check if the object is able to do something| | + | ^attach...|Attach something to the object.| |
| - | ^check|Let the object | + | ^build...|Build something inside the object relying on information already present| |
| - | ^has|Check if the object have something| | + | ^calculate...|Make some kind of calculation. Typically something that's complex or can take some amount of time.| |
| - | ^get|Gets some information from the object| | + | ^can...|Check if the object is able to do something |
| - | ^getAs|Gets some information from the object | + | ^copy...|Copy some information or the entire |
| - | ^is|Check if the object is in a given state.| | + | ^check...|Check if something external to the object but relevant for the object have occured.| |
| - | ^load|Retrieves | + | ^decode...|Decode |
| - | ^save|Stores | + | ^delete...|Delete something. Typically |
| - | ^set|Set some information in the object| | + | ^encode...|Encode |
| + | ^ensure...|Ensure that something is in place or have been performed, by doing it if it haven' | ||
| + | ^find...|Find some information. Typically used for fuzzy searching. Otherwise we use get.| | ||
| + | ^get...|Get some information either | ||
| + | ^is...|Check if the object is in a given state.| | ||
| + | ^job...|A job typically called from the [[Job class]].| | ||
| + | ^load...|Read data into the object.| | ||
| + | ^on...|Used for specific events that take place in the object.| | ||
| + | ^register...|Register some information to the object.| | ||
| + | ^remove...|Removes something from the object or the object from something.| | ||
| + | ^replace...|Replaces something with something else.| | ||
| + | ^retrieve...|Retrieve some information from somewhere | ||
| + | ^parse...|Input some data which is transformed to something else.| | ||
| + | ^prepare...|Prepare some data to later usage.| | ||
| + | ^render...|Renders something to the page.| | ||
| + | ^reset...|Resets something to a previous state.| | ||
| + | ^save...|Save data from the object.| | ||
| + | ^set...|Set information in the object.| | ||
| + | ^store...|Store | ||
| + | ^validate...|Ensures that something is correct.| | ||
| - | Functions are places alphabetically in files, except for // | + | Functions are places alphabetically in files, except for // |
| ==== Variables ==== | ==== Variables ==== | ||
naming_conventions.1605958974.txt.gz · Last modified: 2020/11/21 11:42 by sahl