Koala encoding Specification

Source: Internet
Author: User
Tags coding standards

Koala coding specification 1 preface this document is a complete definition of the koala project programming style specification. The source files of the project module must comply with the rules set in this document.
Like other programming style guides, we will not only discuss the beauty of the encoding format, but also discuss some conventions and coding standards.

2 source file 2.1 file encoding: UTF-8
2.2 name: The name must start with an upper-case letter. The name can only be in English.
2.3 The file structure is shown in the following order:
Element requirements
1. License or copyright information
2. The package statement does not wrap a line.
3. The import statement cannot use wildcards.
4. A top-level class
Note: Each element is separated by a blank line.


2.4 conventions:
    • The code must be formatted.
    • No yellow prompt
    • Class and method must be annotated
    • The description at the class and method level must be completed, and parameters and responses are not required (see the following table)
    • Keep the code clean (do not keep the Code with comments, etc)
示例/** * 抽象实体类,可作为所有领域实体的基类。 * * @author yang * */@MappedSuperclasspublic abstract class BaseEntity implements Entity {/**     * 获取仓储对象实例。如果尚未拥有仓储实例则通过InstanceFactory向IoC容器获取一个。     * @return 仓储对象实例     */    public static EntityRepository getRepository() {        if (repository == null) {            repository = InstanceFactory.getInstance(EntityRepository.class);        }        return repository;    }}



3. The key elements of naming conventions are Brief and clear intentions To comply with the following table rules:

Element requirements example
    1. The project module can only use lower-case letters and hyphens (-) to separate the word koala-security-core from the hyphen (-).
    2. The package can only contain the lower-case letter org. openkoala. Security. Core. domain.
    3. The class can only contain uppercase and lowercase letters, and the big camper entityrepository. Java
    4. The field can only contain uppercase and lowercase letters and underscores. The small camper private string useraccount
    5. The method can only contain uppercase and lowercase letters, and the small camper type is findchildrenoforganization.
    6. The URL can only contain lower-case letters and hyphens (-). Employee/get-posts-by-employee.koala
    7. Javascript, CSS, and JSP can only contain English letters, numbers, and hyphens

The four modules define the 4.1 domain layer? Package name format: XXX. XXX. Core. domain, for example, org. openkoala. Security. Core. Domain
? The exception class is placed under XXX. XXX. Core and ends with xxxexception. It must be a subclass of runtimeexception.
? The JPA object table and column name must be in upper case. The names of the tables must be in the plural (for example, ko_accountabilities)
? JPA object content writing order, field-> constructor-> method (Dynamic-> static)-> business primary key-> attribute
? The query method uses Named query and criteriaquery to query objects, and uses criteriaquery for simple query.
? The JPA entity method must compile the corresponding unit test with a high coverage rate.

4.2 Application layer? Package name format: XXX. XXX. application, for example, org. openkoala. Security. Application
? The interface must be annotated in detail.
? The corresponding unit test must be compiled for interface methods, and the coverage rate is high.

4.3 facade layer? Include fa? Ade interface and DTO object
? Package name format: XXX. XXX. facade, for example, org. openkoala. Security. Facade
XXX. XXX. facade. DTO, for example, org. openkoala. Security. facade. DTO
? The command interface returns the invokeresult object, and the query interface returns the Page Object.
? The pom file cannot have any technical dependency

4.4 facade Implementation Layer? Include fa? Ade interface implementation and aggreger Assembler
? Package name format: XXX. XXX. facade. impl, for example, org. openkoala. Security. facade. impl
XXX. XXX. facade. impl. Cycler, for example, org. openkoala. Security. facade. impl. Cycler
? The aggreger class must contain the toentity and todto methods, and the method must have a non-null judgment on the parameter.


Koala encoding Specification

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.