Instead of using a parallel array to store values, one should consider converting this into an array of objects. Briefly, list two challenges one might encounter when using parallel arrays that are solved when using an array of objects.
Parallel arrays are an implicit data structure that uses two or more arrays to represent a singular array of records. Using Parallel array is a bad idea as it makes the code more fragile.
Whenever we want to add a new field , we need to add new array. If we want to pass the whole entity to another function, we need to pull all the items.
Secondly, in case of performing swap, we need to swap all the array pairs individually.
These can be overcome by using Array of objects.
As name implies Array of object stores the objects in array. An object can be represented as a single record in memory, so for multiple records array of objects must be created. The array not only hold the objects but can hold references to the object.
Get Answers For Free
Most questions answered within 1 hours.