In my code the following pattern is recurrent:
class Assembler {/*...*/}; //does something, in this case assembles a matrix
class AssemblerParam {/*...*/}; //contains the parameters needed to create
//an object of the Assembler class
class AssemblerReader {/*...*/}; //reads a file and creates an
//object of AssemblerParam
I have realized this can be organized a lot better by nesting AssemblerParam and AssemblerReader inside Assembler (plus some advantages for generic programming)
class Assembler {
public:
class Param { /*...*/ };
class Reader{ /*...*/ };
private:
Param parameters;
};
However, now the implementation of the methods of Assembler is a lot less readable for things like this
void Assembler::method() {
parameters.mesh.method(parameters.member.method());
//the code now is cluttered with the word "parameters"
}
Instead I would like my code to read:
void Assembler::method() {
mesh.method(member.method()); //a lot more readable
}
Any solution?
Remark 1 Using inheritance like this
class AssemblerParam{/*...*/};
class Assembler : public AssemblerParam { /*...*/ };
would help on readability, but would pollute my namespace with classes SomethingParam.