473,406 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Large C++ class

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.

Oct 18 '05 #1
6 1833
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.

--
EventStudio System Designer 2.5 - http://www.EventHelix.com/EventStudio
Sequence Diagram Based System Design and Object Modeling Tool

Oct 18 '05 #2
> 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

Oct 18 '05 #3
nilavya wrote:
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

Oct 18 '05 #4
ben
nilavya wrote:
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
Oct 18 '05 #5
EventHelix.com wrote:
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

Oct 18 '05 #6
I would use a named namespace instead. It can be viewed as a class in
object modelling.

Fraser.
Oct 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

36
by: Andrea Griffini | last post by:
I did it. I proposed python as the main language for our next CAD/CAM software because I think that it has all the potential needed for it. I'm not sure yet if the decision will get through, but...
1
by: DJTB | last post by:
zodb-dev@zope.org] Hi, I'm having problems storing large amounts of objects in a ZODB. After committing changes to the database, elements are not cleared from memory. Since the number of...
2
by: Developwebsites | last post by:
const int MAX=999; class person { protected: char firstname, lastname; int ID; public: person();
3
by: A.M-SG | last post by:
Hi, I have a ASP.NET aspx file that needs to pass large images from a network storage to client browser. The requirement is that users cannot have access to the network share. The aspx file...
11
by: Macca | last post by:
Hi, I'm writing an application that will pass a large amount of data between classes/functions. In C++ it was more efficient to send a pointer to the object, e.g structure rather than passing...
4
by: =?Utf-8?B?VzFsZDBuZTc0?= | last post by:
When one architects a new project one of the first steps in the decision is to decide on the layers. (In my opinion anyway) One architecture that I have used before is to go solid OO and create...
4
by: bcomeara | last post by:
I am writing a program which needs to include a large amount of data. Basically, the data are p values for different possible outcomes from trials with different number of observations (the p...
14
by: JoeC | last post by:
I have been writing games and I also read about good programming techniques. I tend to create large objects that do lots of things. A good example I have is a unit object. The object controls...
7
by: =?Utf-8?B?U3RldmVa?= | last post by:
First off, I am not sure if this belongs in this group or the C# group. It seems more like a C++ problem to me. Anyways... I have a C# project which links in an unmanaged C++ DLL, both built...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.