I'm new to node, but I come from an extensive background in programming. Everywhere I looked (both in tutorials and in production code I've seen around), people overwhelmingly use hard coded strings instead of constants to identify events.
I picked one random example out of npm's most depended upon packages list to illustrate what I mean: the «request» library — why do they emit and consume the «data» event by typing the string 'data' every time, instead of defining a library-wide constant?
Using constants would be considered good practice in any programming language I'm aware of, and yet node developers seem perfectly content with the hard-coded approach. Why?
Aucun commentaire:
Enregistrer un commentaire