473,387 Members | 1,492 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,387 software developers and data experts.

Re: Help with naming convention requested

On Jun 12, 7:36*am, James Kanze <james.ka...@gmail.comwrote:
For the moment, I've named the classes: BasicSetOfCharacter (POD
base class) and SetOfCharacter (derived class). *I'm not
particularly happy with this, since it means that functions
taking a const reference really have to take a
BasicSetOfCharacter const&. *Other alternatives I've considered
are ConstSetOfCharacter/SetOfCharacter and
SetOfCharacter/DynamicSetOfCharacter, but I'm open to other
suggestions as well.
I think that "CharacterSetBase" and "CharacterSet" (for the base and
derived classes respectively) would sound more natural and would
better convey the class' purpose. After all, a character set can be
any arbitrary collection of characters, it does not need to match any
of the "standard" character sets - although, of course, it might.

Moreover, you could also convey the const/non-const difference between
the classes with typedefs:

typedef CharacterSetBase * ConstCharacterSetRef;
typedef CharacterSet * CharacterSetRef; // or MutableCharacterSetRef

I would favor leaving out "dynamic" or "mutable" (since the absence of
"Const" should be enough). Note also that - although the two
CharacterSet typedefs are pointer types - the "Ref" in the typedef
name means that variables of this type are not expected to be null
(otherwise, I would use "Ptr" instead of "Ref").

Greg

Jun 27 '08 #1
1 1122
On Jun 13, 2:27 am, Greg Herlihy <gre...@mac.comwrote:
On Jun 12, 7:36 am, James Kanze <james.ka...@gmail.comwrote:
For the moment, I've named the classes: BasicSetOfCharacter (POD
base class) and SetOfCharacter (derived class). I'm not
particularly happy with this, since it means that functions
taking a const reference really have to take a
BasicSetOfCharacter const&. Other alternatives I've considered
are ConstSetOfCharacter/SetOfCharacter and
SetOfCharacter/DynamicSetOfCharacter, but I'm open to other
suggestions as well.
I think that "CharacterSetBase" and "CharacterSet" (for the base and
derived classes respectively) would sound more natural and would
better convey the class' purpose. After all, a character set can be
any arbitrary collection of characters, it does not need to match any
of the "standard" character sets - although, of course, it might.
Exactly. I think you've understood what I'm working at. I
don't want to have to build up "[:alpha:]" at each execution; in
fact, practically, I can't, because I build it by reading and
parsing UnicodeData.txt. So it should be a statically
initialized constant. (In the actual application, a lot of
special sets can be as well, but [:alpha:] is a good example,
because it must be initialized externally.) On the other hand,
client code can (and in some cases does) create their own
SetOfCharacter, using the classical set operations.

I am currently using BasicSetOfCharacter and SetOfCharacter.
What I don't like about it is that most client code doesn't
modify its argument, and you want to be able to pass it things
like CharacterClass::alpha (the set for [:alpha:]). I'm thus
drawn to the idea that SetOfCharacter should be the non-mutable
base class, with something special to indicate mutability. On
the other hand...

With regards to CharacterSet vs. SetOfCharacter: the second
sounds more natural to me. Both Character and Set are nouns (in
this case, at least), and it seems more natural to join nouns
with a preposition than to just juxtapose them. But this could
just be me---it's been over 35 years since I last regularly
spoke English, and it's probable that I've lost a lot of my feel
for the language. (Now that you mention it, English is a
Germanic language, and in German, I'd definitely call it
Zeichenmenge, and not MengeVonZeichen.)
Moreover, you could also convey the const/non-const difference between
the classes with typedefs:
typedef CharacterSetBase * ConstCharacterSetRef;
typedef CharacterSet * CharacterSetRef; // or MutableCharacterSetRef
I would favor leaving out "dynamic" or "mutable" (since the absence of
"Const" should be enough). Note also that - although the two
CharacterSet typedefs are pointer types - the "Ref" in the typedef
name means that variables of this type are not expected to be null
(otherwise, I would use "Ptr" instead of "Ref").
I'm not sure about the typedef's, but I think you've raised a
significant point: in C++, mutability is implicit, and we mark
constness. If I base my naming on the language, the names
should be ConstSetOfCharacter and SetOfCharacter.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orient�e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S�mard, 78210 St.-Cyr-l'�cole, France, +33 (0)1 30 23 00 34
Jun 27 '08 #2

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

Similar topics

0
by: Norm Wong | last post by:
If anyone is interested in using db2uext2 with Cygwin gcc compiler on Windows, I've modified the IBM provided sample with the attached file. There are two main modifications. The mkdir command...
48
by: Chad Z. Hower aka Kudzu | last post by:
A few of you may recognize me from the recent posts I have made about Indy <http://www.indyproject.org/indy.html> Those of you coming to .net from the Delphi world know truly how unique and...
4
by: Mark Broadbent | last post by:
stupid question time again to most of you experts but this is something that continually bothers me. I am trying to get into the habit of naming variables and controls in an assembly as per...
5
by: Marco Solchio | last post by:
I'm coming from C++ world, where I've been using #define SALSA 1 and #define SALSA_DANCE "Salsa Dance" in a header file to define my constants..., all uppercase and underscores. Does the...
48
by: Robert Jacobson | last post by:
Hello all, If I have a class called "Foo," is there a preferred naming convention for iterating through each Foo instance in a collection of Foos? I've seen several different variations, even...
10
by: jjkboswell | last post by:
I'm trying to pin down a good naming convention for the 3 things required to implement an event. You need: 1) a delegate 2) an event 3) an event handler Below is my understanding of a...
4
by: Sturdy | last post by:
Hi, I'm new to C# and .NET. I'm a first time user of Visual C# 2005 Express and have a very basic question. I've looked at several links and lots of docs but can't find any tips on naming multiple...
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...
23
by: special_dragonfly | last post by:
Hello, I'm new to this group, I've read through the subject of a lot of the group but can't find anything relevant. Perhaps my question is too basic but I'm still stuck. Classes and Dictionaries....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.