P
puzzlecracker
Hello Group,
Say I have classes A and B and the both need to maintain a pointer/
reference to each for various reasons, say optimization. And there are
other classes in the project use these two classes, among others.
What is the best design for such architecture?
I saw errors by explicitly including headers of both classes. Also,
assume that include guards are included in each header file. I prefix
each class name with C to preserve convention.
Also, instead of including headers directly, I try to maintain
pointers to each class for now. But below is what I am trying to
create in best way, least coupling, and NO COMPILER ERRORS
In CA.h file
----------------
include"B.h"
//and other headers
class A {
private:
B * pB;
};
------------------
In CA.cpp
-----------------
#include "CA.h"
//other headers
// implementation of A class memebers
In CB.h file
----------------
include"A.h"
//and other headers
class B {
private:
A * pA;
};
------------------
In CB.cpp
-----------------
#include "CB.h"
//other headers
// implementation of A class members
COther.h
#include "CA.h"
#include "CB.h"
//some other stuff
COther.cpp
#include<COther.h>
//implementation
====================
Please let me know if my question isn't clear enough, I am working
with a huge system and want to organize one of its component classes
in the best fashion possible, avoiding coupling and a long build
time.
Other than Lakos's classic (Large scale C++ software design), what
reading material (books, papers) would you suggest dealing explicitly
with large projects and mentioned sort of issues?
Thanks
Say I have classes A and B and the both need to maintain a pointer/
reference to each for various reasons, say optimization. And there are
other classes in the project use these two classes, among others.
What is the best design for such architecture?
I saw errors by explicitly including headers of both classes. Also,
assume that include guards are included in each header file. I prefix
each class name with C to preserve convention.
Also, instead of including headers directly, I try to maintain
pointers to each class for now. But below is what I am trying to
create in best way, least coupling, and NO COMPILER ERRORS
In CA.h file
----------------
include"B.h"
//and other headers
class A {
private:
B * pB;
};
------------------
In CA.cpp
-----------------
#include "CA.h"
//other headers
// implementation of A class memebers
In CB.h file
----------------
include"A.h"
//and other headers
class B {
private:
A * pA;
};
------------------
In CB.cpp
-----------------
#include "CB.h"
//other headers
// implementation of A class members
COther.h
#include "CA.h"
#include "CB.h"
//some other stuff
COther.cpp
#include<COther.h>
//implementation
====================
Please let me know if my question isn't clear enough, I am working
with a huge system and want to organize one of its component classes
in the best fashion possible, avoiding coupling and a long build
time.
Other than Lakos's classic (Large scale C++ software design), what
reading material (books, papers) would you suggest dealing explicitly
with large projects and mentioned sort of issues?
Thanks