Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 9

Metis coding convention


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:

- Required approving reviews is 2

- Require conversation resolution before merging

Link guide config github: https://docs.github.com/en/github/administering-a-


repository/defining-the-mergeability-of-pull-requests/managing-a-branch-protection-rule
Best practice can apply immediately
Message: Resource bundle
- Multi-language
- Easy change
Best practice can apply immediately
Log sql when execute jooq query
Dont need add code log query for each jooq query
Best practice can apply immediately
Should add inner class to separate each kind of constant

public class Constant {


public class Woker {

private Woker() {
}

public static final String WORKERS_HELLO = "wokers_hello";


}
}

You might also like