Skip to content

Style Guide

tyrothalos edited this page Aug 18, 2016 · 1 revision

Official Civcraft Java Style Guide

Table of Contents

  1. Introduction
  2. Project Structure
  3. Classes
  4. Formatting

Introduction

This document serves as a basic style guide for Civcraft. Anything not covered in this guide may be left to the author’s decision.

Project Structure

File encoding

All files in all projects should be encoded in UTF-8.

Source folders

The source files in a Civcraft project should be put into the following directories:

  1. Source files in src/main/java/
  2. Resource files in src/main/resources/
  3. Test source files in src/test/java/
  4. Test resource files src/test/resources/

Classes

Fields

All class fields should never be public with the exception of constants (immutable static final fields).

Organization

Class contents should be organized as follows:

  1. Fields
  2. Methods
  3. Getter and setter methods (this need not apply if Lombok is used)
  4. Inner classes (if there are any)

Formatting

Indentation

Tabs should be used for indentation while spaces should be used for alignment.

Consider using .editorconfig to help achieve this.

Line length

Lines must be no longer than 120 characters. Assume a tab width of 4 spaces.