mardi 19 décembre 2017

Design pattern for casting rows of Object table

I have an issue with a project. I would like to know if there is a Design Pattern for this case:

I'm retrieving from database a row of objects with different types of data

Object[] userInformationsRow = getUserInformationsFromDataBase();
int idColumn = 0;
int nameColumn = 1;
int birthDateColumn = 2;
// 
Integer idUser = (Integer)userInformationsRow[idColumn];
String nameUser = (String)userInformationsRow[nameColumn];
Date birthDateUser = (Date)userInformationsRow[birthDateColumn];

There is an another way to develop that kind of code which seems to me verry long to code and difficult to change in the future.

Aucun commentaire:

Enregistrer un commentaire