• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SCJD help

 
Ranch Hand
Posts: 147
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all I am new here and just started on My SCJD assignment.

My assignment is ...... The Contractor assignment.

My problems.....

1) I have decided to create a reusable contractor object that will allow for new contractors to be created and to gather information from the existing database.
I would like to varify that I made a good choice in datatypes for this class as follows (only included most relevant)

Specialities: I chose an arrayList<String> as it allows for the list to grow dynamically I didnt want an array as there is know knowlege beforehand of how many specialites each contractor has.
size: I chose Byte but I dont know if this was the corect choice. Choice was based on the fact that the supplied database is said to have values of 6(field length) and this is small enough to be stored in a byte BUT what if the company grows in workforce? Should I rather chose Int to allow for this?


2) MVC Yes I am a noobie somwhat and I have done some but not much reading on this. I decided to have a layered application that has 5 classes as follows...
2x GUI classes 1 for web user and one for the users at the office
1x Buisness Layer for the doing the workload of the application (will server both office users and web users)
1x Data Storage class that will store/retrieve the data the same for web and office users
1x Reusable Contractor class

Firstly will this approach work? And secondly will RMI as I understand it allow for web users to access my Blayer untouched? This is how I understand RMI to be?

Just to clarify that up to now I have good understanding on SWING and teh java foundation classes but have never done any RMI, MVC or database related stuff. From what I read on MVC I understand the importance of a layered application but I could greatly do with a recommendation on a book that can explain its use in java.

Last question..

What is a magic cookie? How am I supposed to use it?


Thank you all in advance.
 
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I will only comment on a couple parts of your post. First, the Contractor object is a good idea. I use a HotelRooms object for mine (I have URLyBird). A lot of people use this (Value Object) approach. As for the magic cookie, you can find it in your data file. I have a class level variable for it, initialized to 0. When I parse the file, I set the actual value during the read. I have a method that checks and validates it.
You have to hard code the number, and yours is probably not 258. There are a lot of posts concerning this.
Oh, and get a hex editor! It will greatly help you parsing the file. There are a lot of excellent posts on how to do this to. It should be one of the first things you do. RandomAccessFile is another hint for you. good luck!
 
Yucca Nel
Ranch Hand
Posts: 147
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all I coded the following which gives me what I hope to be the magic cookie num. Does it look correct?

public class Main {

/**
* @param args the command line arguments
*/
public static void main(String[] ags)throws Exception{
RandomAccessFile raf = new RandomAccessFile("db-2x1.db","r");
readMagic(raf);
}
public static void readMagic(RandomAccessFile raf1)throws Exception{
System.out.println(raf1.readInt());
}

}
 
Anne Crace
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yup It looks like it will work! I set my magicCookie and validate it on the next two lines of code. You might consider using "rw" for your access in RandomAccessFile. Don't need it now, but probably will write before it's all over with.
 
Yucca Nel
Ranch Hand
Posts: 147
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the help.

Do you or anyone else mind going into details on what this magic cookie is actually for? And why do I need to store it? I am asking from a RL coding point of view.
 
Anne Crace
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It basically validate the database (file) as the correct one. Search the forum for "magic cookie". I'm sure you will learn all about this cookie. I didn't understand it at first, either.
reply
    Bookmark Topic Watch Topic
  • New Topic