Skip to main content
added 59 characters in body
Source Link
Michel Keijzers
  • 13k
  • 7
  • 42
  • 59

I fully agree with Edgar Bonet.

My opinion is keeping a 'matrix' is better, or actually one array (of structs), where each array elements stores all information for one measurement (which is stored inside one struct). This has some benefits:

  • Data of one measurement is consecutive in memory, so you can easily transfer it (to some external memory or sending it). It's exact one struct (and you can use sizeof(struct_item) to know how many bytes you have to transfer.

  • It's good practice in general to keep information together, creating 5 always-equal length arrays seems strange.

  • If for some reason you want to make a single array dynamic or change it to a ring buffer for example, you can easily add/remove items (instead of dynamically changing 5 arrays). There is also one benefit about having separate arrays (where each array stores one type

  • Locality of information, like an acceleration or timestamp: when you have a functionchange (especially in another class) that only needs onesee comments of them, you can specifically send that array (or pointerKwasmich/referenceDuncanC), so the other information is hidden from that function.

There is also one benefit about having separate arrays (where each array stores one type of information, like an acceleration or timestamp: when you have a function (especially in another class) that only needs one of them, you can specifically send that array (or pointer/reference), so the other information is hidden from that function.

I fully agree with Edgar Bonet.

My opinion is keeping a 'matrix' is better, or actually one array (of structs), where each array elements stores all information for one measurement (which is stored inside one struct). This has some benefits:

  • Data of one measurement is consecutive in memory, so you can easily transfer it (to some external memory or sending it). It's exact one struct (and you can use sizeof(struct_item) to know how many bytes you have to transfer.

  • It's good practice in general to keep information together, creating 5 always-equal length arrays seems strange.

  • If for some reason you want to make a single array dynamic or change it to a ring buffer for example, you can easily add/remove items (instead of dynamically changing 5 arrays). There is also one benefit about having separate arrays (where each array stores one type of information, like an acceleration or timestamp: when you have a function (especially in another class) that only needs one of them, you can specifically send that array (or pointer/reference), so the other information is hidden from that function.

I fully agree with Edgar Bonet.

My opinion is keeping a 'matrix' is better, or actually one array (of structs), where each array elements stores all information for one measurement (which is stored inside one struct). This has some benefits:

  • Data of one measurement is consecutive in memory, so you can easily transfer it (to some external memory or sending it). It's exact one struct (and you can use sizeof(struct_item) to know how many bytes you have to transfer.

  • It's good practice in general to keep information together, creating 5 always-equal length arrays seems strange.

  • If for some reason you want to make a single array dynamic or change it to a ring buffer for example, you can easily add/remove items (instead of dynamically changing 5 arrays).

  • Locality of change (see comments of Kwasmich/DuncanC)

There is also one benefit about having separate arrays (where each array stores one type of information, like an acceleration or timestamp: when you have a function (especially in another class) that only needs one of them, you can specifically send that array (or pointer/reference), so the other information is hidden from that function.

added 496 characters in body
Source Link
Michel Keijzers
  • 13k
  • 7
  • 42
  • 59

I fully agree with Edgar Bonet.

My opinion is keeping a 'matrix' is better, or actually one array (of structs), where each array elements stores all information for one measurement (which is stored inside one struct). This has some benefits:

  • Data of one measurement is consecutive in memory, so you can easily transfer it (to some external memory or sending it).

    Data of one measurement is consecutive in memory, so you can easily transfer it (to some external memory or sending it). It's exact one struct (and you can use sizeof(struct_item) to know how many bytes you have to transfer.

  • It's good practice in general to keep information together, creating 5 always-equal length arrays seems strange.

    It's good practice in general to keep information together, creating 5 always-equal length arrays seems strange.

  • If for some reason you want to make a single array dynamic or change it to a ring buffer for example, you can easily add/remove items (instead of dynamically changing 5 arrays).

    If for some reason you want to make a single array dynamic or change it to a ring buffer for example, you can easily add/remove items (instead of dynamically changing 5 arrays). There is also one benefit about having separate arrays (where each array stores one type of information, like an acceleration or timestamp: when you have a function (especially in another class) that only needs one of them, you can specifically send that array (or pointer/reference), so the other information is hidden from that function.

I fully agree with Edgar Bonet.

My opinion is keeping a 'matrix' is better, or actually one array, where each array elements stores all information for one measurement. This has some benefits:

  • Data of one measurement is consecutive in memory, so you can easily transfer it (to some external memory or sending it).
  • It's good practice in general to keep information together, creating 5 always-equal length arrays seems strange.
  • If for some reason you want to make a single array dynamic or change it to a ring buffer for example, you can easily add/remove items (instead of dynamically changing 5 arrays).

I fully agree with Edgar Bonet.

My opinion is keeping a 'matrix' is better, or actually one array (of structs), where each array elements stores all information for one measurement (which is stored inside one struct). This has some benefits:

  • Data of one measurement is consecutive in memory, so you can easily transfer it (to some external memory or sending it). It's exact one struct (and you can use sizeof(struct_item) to know how many bytes you have to transfer.

  • It's good practice in general to keep information together, creating 5 always-equal length arrays seems strange.

  • If for some reason you want to make a single array dynamic or change it to a ring buffer for example, you can easily add/remove items (instead of dynamically changing 5 arrays). There is also one benefit about having separate arrays (where each array stores one type of information, like an acceleration or timestamp: when you have a function (especially in another class) that only needs one of them, you can specifically send that array (or pointer/reference), so the other information is hidden from that function.

Source Link
Michel Keijzers
  • 13k
  • 7
  • 42
  • 59

I fully agree with Edgar Bonet.

My opinion is keeping a 'matrix' is better, or actually one array, where each array elements stores all information for one measurement. This has some benefits:

  • Data of one measurement is consecutive in memory, so you can easily transfer it (to some external memory or sending it).
  • It's good practice in general to keep information together, creating 5 always-equal length arrays seems strange.
  • If for some reason you want to make a single array dynamic or change it to a ring buffer for example, you can easily add/remove items (instead of dynamically changing 5 arrays).