Difference between revisions of "Coding standards"
Jump to navigation
Jump to search
(20 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
=== | == Naming standards == | ||
Package / naming placement | |||
=== Code naming standards === | |||
==== Package / naming placement ==== | |||
* Package name all lowercase | * Package name all lowercase | ||
* General platform entities | * General platform entities | ||
** Servlets | ** Servlets: '''com.tsnocode.server.servlet''' | ||
** Fields | **Filters: '''com.tsnocode.server.filter''' | ||
** Views | **Core: '''com.tsnocode.ui''' | ||
** Fields: '''com.tsnocode.ui.field.<group>''' | |||
** Views: '''com.tsnocode.ui.views.<type> (item,list,statistics,)''' | |||
**Codeunit: '''com.tsnocode.codeunit.common''' | |||
* Solution specific code | * Solution specific code | ||
** TS customer app: | |||
*** '''com.tsnocode.solution.app''' | |||
*** '''com.tsnocode.solution.customer''' | |||
*** '''com.tsnocode.solution.customer.app''' | |||
** Vendor app: | |||
*** '''com.vendor.tsnocode.app''' | |||
*** '''com.vendor.solution.app''' | |||
Class naming | ==== Class naming ==== | ||
Naming convention follows Java standard | |||
* Starting with uppercase | * Starting with uppercase | ||
* No special characters | * No special characters | ||
* Seperate words with uppercase | * Seperate words with uppercase | ||
=== Safety standards | In addition the following are recommended | ||
* CodeunitPage post fix name "Page" | |||
* CodeunitService post fix name "Service" | |||
* Shared ressources include "Helper" | |||
=== Database naming standards === | |||
==== Table naming ==== | |||
System tables should follow this syntax | |||
* lowercase | |||
* no special characters | |||
Reserved prefixes include | |||
* data_ | |||
* _data_ (deleted tables) | |||
==== Table attribute naming ==== | |||
General rules | |||
* Starts uppercase | |||
* Next word in name starts with uppercase (eg ThisIsAnExample) | |||
* Foreign keys ends with ID (eg UserID) | |||
Changelog attributes fixed names | |||
* CreatedAt | |||
* CreatedBy | |||
* ModifiedAt | |||
* ModifiedBy | |||
* FinalizedAt | |||
* FinalizedBy | |||
== Compliance standards == | |||
The platform must be able to run on | |||
* Current versions of Java | |||
* Current versions of Tomcat | |||
* MySQL and MariaDB | |||
** Do not use current_timestamp (property) | |||
== Safety standards == | |||
* Input sanitization used in SQL, using either | * Input sanitization used in SQL, using either | ||
** Escape all string parameters using DbConnection.EscapeSQL | ** Escape all string parameters using DbConnection.EscapeSQL | ||
** Prepared statements | ** Prepared statements | ||
* Page codeunits should contain user group restrictions | * All Page codeunits should contain some user group restrictions, and set to be default off | ||
== Review standards == | |||
The following changes requires a formal code review | The following changes requires a formal code review | ||
* Changes to the API | |||
* Changes to common objects | * Changes to common objects | ||
** Command | ** Command | ||
Line 27: | Line 80: | ||
** DbConnection | ** DbConnection | ||
* Creation of OR changes to | * Creation of OR changes to | ||
* Servlets | ** Servlets | ||
* CodeunitPagePublic | ** Servlet Filters | ||
** CodeunitPagePublic | |||
** Code containing SQL | |||
* Any code that | |||
** Deletes DB columns OR tables |
Latest revision as of 13:34, 2 October 2024
Naming standards
Code naming standards
Package / naming placement
- Package name all lowercase
- General platform entities
- Servlets: com.tsnocode.server.servlet
- Filters: com.tsnocode.server.filter
- Core: com.tsnocode.ui
- Fields: com.tsnocode.ui.field.<group>
- Views: com.tsnocode.ui.views.<type> (item,list,statistics,)
- Codeunit: com.tsnocode.codeunit.common
- Solution specific code
- TS customer app:
- com.tsnocode.solution.app
- com.tsnocode.solution.customer
- com.tsnocode.solution.customer.app
- Vendor app:
- com.vendor.tsnocode.app
- com.vendor.solution.app
- TS customer app:
Class naming
Naming convention follows Java standard
- Starting with uppercase
- No special characters
- Seperate words with uppercase
In addition the following are recommended
- CodeunitPage post fix name "Page"
- CodeunitService post fix name "Service"
- Shared ressources include "Helper"
Database naming standards
Table naming
System tables should follow this syntax
- lowercase
- no special characters
Reserved prefixes include
- data_
- _data_ (deleted tables)
Table attribute naming
General rules
- Starts uppercase
- Next word in name starts with uppercase (eg ThisIsAnExample)
- Foreign keys ends with ID (eg UserID)
Changelog attributes fixed names
- CreatedAt
- CreatedBy
- ModifiedAt
- ModifiedBy
- FinalizedAt
- FinalizedBy
Compliance standards
The platform must be able to run on
- Current versions of Java
- Current versions of Tomcat
- MySQL and MariaDB
- Do not use current_timestamp (property)
Safety standards
- Input sanitization used in SQL, using either
- Escape all string parameters using DbConnection.EscapeSQL
- Prepared statements
- All Page codeunits should contain some user group restrictions, and set to be default off
Review standards
The following changes requires a formal code review
- Changes to the API
- Changes to common objects
- Command
- Security
- Controller
- DbConnection
- Creation of OR changes to
- Servlets
- Servlet Filters
- CodeunitPagePublic
- Code containing SQL
- Any code that
- Deletes DB columns OR tables