 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Slawek Guest
|
Posted: Mon Nov 14, 2005 12:06 am Post subject: Reducing dependencies |
|
|
Hi,
I know that this is one of the topics that are most popular but I just have
to ask.
Can anyone give me some links, info etc about following question:
- how to reduce code dependencies
- make the code less vurnelable for changes (interfaces?)
Question is becaues I'm starting a new project and I was wandering how to
design classes to make to reduce dependencies.
Also some links with explanation about how exactly compiling work what the
actual difference between global variables and those allocated via 'operator
new'.
This question came up becaues I read that in order to reduce dependencies I
can do something like this:
class CFile;
class CLog
{
CFile *m_pFile
public
..... //code.... ble ble
}
but if I do this I have to dynamically create CFile?
I started to think about It... and I get to conclusion that me C++ skills
are to pure.... to explain myslef what is better
(other option is:)
#include "File.h"
class CLog
{
CFile m_File
public
..... //code.... ble ble
}
this is not only think.... so some good resources about differences in
memory allocation.. (I understand the concept of operator new, but I want to
understand the consequences of it....)
Thanks for any help...
regards,
Slawek
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Michael D. Crawford Guest
|
Posted: Mon Nov 14, 2005 10:23 am Post subject: Re: Reducing dependencies |
|
|
Slawek wrote:
| Quote: | Can anyone give me some links, info etc about following question:
- how to reduce code dependencies
- make the code less vurnelable for changes (interfaces?)
|
I highly recommend John Lakos' excellent book "Large Scale C++ Software
Design". Start by reading chapter 4 and 5.
His concept of "levelization" is important to understand if you don't
want your project to be a rats nest. A levelized codebase has a
heirarchy of dependencies, in which the higher level modules only depend
on modules below them. An unlevelized codebase tends to have every
module depend on every other module.
Don't let the Sun go down before you have obtained your copy.
--
Michael D. Crawford
[email]crawford (AT) goingware (DOT) com[/email]
I am looking for a job programming in C++
http://www.goingware.com/resume/cover-letter.html
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
david.boyle@gmail.com Guest
|
Posted: Mon Nov 14, 2005 4:45 pm Post subject: Re: Reducing dependencies |
|
|
Herb & Andrei takle exactly the sorts of questions you pose in their
"C++ Coding Standards: 101 Rules, Guidelines, and Best Practices".
Cheers,
Dave Boyle
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
albrecht.fritzsche Guest
|
Posted: Tue Nov 15, 2005 9:07 am Post subject: Re: Reducing dependencies |
|
|
Hi Slawek,
look at ACCU's book list - there you will find the section of
your choice and can look at a book suiting your needs.
Slawek wrote:
| Quote: | Also some links with explanation about how exactly compiling work what the
actual difference between global variables and those allocated via 'operator
new'.
|
These are two completely orthogonal questions (global variables might
be allocated via new): names/variables do have a /scope/, eg member
variables can be referenced by every member function. Global variables,
as the name already gives away, might live in the global namespace and
hence have some wider scope. Eg, if on top of your source file you write
int foo;
foo can be referenced from every point in your source file.
/Allocation/, on the other hand, deals only with issues of where the
data lives, how it is allocated/destroyed, ...
| Quote: | class CFile;
class CLog
{
CFile *m_pFile
public
.... //code.... ble ble
}
but if I do this I have to dynamically create CFile?
|
There are other ways to achieve this (I mean, it's C++, isn't it),
but with the above definition, yes. Alternatives include the boost
smart_ptr<> and C++ references.
Ali
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|