I've been running into code (new code) that uses what I call 'Parallel Arrays' or Lists. Meaning there are 2 arrays that contain related data and are linked by their position (index) in the array.
I consider this confusing and prone to all sorts of errors. The solution I normally propose is to create an object called Company
with the fields CompanyId and CompanyName.
An very real example:
List<string> companyNames;
List<int> companyIds;
//...They get populated somewhere and we then process
for(var i=0; i<companyNames.Count; i++)
{
UpdateCompanyName(companyIds[i],companyNames[i]);
}
Are these parallel arrays considered bad practice?