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 messages informative
- The message should indicate what type of
Machine
is working right nowTruck
,Bulldozer
orExcavator
.
- 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 a 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 the encapsulation principle and when private or public should be used.
Bad examples of commit/PR messages: done
/fixed
/commit
/solution
/added homework
/my solution
and other one-word, abstract or random messages.