I am quite confused on the following terms...are all the following terms all the same way to pretty much say "nonmember function" ( function that works with a class that isnt apart of its public interface )


auxillary function

helper function

free function

utility function

I think that a good old dictionary can give you a pretty good start: "auxiliary" and "helper" are synonyms in English. And, as far as I know, they are synonymous in programming terminology as well. "Utility functions" are similar in some sense but slightly different.

A "nonmember" function is obviously in opposition to a member function. A member function belongs to a class, i.e., tied to the class. By opposition, a nonmember function is not tied to a class, i.e., it is "free". So, "nonmember function" is a synonym of "free function". The only reason one might use the "nonmember" term is to emphasize the contrast to a member function, e.g., you might hear things like "this kind of operator should be a nonmember function" (to emphasize a case where it is better to define the function outside the class, when both are possible).

So, we are down to two main concepts: "free functions" and "helper functions". Are they the same? No. A helper function, as its name implies, is there to help, which means that it does not do something useful by itself, but rather helps another function to do something. Very often, especially with more complex algorithms, there are sub-problems that the algorithm solves many times in a loop and that sub-problem is not really useful to the user, but it is useful to a few other variants of the same algorithm. Then, that sub-problem can be put in a "helper function" to be used by several variants of an algorithm. But, to the user, this function is meaningless, the user only cares about calling one of the different variants of the algorithm. Note here, that the helper function can be either a free function OR a member function, either to help free function or a member function, it all depends on the case and all combinations are possible. So, the two concepts are really independent.

Finally, a "utility function" usually refers to a kind of "helper function" which solves a very common, recurring sub-problem (like sorting an array, or separating tokens in a string). You could probably say that all the standard C/C++ functions are utility functions. Note that, again it can be either free or a member function. Also, some people might use "utility" and "helper" or "auxiliary" to mean the same thing, because they are fairly similar, except that "utility" usually denotes a function that is more broadly useful (which is what "utility" literally means).

So, I guess, at the end, it all just boils down to plain non-technical English definitions of the words, which makes sense after all.

Utility: The quality or condition of being useful; usefulness; A commodity or service;
Helper: One that helps; an assistant.
Auxiliary: Giving assistance or support; helping.
Member: A distinct part of a whole; One that belongs to a group;
Non-member: Not a member.
Free: Not bound, fastened, or attached; Not subject to external restraint.

in other words

Helper/auxillary function - usually called inside another function to assist an sub problem!

utility function - a commodity to have such as haveing a function which returns the length of an object...like int getStringLength(std::string)...this function can be used by itself

yep that's the gist of it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.