Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!

Mxolisi Veco

Ranch Hand
+ Follow
since Jan 14, 2010
South Africa
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mxolisi Veco

I am sorry about my earlier response Jason.

I added a shutdown hook to my data class so that I can close the database when the application exists. I did not catch the records in the database so I did not need to write any records back to the database file when the application shuts down.
Good day.
I am not sure what it is that you are trying to ask, if you do not have any records locked, why can't you just say System.exit(0) ?
Good day.
If the getter or setter is simple, I do not think the absence of javadoc is going to have anybad impact. So no need to stress.
I received an e-mail last week (27 September) telling me that I have passed.

Here are some details about my assignment

- The system uses custom popup dialogs over an editable JTable.
- Socket server is used by the application.

I waisted some time when I was building the assignment by adding functionality that was not asked off me.
My application allowed end users to switch in between servers, my application also allowed users to search for rooms that are not booked and to search for smoking or non-smoking rooms. These made the code long and introduced some complexities. It also took some good time away from me. I was not 100% clear on what to do after reading the specification.

Thanks to all the ranchers for the help they gave me when I was building the assignment.
9 years ago
Good day.

i agree..there makes no sense to lock the entire data class. However, while searching on the forums i encountered a solution where someone had suggested making the data class singleton. If the data class is a singleton, wouldnt that mean no two classes can modify the data at the same time... making it lock the data for individual writes?

When you implement your Data class, there will be a RandomAccessFile object that will be used to access the database file. That is the object that people usually make it static and they also synchronize on that Object when reading/updating the database.
Good day.

The interface I was given by oracle-sun was as follow

Required Interface
Your data access class must be called "", must be in a package called "suncertify.db", and must implement the following interface:

package suncertify.db;

public interface DBMain {

That should tell you that the packeg names must begin with
If you use code.zzz.yyy, you will get automatic failure.
Good day.

Are you prepared to employ a remote person who will be working from a different country for this job?
Is the application to be tested something that can not be accessed remotely ?
Is the requirements specification complicated in such a way that a remote person will not be able to understand it with out bieng walked through it?
10 years ago
I do not think its about the exams only, it is mostly about how you built your assignment.
The exam is just something that you take to prove that you wrote the assignment you submitted, not your friend(The java Guru).
Good day.

You are not allowed to bring any refference material in the exam room, so you can not bring any papers or books with you to the exam room.
I also do not speak English as a home language but I wrote my exams already.
I explained my self using simple english. There is no need to complicate things.
The questions are also very simple and ask something that is straight to the point. The enlish used on the question is simple.

Go through the FAQ page to find out about the rules.

There is nothing that you need other than your hands and memory for the exam.
By the way Nimesh Parmar

1) Search ==> Select ==> (Click on the Book button in UI to..) Lock the Record ==> Type cust no ==> (click Confirm on UI and then ){Update ==> Unlock}
(2) Search ==> Select ==> (Click on the Book button in UI) ==> Type cust no ==> (click Confirm in UI and then) {Lock ==> Update ==> Unlock}

The above scenario (2) is more correct than scenario(1). Scenario (2) will take milli seconds to release the lock since by the time the end user clicks the confirm button all the details are available, so no time will spent waiting for the customer ID.
Scenario (1) will take longer to release the lock since while the user is typing the customer ID, the record is locked already.
Good day.

When User 2's thread is waiting, what happens on User 2's terminal? Do you show a busy cursor, implying to User 2 that "the system is busy doing something" or do you "return" control back after "some" time to User 2 saying (s)he is free to search/book other records because record 3 has already been updated?

You don't have to display anything on user 2's screen.
You do not return control to user two until the booking is sucesfull or an error message is displayed.
Computers are fast these days, its unlikely that user two will even notice the delay.
User 2's thread has to wait until it is nitified to attempt to book the room.

So, "some" here would equate to the timeout parameter in wait(long timeout). In case of wait(), the return would happen ONLY IF User 2 updates or decides not to update. The point is, whether you use wait() or wait(long timeout), control would NEVER return immediately back to User 2.

You must NOT use wait(milliseconds) because you will get automatic failure. You must use wait(). Your requirements specification states that it is a MUST that your thread consume no CPU cycles when waiting for a resource.
It does not matter to which thread control returns to, if you implement your locking class right, then all the waiting threads/users will have a chance on the specified record. So user 2's thread will eventually get a chance to try to book the specified record. If by the time user 2's thread gets a chance to book the room, you must throw an RoomBookedAlreadyException ("This room is booked already"). If the room is not booked, update the record number and update user 2's front-end accordingly.

And my current thinking is "control MUST return immediately back to User 2 as soon as Thread T2 encounters the wait method"

You will be complicating your solution for no reason. Rather let user 2 wait until user 2's thread is notified to attempt to book/update the record.
That is, a user must only be able to do one thing at a time. If users are allowed to do many things at a time, that will not help with getting you more marks, instead you are likely to fail because of code complexity that you will be introducing.
Try to keep simple things simple.
Good day.
I threw IllegalArgumentException when users of the Data class provided invalid arguments such as null because such an argument is illegal.

If you want to throw NullPointerException when users provide a null argument to your methods, I assume that is okay since you will provide a description of what is wrong when throwing the exception.
The issue of using IllegalArgumentException or NullPointerException is a subjective one in this case of recieving a null as an argument.

As long as your Data class does not fall over, it is okay to use what you feel is better or will be understood by people who will maintain your code.
I am pursuing certificates in Java
- To know a lot about Java.
- To know how Java expects recommend things be done using java. That is, how code should be grouped and structured.
- To be on an international level. That is, when some talks about design patterns, I can know that they mean the same thing that I know.
I suggest you use Use Roel's

Submission Jar: test case + Ant build script to build your jar.

to build your jar, it will save you some time and trouble. I think that build.xml file will put your images somewhere in the runme.jar file.

Will the reviewer be extracting the files from the JAR, before testing it?

I do not know.
If you build your jar using Roels build.xml file, then you do not have to worry about that.
There is also a JUnit test that you can use to test the jar file created by Roel's build.xml.
Just search for Submission Jar: test case + Ant build script to build your jar
Good day Mostafa.

I have a BusinessServices class that I use when the application is in stand alone mode or in server mode.
The BusinessServices class locks a record; does anything it needs to do; unlock the record.

Locking records in stand alone mode will not cause the program to fall over and it will not corrupt the database.
So I do not see anything wrong with locking records in standalone mode.