R
ronic
I am creating a big class.
and I want to define in different files for this class.
How to do it?
Thanks.
and I want to define in different files for this class.
How to do it?
Thanks.
ronic said:I am creating a big class.
and I want to define in different files for this class.
ronic said:I am creating a big class.
and I want to define in different files for this class.
How to do it?
ronic said:I am creating a big class.
and I want to define in different files for this class.
How to do it?
Thanks.
Alberto Barbati said:I am of the school "one component, one file" where "component"
is one or more strongly related classes.
Nick said:If the problem is just the size of the .cpp/.cxx etc file then just split it
in two - there
is no (practical) reason not to.
lilburne said:The practical problem is that you then have more than one
place to look for the source. I like to have corresponding
file names:
include/somecomponent/myClass.h
source/somecomponent/myClass.cpp
having to ferret about looking in
source/somecomponent/myClass_part1.cpp
source/somecomponent/myClass_part2.cpp
source/somecomponent/myClass_part3.cpp
is a tad annoying.
Big classes are usually a sign of poor design. Are you sure you really
need such a big class? Think twice before answering.
Sims said:I read what you and others say but what about cases where the splitting of
files is more for ease of use rather than design.
For example imaging a data handling class.
You could split the class to make it easier to handle.
class SomeDataHandelingClass
{
#include "SomeDataHandelingClass_READ.h";
#include "SomeDataHandelingClass_WRITE.h";
#include "SomeDataHandelingClass_MISC.h";
};
Would that not be a case where splitting the class would make it somewhat
easier to read eventhouh the class might not be that big?
Nick Hounsome said:By practical I only meant easy to create not easy to maintain
Nick Hounsome said:A big class is probably bad design.
Hogwash.
Not knowing how to put it in different files means you are an inexperienced
programmer who hasn't read much
Hogwash.
which again implies that the class is probably a bad
design.
Hogwash.
I know it's not directly helpful but I promise that in the long term
you'll be better off just stuffing it all one file and spending the time
saved reading C++ design books so you do it right next time.
if I should apologize to the op on your behalf. A person need not be
familiar with every possible technique to design or produce quality
software. A series of assumptions and vacuous conclusions on your
part does not render the op ignorant.
ronic said:Thank for all your good help.
I am creating a class to simulate a micro controller. The micro
controller has
several hundreds instructions. So there are serveral hundreds private
instruction handlers. So I do like this
private:
#include "act.h"
#include "act_ABS.h"
#include "act_ADC_1.h"
#include "act_ADC_2.h"
#include "act_ADCF.h"
#include "act_ADD_1.h"
#include "act_ADD_2.h"
#include "act_ADD_3.h"
......
ronic said:I am creating a class to simulate a micro controller. The micro
controller has
several hundreds instructions. So there are serveral hundreds private
instruction handlers. So I do like this
private:
#include "act.h"
#include "act_ABS.h"
#include "act_ADC_1.h"
#include "act_ADC_2.h"
#include "act_ADCF.h"
#include "act_ADD_1.h"
#include "act_ADD_2.h"
#include "act_ADD_3.h"
......
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.