I hereby claim:
- I am joseluissanchezgracia on github.
- I am sanchjoe (https://keybase.io/sanchjoe) on keybase.
- I have a public key ASBqtWH91KO4FZLfHB3h1mW11m7Sbul2RhJRWR-Ig9flXAo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
Traits both provide a set of methods that implement behaviour to a class and require that the class implement a set of methods that parameterize the provided behaviour. A trait is kind of a “micro interface” that describes some characteristic of a class design that can be found in many different components throughout the system. By referring to the traits instead of the implementing class itself you can keep the system decoupled and modular. | |
public interface HasComments<R extends HasComments<R>> { | |
// one method that parameterize the provided behaviour | |
List<Comment> getComments(); | |
// two methods that implement the behaviour | |
default R add(Comment comment) { | |
getComments().add(comment); | |
return (R) this; |
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |