Re: irregulars: how to split c++ class between multiple files

2003-08-14 Thread The Fool
> From: Alberto Monteiro <[EMAIL PROTECTED]>
> 
> The Fool asked:
> >
> 
> >I have a c++ class that is very large (>90k lines) that I need to
split
> >up between multiple files.
> >
> Uh? Just do it.
> 
> >The way it is now I have a header file with all the declarations
"x.h",
> >and a c++ source file that contains all the functions in "y.cpp".  I
need
> >to be able to split the functions up between two files like "y.cpp"
and
> >"z.cpp".  The primary reason being that the VC++ IDE doesn't work with
> >lines after line 65535 and doesn't allow debugging any function or
parts
> >of functions after line 65535.
> >
> In a real programming language, there should be no problem. You
> can even split so that the "most useful" functions exist in
> one module and the "most obscure" in the other. And it's even
> possible to put things in the x.h that don't exist in either y.cpp or
> z.cpp.
> 
> Like:
> x.h
> 
> class X
> {
> public:
>   int a() const;
>   int b() const;
>   int c() const;
> };

> class X
>   {
>   public: //
const int a();
const int b();
const int c();
>   };


> 
> y.cpp:
> 
> #include "x.h"
> 
> int X::a() const
> {
>   return 42;
> }

> const int X::a()
>   {
>   return 42;
>   }


> 
> z.cpp:
> 
> #include "x.h"
> 
> const int X::b()
>   {
>   return 666;
>   }
> 
> 
> 
> Is this what you asked?

Mostly.
___
http://www.mccmedia.com/mailman/listinfo/brin-l


Re: irregulars: how to split c++ class between multiple files

2003-08-14 Thread Jan Coffey

--- Joshua Bell <[EMAIL PROTECTED]> wrote:
> From: "The Fool" <[EMAIL PROTECTED]>
> 
> > Not in this particular case.  All the functions are related / use the
> > same class variables etc.  Also sometimes speed and efficiency are more
> > important than ease of use.
> 
> Very rarely - what's going to happen to the code in 6 months when you've
> forgotten how half of it works? Is that trade-off worth it? Programmer &
> maintenance time usually outweights processing time.
> 
> It is extremely unlikely that the overhead of method calls (even vtable
> calls) are the performance bottleneck in any realistic project. About the
> only time you need to even think about those are when you're writing the
> tight inner loop of a 2D/3D/Sound rendering core - and with standard APIs
> (OpenGL, DirectX, etc) there's very little need to worry about that.
> 
> Even then, one of the projects I'm working on for fun is a 3D engine for
> the
> PocketPC (no DirectX or hardware acceleration) which is entirely C++ and
> makes heavy use of code broken up into multiple classes. Using such C++
> features as the "inline" directive, const variables, templates,
> metaprogramming, etc. you can completely eliminate even the overhead of
> function calls and object derefencing. The trick is to make the compiler do
> it, not the programmer. Compilers are VERY good at optimizations these days
> if you have enough hints in your code.
> 
> Besides, trying to optimize without doing profiling is crazy (apart from
> obvious things like using good algorithms). It's well known that you should
> write the code first and optimize later, since what you think might be the
> bottlenecks and what actually turn out to be the bottlenecks are very
> rarely
> the same thing.
> 
> Joshua

Well said.

=
_
   Jan William Coffey
_

__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
___
http://www.mccmedia.com/mailman/listinfo/brin-l


Re: irregulars: how to split c++ class between multiple files

2003-08-14 Thread Alberto Monteiro

The Fool asked:
>

>I have a c++ class that is very large (>90k lines) that I need to split
>up between multiple files.
>
Uh? Just do it.

>The way it is now I have a header file with all the declarations "x.h",
>and a c++ source file that contains all the functions in "y.cpp".  I need
>to be able to split the functions up between two files like "y.cpp" and
>"z.cpp".  The primary reason being that the VC++ IDE doesn't work with
>lines after line 65535 and doesn't allow debugging any function or parts
>of functions after line 65535.
>
In a real programming language, there should be no problem. You
can even split so that the "most useful" functions exist in
one module and the "most obscure" in the other. And it's even
possible to put things in the x.h that don't exist in either y.cpp or
z.cpp.

Like:
x.h

class X
{
public:
  int a() const;
  int b() const;
  int c() const;
};

y.cpp:

#include "x.h"

int X::a() const
{
  return 42;
}

z.cpp:

#include "x.h"

int X::b() const
{
  return 666;
}



Is this what you asked?

Alberto Monteiro


___
http://www.mccmedia.com/mailman/listinfo/brin-l


Re: irregulars: how to split c++ class between multiple files

2003-08-14 Thread Joshua Bell
From: "The Fool" <[EMAIL PROTECTED]>

> Not in this particular case.  All the functions are related / use the
> same class variables etc.  Also sometimes speed and efficiency are more
> important than ease of use.

