Is it worth reducing the class of 540 bytes to smaller pieces? (C ++)

So, I have been developing a UI toolkit over the past year, and my Window class has come to the point where the class size (via sizeof) is 540 bytes).

I thought that since not all windows have children, I can separate the parts of the code that processes the children (its alignment, etc.) into a separate class and have a pointer to it. The same goes for texts, icons and scrolling, etc.

Is this a recommended practice or is there something that I am clearly hiding?

+3
source share
5 answers

-, . , 540 , .

540 - . 135 . - 22 std::vector s. , . , . , , .

, , , , ( ..) . , ..

, EverythingUI. , . . ... .

+2

- , . , .

540 ? ? .

+2

. , , , , .

, , - ( ) , new. , , , , , , .

+2
0

I may not understand your problem, but you can look at political design and / or component design , both of which are related to making larger classes out of less functionality.

From what you said about disabling some features and pointing to it, it looks like component-based design is the direction you were thinking about.

0
source

Source: https://habr.com/ru/post/1734729/


All Articles