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

Request for naming help

In libabc, I have a function which takes a NULL-terminated array
of character strings. A second, closely related function take
a NULL-terminated array of void *:
abc_foo( char ** );
abc_vfoo( void **);

I'd like to add 4 similar functions: a variadic version that
takes a char * as its first argument, a variadic version
that takes a void * as its first arg, and similar versions that
take a va_list:
abc_xxx( char *, ...);
abc_xxx( void *, ...);
abc_xxx( char *, va_list);
abc_xxx( void *, va_list);

I think I've already misnamed abc_vfoo(), since one
convention would imply that abc_vfoo() takes a va_list,
but I have no good ideas on the proper naming scheme
for the other 4 functions. I'm looking for ideas on how
to properly mangle these names. How would you
replace the 'xxx' above?

--
Bill Pursell

Apr 3 '07 #1
2 1329
Bill Pursell wrote:
In libabc, I have a function which takes a NULL-terminated array
of character strings. A second, closely related function take
a NULL-terminated array of void *:
abc_foo( char ** );
abc_vfoo( void **);

I'd like to add 4 similar functions: a variadic version that
takes a char * as its first argument, a variadic version
that takes a void * as its first arg, and similar versions that
take a va_list:
abc_xxx( char *, ...);
abc_xxx( void *, ...);
abc_xxx( char *, va_list);
abc_xxx( void *, va_list);

I think I've already misnamed abc_vfoo(), since one
convention would imply that abc_vfoo() takes a va_list,
but I have no good ideas on the proper naming scheme
for the other 4 functions. I'm looking for ideas on how
to properly mangle these names. How would you
replace the 'xxx' above?
Generally functions should be named after what they do, not their
signatures. Here you seem to have a lot of functionally similar
functions. Such situations are indeed a nightmare when it comes to
sensible naming - just witness the amount of confusingly similar names
for functions in GNU GMP.

The C Standard itself prefixes a 'v' to functions taking a va_list.
You might follow that convention. You could also suffix a 'var' or
'_var' to the variadic ones.

But, IMHO, your best strategy might be to try to refactor your code so
that you minimise the number of functionally similar routines. This
might lead to a very slight loss of runtime efficiency but it might be
worth it in terms of code clarity. Try to have a single "interface"
function that accepts several types of arguments and, depending on the
type passed for each invocation, calls one of several "private"
functions to do the actual job. This does result in some compromise
with regard to type safety, but it might be worth it.

Apr 3 '07 #2
Bill Pursell wrote:
>
In libabc, I have a function which takes a NULL-terminated array
of character strings. A second, closely related function take
a NULL-terminated array of void *:
abc_foo( char ** );
abc_vfoo( void **);

I'd like to add 4 similar functions: a variadic version that
takes a char * as its first argument, a variadic version
that takes a void * as its first arg, and similar versions that
take a va_list:
abc_xxx( char *, ...);
abc_xxx( void *, ...);
abc_xxx( char *, va_list);
abc_xxx( void *, va_list);

I think I've already misnamed abc_vfoo(), since one
convention would imply that abc_vfoo() takes a va_list,
but I have no good ideas on the proper naming scheme
for the other 4 functions. I'm looking for ideas on how
to properly mangle these names. How would you
replace the 'xxx' above?
How about cv, gv, cl, gl (g represents general). I doubt they are
needed, since to use a void* parameter the routine has to know what
that void* really points to anyhow. Thus the cx versions are
redundant.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Apr 3 '07 #3

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

Similar topics

0
by: Jeff K | last post by:
JNDI is adding a naming attribute to my add request. Is there a way to prevent this? For example: Using LdapContext.createSubcontext(String s, Attributes atts) with the following: s =...
2
by: Steven D'Aprano | last post by:
Are there any useful naming conventions for modules, classes and functions? For instance, should I name functions as verbs and classes as nouns? eg class Transformer(): pass def...
3
by: clintonG | last post by:
Does the use of DTD, XML Schema and similar constructs adopt the use of C# naming conventions? If so how do I make the distinction of how to apply C# conventions with XML elements, attributes and...
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...
15
by: gjoneshtfc | last post by:
Hello, I have a simple problem that I just cannot get my head around! I currently have the following line in my ASP recordset: Recordset1.Source = "SELECT * FROM MainTable ORDER BY Price ASC"...
9
by: BillCo | last post by:
I'm coming from a MS Access background and so I'm very used to and comfortable with the hungarian (Leszynski et al) naming conventions. However, I'm getting started into my first SQL Server...
8
oll3i
by: oll3i | last post by:
it worked but suddenly when i run it and click a button it throws exception ? D:\SR>java Producent queue1 queue2 queue3 queue4 queue1,queue2,queue3,queue4...
4
by: Olivier Matrot | last post by:
Hello, I have a problem with an ASP.NET 2.0 Application. A client request is processed in parrallel by two threads. This ends with the following exception : <Source>System</Source> <StackTrace...
1
by: Olivier Matrot | last post by:
I have a problem with an ASP.NET 2.0 Application. A client request is processed in parrallel by two threads. After further analysis, it appears that : - There is 2 disctinct session for the...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.