views:

82

answers:

1

i have an array wich 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)
+1  A: 

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
I abhor this naming convention, but +1 anyway for helpfulness :)
Skurmedel