Re: Refactoring Patch

Ralf Engels <[email protected]>
Newsgroups gmane.comp.audio.zinf.devel
Message-ID <[email protected]>
Hi,
thanks for the lengthly reply. I will continue commenting and expecially
with the doxygen comments.
I also will continue clarifying function names as you can see from my
latest patches.

My best success till now was to debug and re-write a program. Besides
fixing all bugs I managed to reduce the rom consumption by 50% and rom
consumption by 95%!
I guess this will not be possible here. :)

However I disagree in one point:

  > For class like objects, references always make sense:
  >
  > 1.  read-write types should  be "type&" as an argument
  > 2.  read-only  types should be "const type& " as an argument
  >
  > This stems from the fact that passing large objects on
  > the stack by value can be quite costly in terms of runtime
  > performance.

If you see a function call like this

doIt( p1 );

You will think that p1 is not modified. Call by value is the standard
case with C.

However someone could define doIt like this:

doIt( ObjType* &p1)

and now I will spend half an hour looking where the heck p1 is initialized.

In Java the same problem does not appear. There p1 could be modified if
it is an Object but never set!

So I prefere to define doIt like this:

doIt( ObjType* *p1 )

In this case the call to doIt( &p1 ) makes it absolutly clear that p1
can be set.

At last I want to say that C++ has good and bad points. A small call
with std::string can lead to a lot of mallocs because the object could
be copied around.
Good point is that you can call by reference and use const to state that
the function will not modify the reference.

More patches will follow...

BR,
Ralf






-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.