[openbeos] Re: BString

  • From: "Daniel Reinhold" <danielr@xxxxxxxxxxxxx>
  • To: openbeos@xxxxxxxxxxxxx
  • Date: Sat, 10 Nov 2001 11:59:41 CST

>
>Just quickie, I am writing a version of BString, just to cut my teeth, 
>any objections/suggestions?
>        Keith

There are gobs of implementations of a basic string class out there -- 
I think most C++ programming books probably do some sort of version as 
an example. Also, the MUSCLE distrib comes with a number of basic class 
implementations including a string class. You may want to look at those 
for inspiration (you can get MUSCLE at BeBits).

However you go about it, I would make sure that your version is as 
lightweight as is possible. It should have the minimum overhead above 
and beyond C char pointers. Developers quickly learn whenever a class 
is too heavy or inefficient and just avoid using it.

As far as implementation methodology, I would do this: 

Create a BString class with a different name. Since you are Keith, how 
about KString? Now, implement your version and then test it against 
BString. Obviously it should support all the class functions with 
exactly the same results. Then write up a testing suite that really 
stresses the hell out of it -- create/destroy thousands (millions) of 
the buggers in a loop. Tweak it until it produces memory usage/speed on 
par or better than the native BString.

Finally, when you have your battle tested version ready, rename it to 
BString and check it into the CVS. And then let us know so we can 
properly praise you!


Other related posts: