473,327 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Naming issue

I have a class that holds a sequence of data items. Modifying those
items is the sole domain of the class itself. However, the user has
read access to the data, e.g. to gather statistics. This access is
via an iterator range. While there is one unrelated place I might add
a write hook later, I'm positive that write access through the range
interface will never make sense. Given that, can I call the iterator
type just "iterator" for convenience or should it be "const_iterator"
for conceptual accuracy? What do you think?
Martin

--
Quidquid latine scriptum sit, altum viditur.
Dec 16 '05 #1
7 1360
After I asked (and got good answers, thanks to Victor Bazarov) a few
similar questions to yours now I'd say something like this:

"Ask yourself if such name would be clear for you and if you'd be able
infer from such name it's character - the constness - easily or not?"

Cheers
--
Mateusz Loskot
http://mateusz.loskot.net

Dec 16 '05 #2
Mateusz Loskot wrote:
After I asked (and got good answers, thanks to Victor Bazarov) a
few similar questions to yours now I'd say something like this:

"Ask yourself if such name would be clear for you and if you'd
be able infer from such name it's character - the constness -
easily or not?"


In view of your posts in that thread, I'm not sure if the above is
supposed to be a real or a rhetoric question. I do believe the answer
to the first part would be Yes for *me* once I'd grasped what the
class does, but that's a hazardous way to write code for others to
use. Regarding the second part, I want to know what the cognitive
burden on *other* people is when the overall semantics of an
interface takes precedence over conventional connotations of a member
name.
Martin

--
Quidquid latine scriptum sit, altum viditur.
Dec 16 '05 #3
I think, after your second post, I get your point better.
It seems that "overall semantics interface of your class" is more
importand than semantics of individual members of that interface. I
also think right answer will be much subjective.

As such, I still think semantics of individual members of interface is
very important and should be as clear as possible, or even predictable.
So, "conceptual accuracy" is also very important at the level of
individual member functions.

Consequently, if semantic of access is const in manner of whole object
- provides read-only access to data managed by object - I'd use
const_iterator + member function declared as const.

Cheers
--
Mateusz Loskot
http://mateusz.loskot.net

Dec 16 '05 #4
Mateusz Loskot wrote:
It seems that "overall semantics interface of your class" is
more importand than semantics of individual members of that
interface. I also think right answer will be much subjective.

As such, I still think semantics of individual members of
interface is very important and should be as clear as possible,
or even predictable.


I guess you're right. Since this was the last decision to make before
relabeling the thing from beta to 1.0 and no others have given their
opinion, I've decided to assume that they're silently shaking their
heads and go for const_iterator. If you want to see what this was
about anyway, look here: http://www.aphoria.de/code/diffevol-1.0.zip
Martin

--
Quidquid latine scriptum sit, altum viditur.
Dec 17 '05 #5
Martin Eisenberg wrote:
I have a class that holds a sequence of data items. Modifying those
items is the sole domain of the class itself. However, the user has
read access to the data, e.g. to gather statistics. This access is
via an iterator range. While there is one unrelated place I might add
a write hook later, I'm positive that write access through the range
interface will never make sense. Given that, can I call the iterator
type just "iterator" for convenience or should it be "const_iterator"
for conceptual accuracy? What do you think?

You should have both, and typedef them to the same type.
Then you should document the behaviour of course.
I'd guess there's not a strong expectation that Type::iterator
must be mutable (think set::iterator, or a container passed by
const reference to some function), but users would expect
both declarations to compile:
YourClass::const_iterator it = a.begin();
YourClass::iterator it2 = b.begin();
homsan

Dec 17 '05 #6
Martin Eisenberg wrote:

If you want to see what this was
about anyway, look here: http://www.aphoria.de/code/diffevol-1.0.zip


Unfortunately, I can not say much about it because I'm not an expert of
genetic algorithms but sounds intersting :-)

Cheers
--
Mateusz Loskot
http://mateusz.loskot.net

Dec 17 '05 #7
homsan toft wrote:
Martin Eisenberg wrote:
Given that, can I call the iterator type just "iterator" for
convenience or should it be "const_iterator" for conceptual
accuracy? What do you think?


You should have both, and typedef them to the same type.


That's interesting, thanks!
Martin

--
Quidquid latine scriptum sit, altum viditur.
Dec 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Shemp | last post by:
We are having a debate in our organization about naming conventions for abstract classes. The three proposed methods are: 1) Prefix the class name with abstract. Example: AbstractUser 2)...
9
by: Sandeep Sharma | last post by:
For many years I have been following the convention of naming all class attributes with a leading underscore. This enables me to quickly identify the class attributes when I encounter them in the...
38
by: news.microsoft.com | last post by:
Greetings, I am posting this message to both the SQL Server and C# news groups because this inquiry is more of a theoretical question that applies to both database and code naming conventions. ...
11
by: orekinbck | last post by:
Hi There What convention do you use when naming an enumeration and variables that use the enumeration? I like plural/singular, for example: public class Example { public enum VehicleTypes...
4
by: michaeltorus | last post by:
H I've got an n-tier web app. The namespaces follow the layers in that I've got a DAL namespace, a BOL namespace and a WEB namespac What I'm tring to decide is the naming convention for my...
8
by: bim_bom | last post by:
Hi, is there any tool to change naming convention in c++ sources? I mean something, that parses cpp and h files in my project, and it finds, what variables are there declared. I think, it should...
114
by: Jonathan Wood | last post by:
I was just wondering what naming convention most of you use for class variables. Underscore, "m_" prefix, camel case, capitalized, etc? Has one style emerged as the most popular? Thanks for...
47
by: Zytan | last post by:
Is the m_variableName used for data members in C# classes? Since everything is in a class, it seems that it becomes pointless. What is the general naming conventions? What are your personal...
23
by: Thorsten Kampe | last post by:
Okay, I hear you saying 'not another naming conventions thread'. I've read through Google and the 'naming conventions' threads were rather *spelling conventions* threads. I'm not interested...
5
by: Monty | last post by:
I have an ASP.Net project I developed in VS2003 (ASP.Net 1.1) that works fine, but when I convert it to VS2005 (ASP.Net 2.0) it's behavior seems to change. I have the following datagrid in my...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.