2

I have an array which contains another array

Would I notate it this way?
pseudocode:

rgrgTest = newArray(2)

What if the array contains i.e. a struct?
pseudocode:

rggrTest = newArray(2).newStruct()

Or this way i.e. if I want to classify the data types of the struct?
pseudocode:

rggrlstlTest = newArray(2).newStruct(int id, str desc, int value)
Jason Aller
  • 3,541
  • 28
  • 38
  • 38
mrt181
  • 5,080
  • 8
  • 66
  • 86
  • 2
    One of the many reasons most people avoid Hungarian notation... – David M Jul 02 '09 at 10:28
  • Are you asking because you are required to use hungarian notation (due to coding guidelines or similar), or because you're suffering under the mistaken belief that hungarian notation is a good thing? – jalf Jul 02 '09 at 10:29
  • rggrTest doesn't say much about what the variable represents. – Skurmedel Jul 02 '09 at 10:31

1 Answers1

1

The "right" way is dictated by your coding standard and list of prefixes.

The order of prefixes typically represents the order in which the things they represent would be read out in your native language.

Use single-letter prefixes (or single letter + numbers for integer types) to stop the names getting too unmanageable, so maybe 'u8' for 1-byte unsigned integer, 'a' for array, 'r' for struct (as in "record").

Don't include the elements of the struct within the prefix; that just gets too unwieldy.

So to give some examples:

au8My1DArray[]      // A 1-dimensional array of unsigned 1-byte integers
aau8My2dArray[][]   // A 2-dimensionnal array of unsigned 1-byte integers
arMyArray[]         // A 1-dimensional array of structs

Note: This is Systems Hungarian notation, and it appears to be very unpopular with Stack Overflow users, but don't be put off! It is still common in embedded software.

See also the Wikipedia article on the subject.

Steve Melnikoff
  • 2,620
  • 1
  • 22
  • 24