Large C++ class

N

nilavya

Hi,

I have a C++ application for WINCE OS.

The main attraction is the GUI. and all the events and commands of the
user actions are sent from GUI. Now there are many features for that
application which involved selecting a command depending on the present
state of the GUi. this lead to making of a large C++ class
approximately 7000 lines. And I instantiate this class only once using
new operator, and it remains till the application exists. Now I faced
some seviour problems related to memory and GUI freeze on the device
running WINCE OS. Does any one have any Document which says what is
better, a large C++ class or several C++ class. One more thing I want
to ask is that, how the function calls and class are loaded in the
memory at run time.


Thanks,
With regards,
Nirav Bhagat.
 
E

EventHelix.com

I don't think the problem you are facing is due to a large class.

However, it is recommended that you do not have a class with more that
10 private variables. Split the implementation of your class to include
smaller helper classes.

I would recommend "Code Complete 2nd Edition" by by Steve McConnell.
The book covers several topics related to the construction phase.
 
B

BigBrian

However, it is recommended that you do not have a class with more that
10 private variables.

A magic number! I've never heard of this hard coded recommendation
before.
However, I agree with the intent of the statement ( but not the hard
coded value ).
Split the implementation of your class to include
smaller helper classes.

I think if your classes are too large, the solution can be more
difficult than this. It can mean that the design is flawed, and more
is necessary than just spliting the implementation of this single
class.


-Brian
 
K

Kristo

nilavya said:
The main attraction is the GUI. and all the events and commands of the
user actions are sent from GUI. Now there are many features for that
application which involved selecting a command depending on the present
state of the GUi. this lead to making of a large C++ class
approximately 7000 lines. And I instantiate this class only once using
new operator, and it remains till the application exists. Now I faced
some seviour problems related to memory and GUI freeze on the device
running WINCE OS.

That much is OT here. I'd suggest you try one of the microsoft
newsgroups related to WinCE.
Does any one have any Document which says what is better, a large C++
class or several C++ class.

I don't see how it would make a difference as far as C++ is concerned.
If WinCE has some memory quirks that make one better than the other,
then that's a question for a WinCE newsgroup as well.
One more thing I want to ask is that, how the function calls and class
are loaded in the memory at run time.

That's implementation defined. Again, ask on a WinCE newsgroup.

Kristo
 
B

ben

nilavya said:
Hi,

I have a C++ application for WINCE OS.

The main attraction is the GUI. and all the events and commands of the
user actions are sent from GUI. Now there are many features for that
application which involved selecting a command depending on the present
state of the GUi. this lead to making of a large C++ class
approximately 7000 lines. And I instantiate this class only once using
new operator, and it remains till the application exists. Now I faced
some seviour problems related to memory and GUI freeze on the device
running WINCE OS. Does any one have any Document which says what is
better, a large C++ class or several C++ class. One more thing I want
to ask is that, how the function calls and class are loaded in the
memory at run time.


Thanks,
With regards,
Nirav Bhagat.

Whether or not to break down your very large class probably will not
reduce maximum memory usage significantly. You will have to consume a
certain amount of memory for a particular task anyway, regardless which
portion of that is placed in which class.

On the other hand, if you stick to "one class, one responsibility"
principle, then debugging and maintaining can be greatly enhanced. Also
enhanced is resource management, viz, unneeded resources get reclaimed
quickly and logically.

Ben
 
K

Kristo

EventHelix.com said:
I don't think the problem you are facing is due to a large class.

I think the problem you are facing is that you don't quote context. ;-)
However, it is recommended that you do not have a class with more that
10 private variables. Split the implementation of your class to include
smaller helper classes.

What good would that do? Who made up that rule?

[snip book recommendation]

Kristo
 
F

Fraser Ross

I would use a named namespace instead. It can be viewed as a class in
object modelling.

Fraser.
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top