permaculture playing cards
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Need advice on the Data class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Need advice on the Data class" Watch "Need advice on the Data class" New topic

Need advice on the Data class

Eduard Mamedov

Joined: May 20, 2010
Posts: 23
Hello, ranchers.
I have some questions about DataFileAccess class.

1) I already release C.R.U.D methods. But i need advice what to do with null in String[] array when we create or update records. I think for create method it's good to throw Exception when array contains null.....and for update method???'s better ignore or simply rewrite with spaces this record field that have null value...???

2) I'm trying to use Facade pattern for my Data class, where DataFileAccess class is used for C.R.U.D operations and I want separate class for logic locking... design like in Andrew Monkhouse's book. But my lock method looks like:

....and there is a problem, cause I need to check recNo that located in a map of DataFileAccess class. Is this normal design to release lock() and unlock() methods in my DataFileAccess class?

Cheers, Eddie

Roel De Nijs

Joined: Jul 19, 2004
Posts: 8391

1/ My approach:
  • create: runtime exception when having a null element in array
  • update: ignoring a null element in array (not updating the corresponding field)

  • 2/ I didn't use a facade, just all functionality in the Data class

    SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
    OCAJP 7
    Eduard Mamedov

    Joined: May 20, 2010
    Posts: 23
    Thanks, Roel
    Olu Shiyan
    Ranch Hand

    Joined: Jun 10, 2010
    Posts: 57

    Just as an added note to Roel's comments, I also believe you don't necessarily have to design your Data class in the same way as the Denny's DVD example in Andrew's book. I haven't coded my Data class yet but I don't really see the need for a Facade in the Data access layer. As far as the version of the SCJD project I received is concerned, Singleton will do.


    SCJP 6, OCMJD6
    I agree. Here's the link:
    subject: Need advice on the Data class
    jQuery in Action, 3rd edition