Professional Documents
Culture Documents
Metis Coding Convention: Layers Package Coding Style Unit Test Review Best Practice Can Apply Immediately
Metis Coding Convention: Layers Package Coding Style Unit Test Review Best Practice Can Apply Immediately
Layers
Package
Coding style
Unit test
Review
Best practice can apply immediately
Layers
Routing
- Routing to Service: syntax [Name]Post
Ex: AddWorkerPost Bean Bean
Mapper Mapper
Service
Pojo
Pojo
DAO
Package
- metis.[Domain].routing
Define routing and uri
- metis.[Domain].service
Service interface
- metis.[Domain].service.impl
Service implement
- metis.[Domain].dao
Dao
- metis.[Domain].data.bean
Request bean and Response bean
- metis.[Domain].data.pojo
Pojo object
- metis.[Domain].data.mapper
Mapper class
- metis.[Domain].util
Messaging
Coding style
Must
- Use google style
- Increase wrapping characters to 140
- Nested loop: no more than two level
- No commit when test case fail
- Log the query always
- Use BigDecimals - No float or double
- Backend returns always timestamp as long to the UI
- Use stream
- The commit has to include comment
- Use builder pattern to data object
Should
- always put new codes below old codes
- avoid format old codes
- Run SonarLint on your machine and clean the dirty code.
- Null safety
- Use wrapper such as CollectionUtils.isEmpty()
Unit test
Apply pattern: setup, tearUp, tearDown
@BeforeAll
void tearUp() {
// create data
}
@AfterAll
void tearDown() {
// clear data
}
Review
Managing a branch protection rule:
private Woker() {
}