1

What generic name is given to classes that encapsulate a collection of esoteric functions which together perform some larger cohesive but entirely self-contained task useful to the wider application, by producing a computed result given a number of input parameters?

An example might be a class that calculates the shortest path/most efficient route when visiting nodes on a Euclidean plane, given a set of obstacle polygons. Inside this class there might be various generic functions for calculating the distance between two points, whether or not two lines intersect, and whether the intersection is concave or convex relative to a given co-ordinate.

Describe exactly the context that the name or terminology is used: This term will be used when naming classes. In the example class I mentioned above, the term would replace "Foo" in the class name MyCompany_Foo_ShortestPath.

Describe the criteria for acceptance: The term must suitably differentiate it from other common class types, such as caches (e.g. MyCompany_Cache_Prices), adapters (e.g. MyCompany_SQLDatabase_Adapter_MariaDB), data providers (e.g. MyCompany_DataProvider_Products), controllers (e.g. MyCompany_Controller_Users) and models (e.g. MyCompany_Model_Employee), while also going some way to explaining the nature of the class (encapsulated, complex functionality).

Which names/terms have you thought of and discarded as inappropriate? Some ideas I've had have been "functional" classes (in that they act like functions, but have been broken down into smaller functions), and "computational" (in that they compute things). I would guess though that there is already an accepted term for this type of class.

Alex
  • 169

1 Answers1

-2

The most proper term I've seen for that type of structure is Method Object.

That being said, I typically use the word "Calculator" in the naming of Method Object classes in my code. "Calculator" indicates that the class would perform a calculation or run an algorithm based on inputs and could potentially live on to be used repeatedly. The term also differentiates it from other classes which contain/transport data or interface with other components. You've even used the same term in your own example: "...a class that calculates the shortest path..."

cajunc2
  • 120