aspose file tools
The moose likes Java in General and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark ""Describing" an array" Watch ""Describing" an array" New topic
Author

"Describing" an array

Patrick Bucher
Greenhorn

Joined: Oct 14, 2009
Posts: 2
Hi there

I have a job to do related to CSV-files. First of all, I receive the file, then I split it up into rows. Then I split this rows into fields and I have an String-array of data. Now I have to read out certain data and create objects out of that data. If I do it straightforward, the code looks like this:

This code is not very nice to read, because there are literal constants in it. The easiest solution would be to create constants to "describe" the array:

But the class does not look nicer if I put about 40 such declarations in it. So I tried an enum:

Accessing the array now is even more complicated and does not bring more clarity to my code. It looks "bloated" instead:

And using the ordinal()-method might not be the idea of using enums. So using enums seems to be the wrong way.

Does anyone have an idea how I can seperate the code of my factory-method from the description of the array?

Thank you!
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: "Describing" an array
 
Similar Threads
Nested Enums
Refactoring int constant's to use enums
Tiger enums....
Instantiating an enum
Poker