aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes B&S-How to deal with some magic number? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "B&S-How to deal with some magic number?" Watch "B&S-How to deal with some magic number?" New topic
Author

B&S-How to deal with some magic number?

Chih-Wei Lee
Ranch Hand

Joined: Feb 20, 2008
Posts: 129
How you guys deal with some magic number, like the index of data field?
For example, on UI portion, you have to know the index of owner field is 5
so you can set a customer ID when someone book a contractor, like
data[5] = "BS123456";

Do you hard code the index "5" or how you handle this?

Thanks


SCEA, SCJD, SCDJWS, SCWCD, SCJP
John Mattman
Ranch Hand

Joined: Feb 18, 2008
Posts: 45
How you guys deal with some magic number, like the index of data field?
For example, on UI portion, you have to know the index of owner field is 5
so you can set a customer ID when someone book a contractor, like
data[5] = "BS123456";



Hello Chih,

I am doing B&s version 2.3.3. As per the instructions in my assignment, the data type for customer id is 8 digit number. Does you assignment say it as an alphanumeric?.

In my assignment I have hard coded the magic value as static constant.
I am only using it for validating my database.
mohamed sulibi
Ranch Hand

Joined: Sep 04, 2005
Posts: 169
hi Chih-Wei Lee;

In my opinion and project, hard code these index instead of getting it dynamically.

Regards.
Mohamed Darim.
Chih-Wei Lee
Ranch Hand

Joined: Feb 20, 2008
Posts: 129
Thanks for your response.
John, you are right. the customer id is 8 digit number.
I didn't notice this, sorry.
Rico ZHANG
Greenhorn

Joined: Apr 28, 2008
Posts: 10
Hi Guys,

I got a similar question.
Just want to know can I set the other header information as final static variables(coz tat will be much easier), or I should load it from the db file every time I need them.

i.e, the length of every field in a record,
the offSet of the Record 0..

things like this.

Thanks...
Chih-Wei Lee
Ranch Hand

Joined: Feb 20, 2008
Posts: 129
I read header information from db file every time when I run a server or run the local mode application.
In my opinion, since I need to read data from db file every time, it would be easier that I also read head and schema information. At least, I don't have to hard code the beginng position of data section in db file.
But I hard code the magic cookie because I need it to check if the loaded db file has valid format so that my program is able to process it.

Lee
Rico ZHANG
Greenhorn

Joined: Apr 28, 2008
Posts: 10
Thanks Lee,

Tat really helps.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: B&S-How to deal with some magic number?
 
Similar Threads
Where does recordNumber come from?
Relationship among Data class, RAF instance(s), and clients
the spec didn't mention the convert tool
URLyBird search for the database records issue - advice needed
Interface question B&S