I'm designing a class for a project I'm working on.
A member function is too big and I want to break it down into smaller functions.
I've looked into lambda functions, private functions and free functions. None of which really satisfy me enough. Lambda functions make the line too long (ex. auto check_vertical = [&](char **grid, size_t i, size_t j, size_t amount) -> bool {
), private functions are visible to other functions within the class and free functions are visible to any files which include the file.
class Foo {
private:
Goo goo;
public:
Foo(size_t size);
~Foo();
size_t get_xyz(size_t size) const;
};
size_t Foo::get_xyz(size_t size) const {
// A lot of code.
}
I currently have this setup.
class Foo {
private:
Goo goo;
public:
Foo(size_t size);
~Foo();
size_t get_xyz(size_t size) const;
};
size_t Foo::get_xyz(size_t size) const {
auto check_something = [&](char **grid, size_t i, size_t j, size_t amount) -> bool {
....
};
// More lambda functions..
}
I want to break down get_xyz
function into smaller functions.
Where should I place the new functions? What's the best design principle?
Aucun commentaire:
Enregistrer un commentaire