I'd like to ask you about one simple thing. I have class A that do something (for example counts something ). There is also one class B that handle some parameters to this class (class A is member of class B). Class B calls one method of class A that does something and writes value to database.
Class A uses parameters that got from Class B. Class A has few methods to made clean code (it's good I think). But... Is it ok to save parameters as private members?? It's not necessary. I don't have to remember them after writing to Database. But if I don't have private data I have to handle it to every private method as parameters (during processing). I think that it's ok to save this parameters as members of this class. Am I right? Or maybe I should avoid this when it's not necessary (when I don't have to remember them)?
When I don't have private members my publicMethod (called from class B) is looked something like that:
void publicMethod(int param1, int param2, int param3, int param4)
{
privateMethod1(param1, param2, param3, param4);
privateMethod2(param1, param2, param3, param4);
privateMethod3(param1, param2, param3, param4);
}
and in private methods I call other private method and I have to handle parameters.... I think it doesn't look good... Am I right? When I have private members it looks like:
void method(int param1, int param2, int param3, int param4)
{
privateMethod1();
privateMethod2();
privateMethod3();
}
It's better I guess. But I'm not professional and I'm not sure...
(I write in C++)