Naming Of Methods/Functions

J

Jeff Gaines

I am working on a program that used CodeDom to create a class file, I've
just about got to the stage where I can produce either a C# or VB file so
I am making progress.

I have made myself a CodeDom Helper class to cut down on code repetition
but I'm struggling to come up with descriptive names for the helper
functions.

As an example I have helper functions that produce the following
CodeExpressionStatements:

dbConnection.Open();
dbDataAdapter.Fill(dataSet, m_TableName);
GetSingleRecordDetails(selectString, alpha01Data);

Calling them all "CreateCodeExpressionStatement" isn't helpful when I'm
struggling to learn CodeDom.

I am thinking along the lines of Createxxx but I don't know what they are
technically called apart from "statements" (and I'm not even sure that is
correct).

I am weak on the technical expressions used in C# / NET so if anybody can
suggest a consistent naming convention or NET guidelines on naming it
would be very helpful :)
 
W

Willem van Rumpt

I am working on a program that used CodeDom to create a class file, I've
just about got to the stage where I can produce either a C# or VB file
so I am making progress.

I have made myself a CodeDom Helper class to cut down on code repetition
but I'm struggling to come up with descriptive names for the helper
functions.

As an example I have helper functions that produce the following
CodeExpressionStatements:

dbConnection.Open();
dbDataAdapter.Fill(dataSet, m_TableName);
GetSingleRecordDetails(selectString, alpha01Data);

Calling them all "CreateCodeExpressionStatement" isn't helpful when I'm
struggling to learn CodeDom.

I am thinking along the lines of Createxxx but I don't know what they
are technically called apart from "statements" (and I'm not even sure
that is correct).

I am weak on the technical expressions used in C# / NET so if anybody
can suggest a consistent naming convention or NET guidelines on naming
it would be very helpful :)

I've done some work with codedom (mainly generating code from XSD's with
lots of options for tweaking the result and injecting additional code),
and the only viable way I found of naming those helpers is
by naming them as explicitely as possible, i.e. :

CreateOpenDbConnectionStatement()
CreateFillDbAdapterStatement()
CreateGetSingleRecordDetailsStatement()

In my case, there was the possibility of splitting it up in to more
minute "particles". So there we would be (for instance):

Create<xxx>Fragment (creating a part of a statement)
Create<xxx>Statement (creating a statement out of fragments)
and
Create<xxx>Snippet (creating code snippets out of statements)

But this highly depends on what is needed, and what you have to support.

Bottomline is:
The naming will either lean to being non-descriptive (lots of
non-informative names), or it will lean to being ugly (lots of long,
unpleasant to read (code wise), elaborate names).

I found that choosing the latter is the lesser of two evils. Code
generation can be confusing, to say the least, so being as explicit as
you can in specifying *exactly* what the thing generates is definitely
going to help you.
 
R

Registered User

I am working on a program that used CodeDom to create a class file, I've
just about got to the stage where I can produce either a C# or VB file so
I am making progress.

I have made myself a CodeDom Helper class to cut down on code repetition
but I'm struggling to come up with descriptive names for the helper
functions.
Be as verbose as you feel you need to be.

- snip -
I am weak on the technical expressions used in C# / NET so if anybody can
suggest a consistent naming convention or NET guidelines on naming it
would be very helpful :)

Standards are great, that is why there are so many of them. When
working without a standardized naming convention excess verbosity
becomes both the standard and explicit documentation.

regards
A.G.
 
A

Arne Vajhøj

I am working on a program that used CodeDom to create a class file, I've
just about got to the stage where I can produce either a C# or VB file
so I am making progress.

I have made myself a CodeDom Helper class to cut down on code repetition
but I'm struggling to come up with descriptive names for the helper
functions.

As an example I have helper functions that produce the following
CodeExpressionStatements:

dbConnection.Open();
dbDataAdapter.Fill(dataSet, m_TableName);
GetSingleRecordDetails(selectString, alpha01Data);

Calling them all "CreateCodeExpressionStatement" isn't helpful when I'm
struggling to learn CodeDom.

I am thinking along the lines of Createxxx but I don't know what they
are technically called apart from "statements" (and I'm not even sure
that is correct).
GenerateCodeSomethingThatDescribeWhatTheGeneratedCodeDoes

I am weak on the technical expressions used in C# / NET so if anybody
can suggest a consistent naming convention or NET guidelines on naming
it would be very helpful :)

The general naming rules does not cover code generation specifically.

Arne
 
J

Jeff Gaines

On 23/03/2011 in message <[email protected]> Arne
Vajhøj wrote:

[snipped]

Many thanks for all the replies :)
GenerateCodeSomethingThatDescribeWhatTheGeneratedCodeDoes

I'll work along the above lines, it will make it easier to find the
specific function I need from my helper class.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top