Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Hungarian, Camel, Snake and Kebab - variable naming conventions

In my program, I'm going to use a variable to hold the number of people (in a group or in a category) perhaps. What should I call that variable?

There are a whole lot of different conventions available to you - here are some I have used / come across

Camel case: numberOfPeople
A series of words, with each intermeidiate word started with a capital letter. Called "Camel Case" because the capital letters make it look like the humps of a camel.

Kebab case: number-of-people
Hypehated words - like chunks of meat or vegatables on a kebab skewer. Note that cannot case only works in a gew languahes such as Tcl and Perl 6, as the minus sign most usually is the subtraction operator.

Snake case: number_of_people
Words separated with underscores - the word snakes along past the underscores. Unlike Kebab case which is of limited (language) use, you can use Snake Case with most modern languages.

Hungarian (Systems) notation: iNumberOfPeople
In hungarian notation, you preceed the variable name with an additional character or characters to indicate the type of variable - in Hungarian Systems notation, that's an indiction of the internal data type such as i for Integer. You can see the developemnt of Hungarin Systems Notation from old Fortran conventions where variable names starting with I J K L M or N were integers, and others were floats.

Hungarian (Apps)) notation: cntNumberOfPeople
Prefixing the name of the variable with character(s) to indicate the use make of a variable within the application - in my example, I have used cnt to incicate it's a counter ... and in my old Fortran programs you'll find "JPxxxxx" all over th eplace to indicate an integer pointer.

Shortening and English / American
Should you use init, initialise or initialize as the name for a piece of setup code? Some languages will force a built in standard on you for such specials, but I strongly recommend that you use your own convention (for your organisation) rather than mixing them up. There's nothing quite so frustrating as typing to debug a piece of code where sometimes the word colour is used, and at other times the word is color.

Although I've not given you any particular recommentation between camel and snake case, nor whethe to use Hungarian prefixes, I am going to strongly recommend that you use one of the two - with additonal hungarian prefixes if you wish. The consistent use of such a notation makes much lighter work for the maintenace programmer, and the people of Pen Island will tell you they have been misread and misunderstood as to what they're about when their name's been written out without separators in a single case ...
(written 2016-01-03)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
P600 - Perl 6
  [582] DWIM and AWWO - (2006-01-30)
  [2816] Intelligent Matching in Perl - (2010-06-18)
  [4604] Perl - version 6 - official version launched at Christmas - (2016-01-02)
  [4605] Hello World - in Perl 6 - (2016-01-02)
  [4606] Using Perl 6 to analyse and report on data - (2016-01-02)
  [4607] Classes and object - first steps in Perl 6 - (2016-01-02)
  [4608] Introspecion in Perl 6 - (2016-01-02)
  [4609] Mapping an array / list without a loop - how to do it in Perl 6 - (2016-01-03)
  [4610] Sorting by key or by comparator - Perl 6 - (2016-01-03)
  [4620] Perl 6 - a Practical Extraction and Reporting example! - (2016-01-11)

Q101 - Object Orientation and General technical topics - Programming Principles
  [2001] I have not programmed before, and need to learn - (2009-01-19)
  [2022] Pre and post increment - the ++ operator - (2009-02-03)
  [2228] Where do I start when writing a program? - (2009-06-11)
  [2310] Learning to write high quality code in Lua - (2009-07-30)
  [2327] Planning! - (2009-08-08)
  [2415] Variable names like i and j - why? - (2009-09-22)
  [2510] The music of the stock market - (2009-11-22)
  [2550] Do not copy and paste code - there are much better ways - (2009-12-26)
  [2586] And and Or illustrated by locks - (2010-01-17)
  [2737] Improving your function calls (APIs) - General and PHP - (2010-04-24)
  [2769] Easy - but for whom? - (2010-05-18)
  [2878] Program for reliability and efficiency - do not duplicate, but rather share and re-use - (2010-07-19)
  [2915] Looking up a value by key - associative arrays / Hashes / Dictionaries - (2010-08-11)
  [2964] An introduction to file handling in programs - buffering, standard in and out, and file handles - (2010-09-21)
  [3026] Coding efficiency - do not repeat yourself! - (2010-11-02)
  [3456] Stepping stones - early coding, and writing re-usable code quickly - (2011-09-24)
  [3542] What order are operations performed in, in a Perl expression? - (2011-12-07)
  [3548] Dark mornings, dog update, and Python and Lua courses before Christmas - (2011-12-10)
  [3551] Some terms used in programming (Biased towards Python) - (2011-12-12)
  [3673] Object oriented or structured - a comparison in Python. Also writing clean regular expressions - (2012-03-26)
  [3878] From Structured to Object Oriented Programming. - (2012-10-02)
  [3928] Storing your intermediate data - what format should you you choose? - (2012-11-20)
  [3954] Lesson 1 in programing - write clean, reuseable and maintainable tidy code - (2012-12-16)
  [4003] Web and console - same principle, same code - Ruby example - (2013-02-14)
  [4061] Seamless, integrated IT - we have a long way to go! - (2013-04-11)
  [4090] Test Driven Development in Python - Customer Comes First - (2013-05-16)
  [4118] We not only teach PHP and Python - we teach good PHP and Python Practice! - (2013-06-18)
  [4153] Rooms available tonight - how to code an algorithm from first principles - (2013-08-19)
  [4206] Writing the perfect program in Tcl? - (2013-11-13)
  [4325] Learning to program - what are algorithms and design patterns? - (2014-11-22)
  [4632] Remember to ask the question before you listen for the answer - (2016-01-26)
  [4645] What are callbacks? Why use them? An example in Python - (2016-02-11)

P222 - Perl - Programming Efficiency and Style
  [743] How to debug a Perl program - (2006-06-04)
  [1181] Good Programming practise - where to initialise variables - (2007-05-09)
  [2399] Firefighting with Perl - (2009-09-07)
  [2657] Want to do a big batch edit? Nothing beats Perl! - (2010-03-01)
  [2688] Security considerations in programming - what do we teach? - (2010-03-22)


Back to
Sorting by key or by comparator - Perl 6
Previous and next
or
Horse's mouth home
Forward to
TransWilts - robust these days - no longer the first service to be cancelled
Some other Articles
Questions for First (West of England)
PC Plod - alive and scaremongering in Wiltshire?
Our best hotel customers help us ... to help them ... be our best customers.
TransWilts - robust these days - no longer the first service to be cancelled
Hungarian, Camel, Snake and Kebab - variable naming conventions
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.info/mouth/4611_Hun ... tions.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb