What's better, Big classes or Small

M

ManicQin

Let's ignore for a minute design decisions , readability and any other
of those parameters , In the most raw form of c++ (purely efficiency
if you want)
what is better, bloating up a classes or breaking them up to small
classes?
(and again pure efficiency of the compiler)


Thanks
 
N

Nick Keighley

Let's ignore for a minute design decisions , readability and any other
of those parameters , In the most raw form of c++ (purely efficiency
if you want)
what is better, bloating up a classes or breaking them up to small
classes?
(and again pure efficiency of the compiler)

skip the compiler and write it directly in machine code
 
M

Matthias Buelow

ManicQin said:
Let's ignore for a minute design decisions , readability and any other
of those parameters , In the most raw form of c++ (purely efficiency
if you want)
what is better, bloating up a classes or breaking them up to small
classes?
(and again pure efficiency of the compiler)

The biggest factor in execution speed of a large program are design
decisions and readability. Anything else is something the profiler will
tell you about.
 
J

Juha Nieminen

ManicQin said:
Let's ignore for a minute design decisions , readability and any other
of those parameters , In the most raw form of c++ (purely efficiency
if you want)
what is better, bloating up a classes or breaking them up to small
classes?
(and again pure efficiency of the compiler)

What do you mean by "pure efficiency of the compiler"? How fast the
compiler can compile your source files?
 
P

Pascal J. Bourguignon

ManicQin said:
Let's ignore for a minute design decisions , readability and any other
of those parameters , In the most raw form of c++ (purely efficiency
if you want)
what is better, bloating up a classes or breaking them up to small
classes?
(and again pure efficiency of the compiler)

Neither big or small. Medium sized classes.

The point is that both human programmers, and modern processors are
sized to handle efficiently in short term memory (L1-cache) a medium
number of items. That is, betweeen 5 and 9, 7 on average.

That's the average number of data member a object shall have,
(multiply by 2 to 4 times for the number of methods).

Of course, you may have exceptions, with one or zero data, or with 40
data fields, but you would have to give a very strong reason why not
store the 40 data into a dictionnary, and why not remove the class
with one data member and using directly the data.


Otherwise, for the question of efficiency of the compiler, by the time
your program is termined (and this will be farther in the future the
more you think about performace in these terms), the hardware will
have evolved in such a way and magnitude, that any step you could have
made toward that efficiency would be totally irrelevant (and possibly
counter productive).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,169
Messages
2,570,920
Members
47,464
Latest member
Bobbylenly

Latest Threads

Top