Very rarely - what's going to happen to the code in 6 months when you've
forgotten how half of it works? Is that trade-off worth it? Programmer &
maintenance time usually outweights processing time.

It is extremely unlikely that the overhead of method calls (even vtable
calls) are the performance bottleneck in any realistic project. About the
only time you need to even think about those are when you're writing the
tight inner loop of a 2D/3D/Sound rendering core - and with standard APIs
(OpenGL, DirectX, etc) there's very little need to worry about that.

Even then, one of the projects I'm working on for fun is a 3D engine for the
PocketPC (no DirectX or hardware acceleration) which is entirely C++ and
makes heavy use of code broken up into multiple classes. Using such C++
features as the "inline" directive, const variables, templates,
metaprogramming, etc. you can completely eliminate even the overhead of
function calls and object derefencing. The trick is to make the compiler do
it, not the programmer. Compilers are VERY good at optimizations these days
if you have enough hints in your code.

Besides, trying to optimize without doing profiling is crazy (apart from
obvious things like using good algorithms). It's well known that you should
write the code first and optimize later, since what you think might be the
bottlenecks and what actually turn out to be the bottlenecks are very rarely
the same thing.

Joshua
___
http://www.mccmedia.com/mailman/listinfo/brin-l


Re: irregulars: how to split c++ class between multiple files

2003-08-14 Thread Jan Coffey

--- The Fool <[EMAIL PROTECTED]> wrote:
> 
> 
> --
> From: Horn, John <[EMAIL PROTECTED]>
> To: Killer Bs Discussion <[EMAIL PROTECTED]>
> Subject: RE: irregulars: how to split c++ class between multiple files
> Date: Saturday, August 09, 2003 10:20 AM
> 
> > From: The Fool [mailto:[EMAIL PROTECTED]
> > 
> > I have a c++ class that is very large (>90k lines) that I 
> > need to split
> > up between multiple files.
> 
> I'm not a c++ programmer.  But that seems to be a very, very large
> class.  Wouldn't it be better (and/or possible) to split it up into
> a main class and some helper classes?
> 
> Not that that answered the original question, of course...
> 
> ---
> Not in this particular case.  All the functions are related / use the
> same class variables etc.  Also sometimes speed and efficiency are more
> important than ease of use.

A class of that size is certaily not well factored. Trust me, good OO
abstraction will not screw your performance in C++.

Send me your design and I can help you refactor it.

=
_
   Jan William Coffey
_

__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
___
http://www.mccmedia.com/mailman/listinfo/brin-l


Re: irregulars: how to split c++ class between multiple files

2003-08-14 Thread The Fool


--
From: Horn, John <[EMAIL PROTECTED]>
To: Killer Bs Discussion <[EMAIL PROTECTED]>
Subject: RE: irregulars: how to split c++ class between multiple files
Date: Saturday, August 09, 2003 10:20 AM

> From: The Fool [mailto:[EMAIL PROTECTED]
> 
> I have a c++ class that is very large (>90k lines) that I 
> need to split
> up between multiple files.

I'm not a c++ programmer.  But that seems to be a very, very large
class.  Wouldn't it be better (and/or possible) to split it up into
a main class and some helper classes?

Not that that answered the original question, of course...

---
Not in this particular case.  All the functions are related / use the
same class variables etc.  Also sometimes speed and efficiency are more
important than ease of use.

___
http://www.mccmedia.com/mailman/listinfo/brin-l


Re: irregulars: how to split c++ class between multiple files

2003-08-10 Thread Jan Coffey

--- The Fool <[EMAIL PROTECTED]> wrote:
> I have a c++ class that is very large (>90k lines) that I need to split
> up between multiple files.
> 
> The way it is now I have a header file with all the declarations "x.h",
> and a c++ source file that contains all the functions in "y.cpp".  I need
> to be able to split the functions up between two files like "y.cpp" and
> "z.cpp".  The primary reason being that the VC++ IDE doesn't work with
> lines after line 65535 and doesn't allow debugging any function or parts
> of functions after line 65535.
> 

If you have a single class of the size you describe. You have a clear design
issue.

This link may be of some asistence.

http://www.objectmentor.com/resources/articles/Principles_and_Patterns.PDF

If you need more specific help I would be willing to assist you. feel free to
e-mail me off line.


=
_
   Jan William Coffey
_

__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
___
http://www.mccmedia.com/mailman/listinfo/brin-l


RE: irregulars: how to split c++ class between multiple files

2003-08-09 Thread Horn, John
> From: The Fool [mailto:[EMAIL PROTECTED]
> 
> I have a c++ class that is very large (>90k lines) that I 
> need to split
> up between multiple files.

I'm not a c++ programmer.  But that seems to be a very, very large
class.  Wouldn't it be better (and/or possible) to split it up into
a main class and some helper classes?

Not that that answered the original question, of course...

  - jmh
___
http://www.mccmedia.com/mailman/listinfo/brin-l