Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Quick Newbie question about naming conventions

Quick Newbie question about naming conventions

Scheduled Pinned Locked Moved C / C++ / MFC
questioncsharpc++visual-studio
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Megidolaon
    wrote on last edited by
    #1

    Hi, I'm trying to get into C++ and I was wondering about the class and method names. I'm hailing from C#, where everything is written fully and all names are immediately comprehensible. However, it seems in C++ mostly abbreviations are being used. Is there any good reason for this or is that just because C++ has been around since long before Intellisense, so it's just a matter of convenience? Thanks.

    _ N M 3 Replies Last reply
    0
    • M Megidolaon

      Hi, I'm trying to get into C++ and I was wondering about the class and method names. I'm hailing from C#, where everything is written fully and all names are immediately comprehensible. However, it seems in C++ mostly abbreviations are being used. Is there any good reason for this or is that just because C++ has been around since long before Intellisense, so it's just a matter of convenience? Thanks.

      _ Offline
      _ Offline
      _AnsHUMAN_
      wrote on last edited by
      #2

      ya! it's only a matter of convenience to avoid long variable names and distinguishing them from being local or member variables. for example there is oneHungarian Notation[^] that can be followed. If you feel that the people who follow you, should understand the code by just having a glimpse at it, it would be better to use a notation. on an ending note - > If you use your own:DOCUMENT IT VERY CAREFULLY.

      Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

      1 Reply Last reply
      0
      • M Megidolaon

        Hi, I'm trying to get into C++ and I was wondering about the class and method names. I'm hailing from C#, where everything is written fully and all names are immediately comprehensible. However, it seems in C++ mostly abbreviations are being used. Is there any good reason for this or is that just because C++ has been around since long before Intellisense, so it's just a matter of convenience? Thanks.

        N Offline
        N Offline
        not_in_use
        wrote on last edited by
        #3

        It's not specific to C++. Different projects use different naming conventions, so depending on whose code you look at it will vary greatly. It's really a matter of preference. The C++ standard library comes all in one single namespace called std that deals with basic stuff like string manipulation, lists etc., whereas the .NET API pretty much wraps the entire OS API. The C++ library can get away with much shorter names since its feature set is very limited and defined, whereas .NET needs means to organize all that stuff, and it does so by using tons of nested namespaces, which results in much longer symbol names overall. I agree that most STL class names are not necessarily immediatly comprehensible and are thus not really a good example to follow in terms of naming conventions. Nor are the MFC, which were conceived before design patterns, templates, and namespaces had reached the real world, plus they are massively influenced by the Windows API naming conventions and are overall much closer to a C library than to a modern C++ library. My advice is to be as verbose as you need to be but as short as you can be without sacrificing clarity. The time you save when you use cryptic abbreviations is far less than the time it is going to cost when someone has to fix a bug in that code, or even just understand what it does. If you want an example of what readable C++ code with good coding conventions and modern design looks like, check out the open source FreeCloth project. Reading through that code really changed the way I had been thinking about a few things. Hope this helps, Peter

        1 Reply Last reply
        0
        • M Megidolaon

          Hi, I'm trying to get into C++ and I was wondering about the class and method names. I'm hailing from C#, where everything is written fully and all names are immediately comprehensible. However, it seems in C++ mostly abbreviations are being used. Is there any good reason for this or is that just because C++ has been around since long before Intellisense, so it's just a matter of convenience? Thanks.

          M Offline
          M Offline
          Megidolaon
          wrote on last edited by
          #4

          Thanks!

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups