Skip to content

The coding conventions used by Informatica and Information Technology.

Notifications You must be signed in to change notification settings

NHL-Stenden-Emmen/coding-conventions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Coding Conventions

Meet the standards for Informatica and Information Technology

Naming

  • Use meaningful names Use descriptive names for all identifiers (names of classes, variables and methods. Avoid ambiguity. Avoid abbreviations. Simple mutator methods should be named setSomething(...). Simple accessor methods should be named getSomething(...). Accessor methods with Boolean return values are often called isSomething(...), for example isEmpty().

  • Class names start with a capital letter.

class Post
  • Class names are singular nouns.

  • Methods and variable names start with lowercase letters. All the – class, method and variable names – use capital letters in the middle to increase readability of compound identifiers, e.g. numberOfItems, also called lowerCamelCase.

  • Constants are written in UPPERCASE. Constants occasionally use underscores to indicate compound identifiers (SCREAMING_SNAKE_CASE): MAXIMUM_SIZE

  • Suffix exceptions with Exception.

class MyOwnException
  • When calling methods or fields from the current class, always prefix them with this..
this.firstName

this.doSomething()

(Unit) Testing

  • Tests should be placed in a seperate folder. The folder should be called test.

  • For methods of Unit Tests we use the following convention:

void methodThatIsBeingTested_howIsTested_expectedResult()

Layout

  • One level of indentation is four spaces.

  • All statements within a block are indented one level. 

  • The braces for class method and structural blocks are on separate lines and are at the same indentation level, for example:

public int getAge()
{
    statements
}

while (condition)
{
    statements
}


if (condition)
{
    statements
}
else
{
    statements
}
  • Always use curly brackets in control structures. Curly brackets are used in if-statements and loops even if the body is only a single statement.

  • Use a space around operators (=, +, -, *, %, /).

int sum = 5 + 6;
double multiple = 5 * 6;
  • Don’t use a space between the method name and the opening parenthesis of the parameters.

  • Use a space between the parameters of a method, so after each comma.

public void method(int param1, int param2)
  • Use a space between (operational) keywords like if, while, for and the opening parenthesis.
while (condition)
if (condition)
for (condition)
  • Don’t use a space for incrementing and decrementing operators, for example:
number++;
  • Use a blank line between methods (and constructors). Use blank lines to separate logical blocks of code. This means at least between methods, but also between logical parts within a method.
public int method()
{
    return 1;
}

public int anotherMethod()
{
    return 2;
}
  • Add a blank line before a return statement.
public void method()
{
    statements
    statements

    return;
}

Don't add a blank line if there is only one line within a code block (for example an if-block).

if (condition) 
{
    return;
}
  • Fields should be declared in the top of the class, before constructor(s) and methods.
class MyClass
{
    Fields

    Constructor

    Getters and setters

    Methods
}
  • Getters and setters should be bundled. So, for example, if we have two fields name and number we would have:
public String getName()
{
}

public void setName(String name)
{
}

public int getNumber()
{
}

public void setNumber(int number)
{
}
  • Custom methods should be placed below getters and setters.

  • Enum constants should be on its own line.

public enum Currency
{
    EURO,
    DOLLAR
}

Project structure (Java)

  • Put classes that belong to eachother in a package.

  • The root of your project should contain a package according to the following naming conventions:

com.nhlstenden.projectname

HTML & CSS

  • Don't use whitelines in your HTML.

  • Every nested tag should be indented.

  • Tags should be in lowercase.

<button></button>
  • Don't use spaces around = signs.
<img src="image.png" alt="A black and white cat" />
  • Use lowercase for your filenames.
index.html
about-us.html
style.css
  • Don't place a space after opening a tag paragraph tag.
<p>I don't need a space</p>

About

The coding conventions used by Informatica and Information Technology.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published