Skip to content

Instantly share code, notes, and snippets.

View joseluissanchezgracia's full-sized avatar

José Luis Sánchez Gracia joseluissanchezgracia

View GitHub Profile

Keybase proof

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:

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;
@joseluissanchezgracia
joseluissanchezgracia / 0_reuse_code.js
Created February 17, 2016 01:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console