I'm experimenting with a naming convention I've devised and am seeking opinion. It involves the use of an "As" infix, and at this point I am envisioning it in the context of JavaScript, C# and C++ coding to assist with clarity of data format/contract when dealing with conversions or multiple representations of the same inherent data or object.
Examples:
// ex 1. receive and convert user input.
string userInput = "123";
float userInputAsFloat = float.Parse(userInput);
int userInputAsInt = (int)Math.Round(userInputAsFloat);
// ex 2. prepare an object for json transport.
Dictionary<string,object> packet = new Dictionary<string,object>();
string packetAsJson = packet.ToJson();
// ex 3. interface with a component from various angles.
IUnknown foo = MyObjectFactory.CreateFoo();
IVisualizer fooAsVisualizer = (IVisualizer)foo;
ILocator fooAsLocator = (ILocator)foo;
Thoughts for/against? Does this convention have a name?
submitSignupDetails
is pretty self explanatory, I don't needbtn
in front of it.txt_username
is sort of OK, but I would prefer justuserNameInput
, for full disambiguation.