Casing when coding

One of the first developer jobs I had was programming in VB6 for a small business down the road. Up to that point I had been casually coding at school but this was my first exposure to “professional” development. To get the job I had to do a weeks worth of work and then get it reviewed by the boss. I thought I did a pretty good job until I got his review back and he criticized everything – in particular he ripped apart my naming conventions (or lack of them).

In memory of this event I thought I would post briefly on naming conventions / terminology. We have come a long way since the vb6 days.

Pascal Case – if you ever hear this it means that when forming a name of something, if we do it in Pascal Case we capitalize the first character of each “word”. Keeping in mind that a method name could be formed by many word. The following are examples…

  • MethodName
  • FunctionThatReturnsAValue
  • MyNameIsMark

Camel Case – think of this as looking like a camel… it starts off small and then has bumps in it. The convention is to capitalize the first character of each word except the first word. The following are examples

  • methodName
  • functionThatReturnsAValue
  • myNameIsMark

Screaming CAPS – a favourite of mine in the vb6 days of constants. Everything goes in Upper Case usually with underscores to identify different words. An example of this would be

  • METHOD_NAME
  • FUNCTION_THAT_RETURNS_A_VALUE
  • MY_NAME_IS_MARK
This article is part of the GWB Archives. Original Author: MarkPearl

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.