Journal Articles

CVu Journal Vol 14, #2 - Apr 2002 + Letters to the Editor
Browse in : All > Journals > CVu > 142 (12)
All > Journal Columns > LettersEditor (132)
Any of these categories - All of these categories

Note: when you create a new publication type, the articles module will automatically use the templates user-display-[publicationtype].xt and user-summary-[publicationtype].xt. If those templates do not exist when you try to preview or display a new article, you'll get this warning :-) Please place your own templates in themes/yourtheme/modules/articles . The templates will get the extension .xt there.

Title: The Wall - Your Letters etc.

Author: Administrator

Date: 08 April 2002 13:15:51 +01:00 or Mon, 08 April 2002 13:15:51 +01:00

Summary: 

Body: 

Re: A Little Class

Dear Detlef,

The October issue of C Vu has remained by my bedside open at your article for the last 3 months and I must confess that I have had the greatest difficulty in really understanding what is going on in this class. I have tried about 5 times to get through it.

Now I do not wish to criticise because I am pleased that you wrote the article - it highlights huge gaps in my knowledge - but I thought it might be helpful for you to know about the areas that I struggled with.

First it would have been helpful as an introduction to give an illustration of what stamp actually does and what the internal variables might look like after 5 applications

Second I found the inclusion of a namespace something of a diversion - is it really necessary to introduce this concept and if so why is it good practice?

Third, I did not understand the explanations of the methods of StringCounter and why it is so necessary to make one of the methods explicit.

Fourth I got lost with the algorithm. I found it difficult to visualise a picture of what is actually happening.

I then wondered if there could be a simpler way to tackle this problem and this might be what you refer to in your opening paragraph:

  1. Keep track of a Long Integer that holds the value of the "number" just issued

  2. Convert this to a number in base 26 arithmetic by using the modulo function and hold the result in a vector

  3. Look up the relevant alphabetic characters using the numbers in the vector

This has the merit that incrementing the counter is very easy; it's arithmetic not a complex string manipulation.

Robert Pauer

Detlef's reply

Dear Robert,

Thank you for your comments. It's always helpful to get some feedback on my writing, so I can learn how to make it better next time (hopefully). So I really appreciate that you took the time to write down your problems with my article.

Regarding the explanation of the algorithm: I completely agree. I knew that this was the weak point of my article and even more, I know that too few illustrations is a general fault of all my documents. But every time I write something new, I forget about this.

Obviously, for me are writing and drawing two completely different activities, and if I do the one, I forget about the other :-( Perhaps as an excuse, the real motivation to write that article was not to provide a (quick'n'dirty) solution to this particular problem, but to show a bit more in general how to write a class of professional quality that would pass a real code review.

About the namespace topic: yes, for a quality class a namespace is a must. For a (probably too detailed) article on namespaces look back to Sean Corfield's article "What's in a name?" in Overload 10, it can also be found on the internet at http://www.corfield.org/cplusplus.phtml?cpp=name

The keyword explicit also deserves a full article; the short message is: always use explicit on constructors that can be called with one argument except where you definitely want otherwise.

Your solution is definitely a valid one, and it's probably also simpler, as you write, as most manipulations are done in integer, and most programmers are more comfortable with numbers than with strings. But part of the exercise for me was to learn something about std::string, so to count inside of a string was actually a good opportunity for me. Also, the algorithm itself is not really complicated, it's essentially just counting in base 26 arithmetic. It's just my explanation that is complicated, and if I had tried to explain how to convert an integer into a string representing that number in base 26, I would probably have made it even more complicated ;-)

Best wishes

Detlef

Notes: 

More fields may be available via dynamicdata ..