We don't need them after class declaration or method signature.
- Bad example:
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}
- Improved example:
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}
Use english only and make them informative:
message should indicate what type of Machine
is working right now Truck
, Bulldozer
or Excavator
.
- Bad example:
Cat fluffy = new Cat();
Dog oscar = new Dog();
This example is bad cause it won't allow us to use polymorphism in our code. Our reference is now bonded to specific implementation, but it is always better to depend on the abstraction. Let's see how we can improve it:
- Improved example:
Animal fluffy = new Cat();
Animal oscar = new Dog();
Remember that if you don't use any access modifiers that will apply the default one. Do we always want to have all elements with default access modifiers? Remind yourself about encapsulation principle and when private or public should be used.
Bad example of commit/PR message: done
/fixed
/commit
/solution
/added homework
/my solution
and other one-word, abstract or random messages.