naming_conventions
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
naming_conventions [2019/09/14 08:48] – 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| | + | |
- | ===== HTML ===== | + | Objects are named in lowercase and with _ between words, so: |
- | ==== Elements ==== | + | $user_property |
- | + | ||
- | ^Element^Form^Example^ | + | |
- | |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]-form|user-menu| | + | |
- | |Table|[object name]-table|user-table| | + | |
- | + | ||
- | + | ||
- | ===== Javascript ===== | + | |
==== Functions ==== | ==== Functions ==== | ||
- | Functions | + | Functions |
- | ===== PHP ===== | + | ^add...|Add further information to an object, meaning that nothing is replaced but something is added.| |
+ | ^attach...|Attach something to the object.| | ||
+ | ^build...|Build something inside the object relying on information already present| | ||
+ | ^calculate...|Make some kind of calculation. Typically something that's complex or can take some amount of time.| | ||
+ | ^can...|Check if the object is able to do something or if the user is allowed to do something with the object| | ||
+ | ^copy...|Copy some information or the entire object.| | ||
+ | ^check...|Check if something external to the object but relevant for the object have occured.| | ||
+ | ^decode...|Decode some information from something else. The opposite of encode.| | ||
+ | ^delete...|Delete something. Typically the object| | ||
+ | ^encode...|Encode some information into something else. The opposite of decode.| | ||
+ | ^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 from inside the object or one or more objects in a static context.| | ||
+ | ^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 else. The opposite of store.| | ||
+ | ^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 some information somewhere else (ie not in the object). The opposite of retrieve.| | ||
+ | ^validate...|Ensures that something is correct.| | ||
- | ==== Classes ==== | + | Functions are places alphabetically in files, except for // |
- | Classes are CamelCase and in singular form | + | ==== Variables ==== |
- | ==== Functions ==== | + | Variables are initialized |
- | + | ||
- | Functions should be dromedaryCase | + | |
- | + | ||
- | Class functions should be named according | + | |
- | + | ||
- | ^calculate|Calculates something within | + | |
- | ^can|Check if the object is able to do something| | + | |
- | ^get|Gets some information from the object| | + | |
- | ^is|Check if the object is in a given state.| | + | |
- | ^load|Retrieves object information from somewhere| | + | |
- | ^save|Stores object information somewhere| | + | |
- | ^set|Set some information | + | |
===== SQL ===== | ===== SQL ===== | ||
Line 56: | Line 57: | ||
Tables are named after their corresponding classes, but in plural form, such as //users// | Tables are named after their corresponding classes, but in plural form, such as //users// | ||
- | ^Keys|Keys are named [object name]id such as '' | + | ^Keys|Keys are named [object name]_id such as '' |
- | ^Foreign keys|Foreign references are named [foreign object name]ref such as '' | + | ^Foreign keys|Foreign references are named [foreign object name]_ref such as '' |
+ | |||
+ | In other cases the object name should never be part of the field names, so not // | ||
- | In other cases the object name should never be part of the field names, so not // | + | Field names are lowercase and words are split by underscore _ |
naming_conventions.1568450923.txt.gz · Last modified: 2019/09/14 08:48 by sahl