vendredi 6 février 2015

"Use map instead of class to represent data" -Rich Hickey


In this video by Rich Hickey, the Clojure creator, he advises to use map to represent data instead of using a class to represent it, as done in Java. I don't understand how it can be better, since how can the API user know what are the input keys if they are simply represented as maps.


Example :



PersonAPI{

Person addPerson(Person obj); <br>
Map<String,Object> addPerson(Map<String,Object> personMap);

}


In the second function how can the api user know what are the input's to create a person ?





Aucun commentaire:

Enregistrer un commentaire