Over time, I came to understand the mentality of many small functions, and I really like it, but I find it difficult to lose my shyness to apply it to classes, especially with more than a handful of non-public member variables.
Each additional helper function clutters the interface, as often the code is class specific, and I cannot just use some kind of common code. (To my limited knowledge, in any case, Iβm still a beginner, I donβt know a single library there, etc.)
Therefore, in extreme cases, I usually create a helper class that becomes a friend of the class that needs to be worked on, so it has access to all non-public guts.
An alternative is free functions that need parameters, but even if premature optimization is evil, and I really havenβt profiled or parsed it ... I still DREAD a simple thought to convey all the things that I need sometimes, even as links, although this should be a simple address per argument.
Is this all a matter of preference or is there a widely used way to deal with such things?
I know that trying to force things into templates is a kind of anti-template, but I am worried about code exchanges and standards, and I want to get the material, at least, rather painful for other people to read.
So how do you guys handle this?
Edit: Some examples that prompted me to ask this question:
About free features: DeadMG is confused in the fact that the work of free features ... without arguments.
My problem with these functions is that, unlike member functions, free functions only know data if you give them to them, if global variables are not used, etc.
Sometimes, however, I have a huge complicated procedure that I want to disclose for ease of reading and understanding, but there are so many different variables that are used everywhere, passing all the data to free functions, which the agnostic for each bit of a member's data looks like a nightmare. Click for an example.
This is a snippet of a function that converts data to a format that my mesh class takes. For example, for refactoring, this will use all of these parameters for the finalizeMesh function. At the moment, this is part of the huge function of these computer cells, and bits of information about sizes and sizes and scaling information are used everywhere, intertwined.
What I mean by "free features, sometimes you need too many parameters."
I think this shows a bad style, and not necessarily a symptom of being irrational as such, I hope: P.
I will try to clarify the situation along this path, if necessary.