# Coding standards

# Naming standards

### <span class="mw-headline" id="bkmrk-url-related-naming-1">URL related naming</span>

- Allways use lowercase for application naming

### <span class="mw-headline" id="bkmrk-code-naming-standard-1">Code naming standards</span>

#### <span id="bkmrk-"></span><span class="mw-headline" id="bkmrk-package-%2F-naming-pla-1">Package / naming placement</span>

- 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.&lt;group&gt;**
    - Views: **com.tsnocode.ui.views.&lt;type&gt; (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**

#### <span class="mw-headline" id="bkmrk-class-naming-1">Class naming</span>

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"

### <span class="mw-headline" id="bkmrk-database-naming-stan-1">Database naming standards</span>

#### <span class="mw-headline" id="bkmrk-table-naming-1">Table naming</span>

System tables should follow this syntax

- lowercase
- no special characters

Reserved prefixes include

- data\_
- \_data\_ (deleted tables)

#### <span class="mw-headline" id="bkmrk-table-attribute-nami-1">Table attribute naming</span>

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

# Solution staging

1. Transfer solution 
    - Source: Make backup, view XML, copy
    - Target: Add repository item, create this item
2. Transfer templates 
    - Source: Check solution setting for Template (if not Default)
    - Source: Download template file / Copy template content
    - Target: Add new template and upload template file / paste content
    - Target: Update solution setting for Template (if not Default)
3. Transfer stylesheet 
    - Source: Check solution setting for Stylesheet (if not Default)
    - Source: Copy stylesheet content via stylesheet page (recursive)
    - Target: Add new stylesheet and paste content
    - Target: Update solution setting for Stylesheet (if not Default)
4. Transfer media files 
    - Source: Check files referred in stylesheet
    - Source: Check files referred in links
    - Source: Download files
    - Target: Create media file and upload files
    - Target: Update file references (TEMPORARY)
5. Transfer wrapper 
    - Source: Check interface setting for Wrapper (if not Default)
    - Source: Copy wrapper content
    - Target: Add new wrapper and paste content
    - Target: Update interface setting for Wrapper (if not Default)

# Test cases

### <span class="mw-headline" id="bkmrk-test-cases-fields-1">Test cases Fields</span>

- Commands: list, show, edit (update)
- List interactions: Sort, Grouping