Hi Guys,
I am using the VALUE OBJECT pattern which is mentioned in Andrew's book, but I am stuck with a question.
In the instruction of the assignment, in the header information part, it includes the DB schema as well, and all of the field names and length can be found here.
After I read every Record information, I need to populate all the field values into the OBJECT,in my Case, my Record Object is called Contract.And I will populate the information like this(similar to Andrew's book's example)
I will use the Length which grabbed from the header information part.
String name=fieldReader.readField(****,****);
String location=fieldReader.readField(****,****);
String spec=fieldReader.readField(****,****);
...
...
Then : Contract contract=new Contract(name,location,spec,.....)
But if I do this, I have to assume that I have known all of the field names already;I am just wonderring whether it is ok to do that.
Otherwise I have to put a HashMap into the Record Object, then put all the field names and field values into the HashMap. This way will be more generic, then it can be used in future even the DB structure is changed; But it is not tat convenient anyway; and will be weird for a DB application.
Is there anyone using this the OBJECT VALUE pattern? how do you deal with tat?
Cheers