NamingConventions

Latest

  • Dev Juice: What's the deal with k for constants?

    by 
    Erica Sadun
    Erica Sadun
    08.05.2011

    Dear Dev Juice, What's the deal with the k in #define kFilename. Is it German? Does it stand for konstant? What gives? Pure Fusion Dear Pure Fusion, The k prefix seems to originate in a naming system called Hungarian Notation, developed by Charles Simonyi at Xerox PARC. The idea behind this system is that the name of a variable should reflect its semantics. Wikipedia offers a sense of these naming conventions, such as arru8NumberList, meaning the variable is an array of unsigned 8-bit integers. Apple follows a similar but more practical convention. Like the original Hungarian Notation, it encodes opaque types, but it does so with a distinctly Apple spin and without all the silly made up non-obvious naming bits like "arru8". As you've already noted, Apple's "k" prefix indicates constants. Typically, the k prefix is followed by type, followed by a more general indication of the item's use. A typical Apple symbol, such as kCFCharacterSetWhitespace can easily be broken down as k (constant) + CFCharacterSet (opaque type) + Whitespace (unique role). Hungarian Notation's goal of encoding semantics into symbols has gone in and out of fashion over time. Some devs love it, others hate it. Most fall in the middle, as does Apple's usage. Being able to instantly identify the role of a symbol as a constant is a win, but a mindless adherence to pedantry in unnatural naming can become a stumbling block. Fortunately, Apple seems to have chosen its path well and its naming schemes are easy to follow while remaining semantically rich. Happy developing!

  • Forum Post of the Day: Mega Super Giga Mana potions

    by 
    Mike Schramm
    Mike Schramm
    08.31.2007

    Bregdark is worried about Blizzard-- first we had Health and Mana potions, but those weren't enough. Then we had Superior Mana potions, Major mana potions, and now in Outland, we're chugging Super Mana potions. But where can Blizzard go from here?There are quite a few good suggestions in the thread: Mega Mana potions, Super Duper potions, Totally Rad Mana potions, and the fan favorite "Sexy Time Mana potions." Of course, there's always got to be someone raining on the party, so Barnes (wait a minute) pipes up with a ton of words Blizzard could actually use, and then some:"Ultra, Hyper, Mega, Ultimate (probably ill-advised to use this one), Magnificent, Marvelous, Superb, Grand, Prime, Splendid, Sublime, Exquisite, Great, Perfect (also not recommended), Supreme, Terrific, Transcendent, Copious, Prodigious, Primal (re-use). That's excluding fantasy intensifiers or superlatives such as "Fel", "Nether", "Draenic", etc."So yes, no need to worry-- Blizzard's got lots of options to choose from. But am I the only one that feels just a little taken aback at the thought that we're going to get yet another expansion that has nothing but bigger widgets. Yes, of course, the point of every RPG, MMO or otherwise, is to go out there and get more health and a bigger sword, but playing the same game with a fresh coat of new paint will get old after a while, won't it?