This is a very basic question that doesn't seem to be asked or answered anywhere.
Sometimes we define a method and name the parameter as "factory". Example: https://github.com/AirtestProject/Airtest/blob/c29d0462fe29db5c04cda31de1c05bcae5991061/airtest/report/js/lazyload.js
(function (root, factory) {
if (typeof exports === "object") {
module.exports = factory(root);
} else if (typeof define === "function" && define.amd) {
define([], factory(root));
} else {
root.LazyLoad = factory(root);
}
Sometimes we name the class as SomeFactory. Example: https://github.com/SeleniumHQ/selenium/blob/d4dba1c07a1d8601f80b9e71be7853317ab0d49d/java/src/org/openqa/selenium/remote/server/ActiveSessionFactory.java
public class ActiveSessionFactory implements SessionFactory {
Sometimes methods are named as someFactoryMethod. Example: https://github.com/SeleniumHQ/selenium/blob/d4dba1c07a1d8601f80b9e71be7853317ab0d49d/java/src/org/openqa/selenium/remote/server/ActiveSessionFactory.java
public synchronized ActiveSessionFactory bind(
Predicate<Capabilities> onThis,
SessionFactory useThis) {
Require.nonNull("Predicate", onThis);
Require.nonNull("SessionFactory", useThis);
Sometimes variables are also named as varFactory
private List<SessionFactory> factories;
What is the expectation around the word "factory" in these contexts? When should I name something as "factory"? Isn't every class essentially a blueprint or a "factory" in some way?
Not sure if this last question can be answered but are there other similar common names that classes/methods are usually named besides "factory"?