Folha de Estilo - EduardoMoreira/Desenho-UnB-2016-01 GitHub Wiki
Versão 0.1
Histórico da Revisão
Data | Versão | Descrição | Autor |
---|---|---|---|
03/04/2016 | 0.1 | Criação do documento | Matheus Silva |
1) Names
-
Every variable must have their names in english;
-
Every branch, commit and issue must be written in english;
-
The variable names must be written on “mixedCase” rule, with significant names:
float thisIsAVariable;
-
The function names must be written on “mixedCase” rule, with significant names:
void methodOne;
-
The class names must follow the CamelCase rule:
class MyClass;
-
The constant names must be written with capital letters, separating the words with ‘_’:
const int NUMBER_PEOPLE;
2) Strings:
-
It must be used double quotation mark ("") instead of single quotation mark ('') in all possible cases:
askClientName = "Escreva o nome do cliente: ";
3) Parenthesis:
- It must be used on the following cases:
-
Conditionals:
if (valueTotal == valueMonth && valueMonth == valueDay)
-
Functions:
void rankingEnade(int value)
-
4) Braces:
-
It must open the keys on the below line:
1. Conditionals:
if (valueTotal == valueMonth and valueMonth == valueDay) { // Do Something }
2. In Functions:
float calculatesProfit(int days) { // Do Something Else }
3. In Classes:
class SchoolEnade { // To Do }
5) Spacing:
-
It must be put a blank (' ') on the following cases:
1. Conditionals (after if and between the variables):
if (schoolBase > schoolCompare)
2. Functions (between the parameters):
cleanFields(allFields, personEnterprise)
3. When you use the character ‘&’ to indicate parameter passing by reference, it must be put ‘&’ along with the variable name:
void schoolDepartmentRanking(int &referenceVariable)
4. Comment:
1. One line comment: // This method is responsible to calculate ENADE's grades 2. More than one line comment: /* This method is responsible to show ENADE's grades * with University's Name, University's City and * University's State */
5. Math Operations:
1. (valueMonth * amountMonth) / (quantityEmployees) 2. (“The month value is” + valueMonth);
-
It must not exist a blank character after parenthesis or double quotation mark:
strWarning = (“Type Again:”);
6) Line break
-
There should not be an extra line break between a function declaration and the begining of the code:
if(quantityProduct == quantityStorage) { // ToDo }
-
There should be an extra line break between programming blocks:
for(estado = 0; estado < numeroEstadosPais; estado = estado + 1) { // ToDo } for(escola = 0; escola < numeroEscolaEstado; escola = escola + 1) { // ToDo }
-
There should be a line break between the parameters of the builders:
public Client(String name, String cpf, String telephone, String age, Address address) { // Constructor }
-
There should be a line break after the header of a class
/********************************************************** * File: GestaoEmpresa.java * Purpose: Main menu of the program. **********************************************************/ public class GestaoEmpresa { // Class declaration }
7) Comments:
-
Every function must have an explanatory comment block in english starting with ‘/’ and ending with ‘/’:
/* This function calculates the profit * of the month in the sales department */
-
Every block has an explanatory comment
// This sum calculates the amount of money spent on a given time period
8) Header:
-
Every file must have a header containing one line with the name of the file and another with the purpose of the file:
/************************************************ * File: JuridicalClient.java * Purpose: JuridicalClient class implementation. *************************************************/