On Fri, 2002-10-18 at 02:59, Evgeny Kotsuba wrote:
> Well. Please look at http://www.wxwindows.org/faqgen.htm and take in
> mind that wxwindows is deeply-OO/++
> As for me it is impossiple to catch errors in temlates via debugger
> and I can't catch errors by Cnin-Gach-Gook methods (via long
> meditation over the source)
Well, templates allow the debugger to show you the source, whereas
#defines don't. I suspect that your compiler may have inlined all the
template code, which is a separate problem.
> >> >file naming: .h files should only declare one class.
> >> it will fine if we have few non- related classes
> >
> >Huh? Not sure what you mean. Can you enlarge on your comment?
> >
> say we have
>
> class shortClassA
> {
> }
>
> class longClassB
> {
> ....
> shortClassA blabla;
> shortClassA blabla1;
> shortClassA blabla2;
> .....
> }
>
> and shortClassA is used only in longClassB
I would do:
class LongClassB {
public:
...
private:
class ShortClassA {
public:
..
};
shortClassA blabla;
shortClassA blabla1;
};
> >> what about "not use static initialisation" exept for structures and
> >> structures-like classes ?
> >
> >static initialisation is incredibly useful. So why not use it?
> But how to catch erros etc. before main() is started ?
Thats easy. If the error is in initialisation code, you simply
breakpoint it or have it throw an exception. Also, __main() (If I recall
correctly) is used to call all static initilizers on most Unix-like OS's
(ie not Win32 :]). Any code put in static initializers must be very very
basic and reliable - ie module registration.
> As for squid - how to do smthg before config is read ?
We do lots before the config is read. Using my example above we register
the available auth, fs and repl modules. Using static initializers we
can simply link those in - and dlopen them - to become available. Not
using static initializers we have to know at compile time what modules
are available.
> And say, how to
> reinit squid at runtime - should we have both static and dynamic
> initializations ?
Again, we already do. I'm not suggesting that that change.
> >
> >What other 'devil constructions' are you referring to?
>
> I have deal with some code where memory management was build on ++
> exeptions. As it was written in some books by big scientists. It was
> nightmare. It was impossible to use any general technics to catch
> errors with memory usage...
Well, we're all very keen on easy debugging. I'm pretty sure you won't
see us use exceptions for memory debugging, other than the default
exception that new() throws. Which reminds me, gotta put that into the
overloaded operator new calls / have mem.cc throw it. It doesn't matter
today, because out of memory is a fatal() IIRC.
> Templates. Platphorm - specific templates. Recursive called .h
> //file1.h
> ...
> #include "file2.h"
>
> //file2.h
> ...
> #include "file3.h"
>
>
> //file3.h
> ...
> #include "file1.h"
> ....
Well this is bad if the files are not #ifdef guarded. If they are
properly #ifdef guarded, I don't see the issue.
Rob
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:16:57 MST