I have seen numerous projects have a file named commons
for example:
commomns.go
I was wondering, why was this convention adopted and what did the meaning of naming a file or a package or something as commons?
1
commonly used
While writing code, one often finds themselves with a common set of tools/classes/libraries that are used again and again across multiple projects.
The other classic name for this is ‘util’, but ‘util’ classes are sometimes seen as an anti-pattern. Even though thats what these are, such a name can sometimes set off a developer’s anti pattern senses and just avoid them for good measure.
the commons
Some projects have a ‘commons’ associated with them. For example, Wikimedia Commons is stuff to be shared and used. The commons also refers to a particular set of resources:
Commons refers to the cultural and natural resources accessible to all members of a society, including natural materials such as air, water, and a habitable earth. These resources are held in common, not owned privately. The resources held in common can include everything from natural resources and common land to software. The commons contains public property and private property, over which people have certain traditional rights. When commonly held property is transformed into private property this process alternatively is termed “enclosure” or more commonly, “privatization.”
From wikipedia: Commons
These are things to be shared. A cultural public good that has been gifted to the community. There is a great deal more in the Wikipedia Commons page that can be put in this text area. To sum it up, there is a lot of connotations associated with the concepts of sharing and the commons that dates back centuries. See also the digital comons.
“commons” or “util” are normally used for shared code between different parts of a complex project. And off course are a very good example of bad naming and laziness and normally end up as a bag for crap.
What type of things you can find inside a common library in a project?, who knows!, surprise me!.