• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question regarding Field Lengths

 
Arun G Rao
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I started with a simple deisgn of having constants that represents the field lengths and record lengths.

I am having second thoughts about this. Should I be reading from the data file and build these values instead of assuming them as constants?

Please let me know your thoughts on this.

Thanks
Arun
 
Steve Baranski
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Arun - I think this depends in large part on how you separate responsibilities in the data access layer of your assignment. Are you creating a Data class, or an URLyBirdData or BodgittScarperData class?

I think you need to iron out what the Data class does (i.e., access any kind of data, or specialized data), and document your assumption. Should the Data class know about the type of data it's accessing? Or should that be the responsibility of another class(es)?

If you search around, there are a number of debates about the Data class. Some use it as a facade for file I/O and locking services (which has another benefit), and others deal with it more directly.

In the end, it's your choice. Good luck...
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, everyone

Well, my opinion is that the fact that the database file comes along with a few metadata records is precisely to sugest that in the future they could call you to a meeting to ask you add or remove a couple of fields or to add a few more characters to one of the character fields (if this were not just for an assignment).

Otherwise it would be enough if the file just contained the actual user data, without any metadata, and the use of the file were documented elsewere.

So I think I will take a dynamic approach, not hardcoding of any field sizes or field names. I will get the metadata from the file every time the application starts and based on the current values stored in the file I will do the necesary calculations to manipulate the file randomly, never in the world supposing a fixed number of fields or sizes.

What do you think?

Regards,
Edwin Dalorzo.
[ January 11, 2006: Message edited by: Edwin Dalorzo ]
 
Arun G Rao
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your thoughts.

I am using my Data class as a facade. I have a Data Access class and the lock manager as part of this class.

I have implemented a Factory pattern to get the DAO class. The DAO that will returned in this instance is a FlatFileDAO. In future, if the data repository is moved to a Database, all that needs to be changed is the DAO.

You are right about not assuming the field names and field lengths. This is probably what I would do at work.

I think I will make a trade-off for readable and maintainable code. I will take a hybrid approach and assume the data field names and read in the lengths. My design for the data transfer objects also prompts for the trad-offs. I am not passing the data to the UI tier as the String[]. I transfer them over to Value Objects. This again for readability and maintainability.

I will probably stick to this as my design theme.
 
Anton Golovin
Ranch Hand
Posts: 530
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your class which accesses the data, I would create an internal class to keep those constants. Thus, you will not be letting the values out for everyone to get at, but at the same time you will separate this information from the purpose of your data-access class.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic