J-Framework Naming and Coding Convention
This document contains the Naming and Coding Convention (NCC) that is recommended be used in the development of J-Framework-based systems.
The coding conventions shall include the convention for:
-
Project names and artifacts.
-
Source code.
-
Rest API.
-
Database components.
-
Front-End.
-
Web Pages.
-
Filenames.
-
Shell scripts.
Project Name and Artifacts
Project names and artifacts shall be:
-
All small-with dashes.
-
Prefix with
{system-name}-{component-layer}-.
Examples:
-
appstudio-frontend-accounts -
codegen-backend-admin -
appgen-microservice-customers
Source Code
Since Java will be used as the primary programming language for J-Framework-based projects, the Java coding and naming convention shall be used. Full documentation of the Java coding convention can be found at: https://www.oracle.com/java/technologies/javase/codeconventions-contents.html.
Main points to consider when writing Java code:
-
Package:
-
name is all small without underscore or dashes.
-
For any class, the package should be:
-
com.{company-name}.{system-name}.{component-layer}.{package-name}
-
Class:
-
The class name should be a noun.
-
Should be a camel case with the first letter is capital.
-
No underscores should be included.
-
-
Variables:
-
Should be a noun.
-
Camel case with small for the first letter.
-
No underscores should be included.
-
-
Methods:
-
Should be verb.
-
Camel case with small for the first letter.
-
No underscores or dashes.
-
-
Constants:
-
All the constants should be declared in
com.{company-name}.{system-name}.{component-layer}.{packagename}.Constantsclass. -
All should be all capital with underscores.
-
Common constants should be declared in
com.{company-name}.{system-name}.commons.Constantsclass in the{system-name}-commonsproject.
-
Rest API’s and Microservices
All the microservices should be declared and named as follows:
-
Should be put in a project with the name
{system-name}-microservices-{service-name} -
The package should be
com.{company-name}.{system-name}.services.{servicename} -
The Rest service class should be in the
controllerspackage, where the full package name should be com.{company-name}.{system-name}.services.{servicename}.controllers -
The rest service should be called
{ServiceName}Controller. -
The service should follow the Mature Rest Services convention where HTTP methods will be the logical indication for the method’s actual functionality. Check out the Richardson maturity model at https://restfulapi.net/richardson-maturity-model/#:~:text=This%20model%20of%20division%20of,mature%20it%20shall%20be%20considered.
Database components
Oracle
For Oracle databases, the NCC should be declared as follows:
-
All database objects names should be capitalized with underscores.
-
Table names:
-
Should be plural.
-
Prefixed with the module name.
-
Should always have an AUTO_INCREMENT primary key named
ID. -
Examples: (CODEGEN_CUSTOMERS, SEC_AUDITS, OPS_MONITOR).
-
-
Table fields: Should be singular
(CUSTOMER_NUMBER). -
Views: Should be prefixed with
VI_{MODULE_NAME}. -
Sequences: Should be prefixed with
SEQ_{MODULE_NAME}.
Front-end
Projects shall follow the Single-Page design approach as much as possible, where each page will be deployed as an individual application.
So, in each application, all web front-end applications should be named:
-
Small with dashes.
-
The project name should be
{system-name}-frontend-{app-name}. -
The project should be the Maven
warproject. -
The package name should be
com.{company-name}.{system-name}.web. -
The controllers (JSF-managed beans) shall be located in
com.{company-name}.{system-name}.web.controllers. -
All the JSF controllers bean should be named
{ClassName}Controller. -
The core business page shall be named
index.xhtmland shall be located at the root of the web foldersrc/main/web. -
The default template should be located at
src/main/web/WEB-INF/templates/default.xhtml. -
The error template should be located at
src/main/web/WEB-INF/templates/error.xhtml. -
There should be custom error pages located at
src/main/web/errors.