-2

An anonymous type can be thought of as a "Set Once" Object type, whereas an plain old Object or Variant can be set many times. An object or variant tends to be short lived, while an anonymous type is expected to live longer, making it important to communicate intent.

What naming convention do you use to communicate intent when using anonymous types?

I've searched "Naming Convention" questions and the answer is still elusive with regard to Anonymous Types which are different from objects or variants.

Hungarian Notation is like a giant nose pimple on prom night, so probably nothing useful there.

Since an anonymous type cannot be changed once it is instantiated, shouldn't be named according to its intent?

jjnguy
  • 136,852
  • 53
  • 295
  • 323
CLaRGe
  • 1,821
  • 1
  • 25
  • 22
  • 2
    I don't get it... Naming an anonymous type? Isn't it the definition of anonymous not to have a name? – Mehrdad Afshari Apr 22 '09 at 17:45
  • He's talking about the object that needs a name, not the anonymous type itself (i.e., the interface or abstract class that's being implemented). – Bob Cross Apr 22 '09 at 17:57
  • Yeah, this thoroughly confused me too. Seems somewhat paradoxical... Perhaps the particular concept to which refer as "anonymous types" isn't the same as what I'm thinking (i.e. C# anonymous types). – Noldorin Apr 22 '09 at 17:59
  • Surely you would name the *variables* of anonymous types just like you would any other variables? – Noldorin Apr 22 '09 at 18:01
  • -1: "Naming" + "Anonymous" == 0 – John Saunders Jul 17 '09 at 12:54
  • You got to mention the language when you are talking about naming conventions. – nawfal Nov 06 '16 at 08:27

3 Answers3

2

When I use anonymous types in Java Swing apps I use them in the following fashion:

private ActionListener [actionPerforming]Action = new ActionListener(){ /*Stuff Here*/};

That way it is clear what the variable is doing.

jjnguy
  • 136,852
  • 53
  • 295
  • 323
0

Well, it may seem somewhat of an oxymoron but shouldn't you use whatever naming convention means the most to you, as the developer? Whatever appeals to you, makes you most comfortable..

Personally, I used to favour Hungarian Notation but I was recently converted to the camelCase (Microsoft?) method by the elegance of it. It's a matter of personal choice, really.

GenericMeatUnit
  • 477
  • 4
  • 9
0

Check out Hungarian Notation naming convention. http://en.wikipedia.org/wiki/Hungarian_notation

nSize : integer (systems) or count (application)
iSize : integer (systems) or index (application)    
bBusy : boolean
chInitial : char
cApples : count of items
dwLightYears : double word (systems)
fBusy : boolean (flag)
fpPrice: floating-point
Yada
  • 30,349
  • 24
  • 103
  • 144