naming conventions?

This is a discussion on naming conventions? within the C Programming forums, part of the General Programming Boards category; Originally Posted by laserlight Generally, I do not have difficulty differentiating between syntactic elements after viewing them in context, regardless ...

  1. #31
    Banned
    Join Date
    Nov 2007
    Posts
    678
    Quote Originally Posted by laserlight View Post
    Generally, I do not have difficulty differentiating between syntactic elements after viewing them in context, regardless of the naming convention. If you cannot do that... it would be tough to be a programmer, or even a reader of novels.


    Recall that C++ has function pointers. Aside from that, I find that it helps me mentally remember the functions and variables. As a secondary reason, it increases the number of possible names in the given scope.


    Macro names do not obey the rules of scope. Consequently, Stroustrup, Meyers, Sutter and Alexandrescu all recommend reserving fully capitalised names for macros.


    I do not see a problem since named constants are usually within namespace or class scope.
    Points taken.

  2. #32
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,007
    Quote Originally Posted by manav View Post
    Well zacs and laser are out of it already. Not to stretch any further myself. And Elysia has good points also.

    I would just sum up, saying, I find it rather pointless to worry too much, about naming schemes. For me, a better naming scheme is, in which, identifier names are closer to their real worlds names.

    eg:
    humansCount / humans_count is easier to read
    than
    nHumansCount or m_nHumansCount etc.
    I think you were the one who started the argument by commanding to use a style and saying that you must not use "MyName" because it's arrogant (in your view).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #33
    Banned
    Join Date
    Nov 2007
    Posts
    678
    Quote Originally Posted by Elysia View Post
    I think you were the one who started the argument by commanding to use a style and saying that you must not use "MyName" because it's arrogant (in your view).
    My post is unedited as yet. Show me the word "must".

    People do not change their strongly guarded opinions/habits/nature etc. So, I am not trying to persuade everybody into using my type of coding style. You are doing this. Including in your own signature. Saying to all and sundry. Use int main. Don't use scanf.

  4. #34
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,007
    Quote Originally Posted by manav View Post
    My post is unedited as yet. Show me the word "must".
    I did not say it contains must. But you worded it like a command, ie - similar to "must".

    You are doing this. Including in your own signature. Saying to all and sundry. Use int main. Don't use scanf.
    There is a difference. Void main is undefined, non-standard, or in other words, it's not C OR C++. It's "special C/C++" - something that does not exist and should never be used.
    Scanf can read strings, but you must do it right or you can very easily get buffer overruns. And why is that bad? Because it's a security issue plus it's undefined - anything can happen, including corrupt data in the program or crashes. Don't come to me complaining "why isn't this working?!" when you have a buffer overrun somewhere that might overwrite your variables.

    Coding styles are different. They are not required by the language or undefined.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #35
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,266
    My post is unedited as yet. Show me the word "must".
    There is no need, since those statements were clearly instructions. In other words, "must" is inherent in the context.

    People do not change their strongly guarded opinions/habits/nature etc. So, I am not trying to persuade everybody into using my type of coding style.
    Yes, but in your original statement, it is quite clear that you were not trying to persuade everybody, but was commanding the original poster to use the given style. That is what Elysia is getting at.

    You are doing this. Including in your own signature. Saying to all and sundry. Use int main. Don't use scanf.
    Elysia's signature does not tell people to use Elysia's style, but to follow the standards and to avoid specific functions. There are objective reasons to avoid those functions, unlike your subjective "arrogant" reason.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #36
    Banned
    Join Date
    Nov 2007
    Posts
    678
    Quote Originally Posted by laserlight View Post
    There is no need, since those statements were clearly instructions. In other words, "must" is inherent in the context.
    I do not think so. Otherwise I would not need to prove Elysia wrong.

    Yes, but in your original statement, it is quite clear that you were not trying to persuade everybody, but was commanding the original poster to use the given style. That is what Elysia is getting at.
    Commanding!? Oh come on please! You are not a native English speaker I think.
    Me neither.

    Should/Ought to - is used as a suggestive of helpful/useful
    Must - is used for compelling/forcing making it a rule

    I did not use should/ought to. Beacuse I did not think my suggestion were more useful, than any other consistent guidelines.

    Must I can never use. I can't force any body to do any thing at all.

    I just wrote in plain declarative sentences without any kind of obligatory means at all.
    No I am not good at English. Spoken. Written. Or Grammar.

    Elysia's signature does not tell people to use Elysia's style, but to follow the standards and to avoid specific functions. There are objective reasons to avoid those functions, unlike your subjective "arrogant" reason.
    Standard must have vaild reasons to allow compiler extensions. C++ does not even need an explicit return from a function defined as returning int. I am talking about main(). Why bother.


    But in my separate, personal, not related to this discussion, opinion, Elysia's signature is not a think to poke a stick at. I am missing the "times quoted" count though.

  7. #37
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,007
    Quote Originally Posted by manav View Post
    I do not think so. Otherwise I would not need to prove Elysia wrong.

    Commanding!? Oh come on please! You are not a native English speaker I think.
    Me neither.

    Should/Ought to - is used as a suggestive of helpful/useful
    Must - is used for compelling/forcing making it a rule

    I did not use should/ought to. Beacuse I did not think my suggestion were more useful, than any other consistent guidelines.

    Must I can never use. I can't force any body to do any thing at all.

    I just wrote in plain declarative sentences without any kind of obligatory means at all.
    No I am not good at English. Spoken. Written. Or Grammar.
    "Do not",
    "always",
    "name them"
    Tell me how those are not commanding.
    I think you need to brush up on your english skills. Though I may not be native english, I know well enough that it sounds commanding.
    Post that somewhere else and see how people reacts.
    It is commanding, because you failed to specify that it was a suggestion or guideline.

    Standard must have vaild reasons to allow compiler extensions. C++ does not even need an explicit return from a function defined as returning int. I am talking about main(). Why bother.
    No, you're wrong. That's C. C++ does not support any implicit returns.
    Does the standard allow extensions? The standard can neither approve nor disapprove extensions. That's something only the compiler makers have power over.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #38
    Banned
    Join Date
    Nov 2007
    Posts
    678
    Quote Originally Posted by Elysia View Post
    No, you're wrong. That's C. C++ does not support any implicit returns.
    Does the standard allow extensions? The standard can neither approve nor disapprove extensions. That's something only the compiler makers have power over.
    Just a sec, I am talking about return 0; being optional in C++ main.

  9. #39
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,007
    Ah yes, that. But that's only optional in main and no other function in C++.
    (Although why they chose it to be optional for main, I dunno, but as it happens, I abuse it sometimes )
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #40
    Banned
    Join Date
    Nov 2007
    Posts
    678
    Quote Originally Posted by Elysia View Post
    "Do not",
    "always",
    "name them"
    Tell me how those are not commanding.
    I think you need to brush up on your english skills. Though I may not be native english, I know well enough that it sounds commanding.
    Post that somewhere else and see how people reacts.
    It is commanding, because you failed to specify that it was a suggestion or guideline.
    Although I was never commanding anybody for anything. But now I reread all the other replies up to my post. And see one difference in those and my reply. All of them used First Person Pronouns to specify their suggestions. I did not use any Pronoun at all. And most people are interpreting my sentences as being used Second Person Pronoun, and they think the Second Person is OP and the sentences are commands to him.

    What a Fish!
    But I have already told you all, I am also not a Native English. And I never got good marks in English Grammar.

    Does the standard allow extensions? The standard can neither approve nor disapprove extensions. That's something only the compiler makers have power over.
    What a pity!

  11. #41
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,007
    Quote Originally Posted by manav View Post
    Although I was never commanding anybody for anything. But now I reread all the other replies up to my post. And see one difference in those and my reply. All of them used First Person Pronouns to specify their suggestions. I did not use any Pronoun at all.
    What they did was mostly cite what their individual preference was, using it as an example of a suggestion.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  12. #42
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by manav View Post
    Commanding!? Oh come on please! You are not a native English speaker I think.
    Me neither.
    Well I am a native English speaker, and it sure sounded like the 5 Commandments of manav to me.

  13. #43
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    Manav is right in a way except, Manav, you must realize the informal nature of the board and the internet in general. You are quite right if you say you aren't a native english speaker because what you learn formally in english as a second language is not fully applicable on the internet.

    If you were writing a formal speech I would agree with you, but remember it's also the way in which you present what you are saying. In your case it's like you wrote a law on C

    The internet english is almost like a secondary vulgar. So if you use the word 'should' or say 'do this', it's taken as a command not a suggestion. To me it sounded like you were telling people they 'must' do something even though you didn't explicitly use the word 'must'.

    Remember, it's also the tone that sets what you imply, not just the words in itself.

    Who cares now, let's all get over this.
    Last edited by JFonseka; 05-26-2008 at 09:21 AM.
    =========================================
    Everytime you segfault, you murder some part of the world

  14. #44
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Well I think it was these words that made it sound like commandments:
    Quote Originally Posted by manav
    Do not use this kind of variable names ...
    Always use this kind of variable names ...

  15. #45
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,007
    True, the last two lines sounded less commanding, but commanding nevertheless.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Forcing code conventions
    By audinue in forum Tech Board
    Replies: 28
    Last Post: 03-31-2009, 09:46 AM
  2. standard naming conventions?
    By h_howee in forum C++ Programming
    Replies: 8
    Last Post: 11-10-2007, 11:53 PM
  3. Naming variables, functions...
    By Ariod in forum Tech Board
    Replies: 9
    Last Post: 08-19-2003, 01:17 PM
  4. C++ conventions
    By Unregistered in forum C++ Programming
    Replies: 0
    Last Post: 03-14-2002, 08:15 AM
  5. C++ and Program Version Naming
    By kuphryn in forum C++ Programming
    Replies: 2
    Last Post: 11-27-2001, 11:19 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21