-
Notifications
You must be signed in to change notification settings - Fork 0
Coding Guideline
Ensure build is successful before creating pull request and try to run the app. Attach build success message to the PR description. Example can be seen here.
-
function-appContains main Spring Boot application class.
If a new dependency is added and requires global configuration using annotations, place the annotation in the Spring Boot application class in this module.
Another file(s) this module contains is/are
application.propertiesfile.If we need to add spring boot configuration properties or custom properties of our own, add the properties here. For custom properties, note that another class must be created in module
function-common, packagepropertiesfor accessing the custom properties. -
function-commonContains common classes to be reused in many modules, such as:
-
data interface for
function-validationandfunction-web-modelmodules, -
enumerations for
function-model,function-service-impl, andfunction-webmodules, -
exceptions thrown from
function-service-implandfunction-validationmodules, -
properties files used to access properties from
application.propertieslocated infunction-appmodule.
For enumerations and data interface, it is important to perform unit testing as they are covered in analysis scan.
-
data interface for
-
function-data-migrationUsed for seeding and changing the format of existing data in database. We use Mongobee in this project for data migration.
Configuration class should work just fine, so if something's not working, it is possibly the migration (change log) that is problematic.
To add more data or to perform migration, set it up in class
FunctionChangeLogby adding another method specifying the migration specification/purpose in brief. Above the method, add annotation@ChangeSet(author=<your_name>, id=<migration_name_or_id>, order=<order_of_execution>). See@ChangeSetdocumentation for detail.Note that this module can be separated from current project should the need arise.
-
function-modelContains entity representations and related classes for the entities (models). Each entity is placed in separate package according to each team name.
For other classes related to models can be placed in package
util, and be separated per package for each utility again. -
function-repositoryContains repositories for accessing data in database, placed in separate package according to each team name.
For each interface, put
@Repositoryannotation on top of the class.For every custom method that is written, create unit test for them as well.
-
function-service-apiContains interfaces for service methods and classes. For naming conventions can be seen in this section.
-
function-service-implContains implementation of logic for each feature and helper classes for recurring/general codes.
Annotate each service class with
@Serviceannotation, and implement the class' service API (interface) fromfunction-service-api.For certain codes which seems to be too general, separate to package
helper. For codes that are hard to test inside the service classes, separate to packagehelperas well.For each helper class, annotate
@NoArgsConstructor(access = AccessLevel.PRIVATE)and set the classfinalso the class could not be extended. Also, for each method, use static method. -
function-validationContains all validation-related classes, from annotations to validators. Format for each annotation or validator can be seen in existing examples.
For annotation that has target of
ElementType.TYPE, use data interface as second parameter ofConstraintValidatorinterface implemented by custom validator. Also, for the same subject, set field on the annotation class (example can be seen atOnlyStudentCanHaveBatchAndUniversityannotation). This is to ensure that if the validator returns invalid flag, there is a source of error that can be used in errors map returned to exception controller.Each validator class must be tested.
-
function-webContains configurations, controllers, and mappers for each feature. Separate each classes by team's name per package.
For codes with general purposes, put them in package
helperwith new class, or update existing class if necessary.Each class in this module, except configuration, must be tested.
-
function-web-modelContains web representations (web models) for web request or response. Annotations from hibernate or javax validation modules, and from
function-validationmodule will be used in request representation classes. Specify messages for each validation. Each representation is placed in separate package according to each team name.For other classes related to web models can be placed in package
util, and be separated per package for each utility again.
IMPORTANT NOTE: Use style from docs/Style/FUNCTION-STYLE.xml in IntellIJ IDEA for equal code style. Please do apply it as default style when coding in function-backend project.
-
Test Method
- Each test method must be named as follows:
testGiven<Condition1AndCondition2>By<MethodFunctionalityNotItsName>Return<ExpectedObjectOrException>. - Special Cases
- Controller
- Condition must be
ApiCall, then extended with other conditions.
- Condition must be
- Mapper
- Request
- After
By, add nameParsingTo<ClassName>Class.
- After
- Response
- After
By, add nameMappingTo<ClassName>Class.
- After
- Request
- Controller
- Each test method must be named as follows: