Jason Ford

Ranch Hand
+ Follow
since Aug 02, 2001
Merit badge: grant badges
For More
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 Jason Ford


As Andrew mentioned, you should implement the cookie as specified in the interface comments. I agree that it isn't technically necessary. However, it is one of the easier requirements to implement, so why not do it?

Have you ever heard of the Halo effect? You know, where you've convinced somebody that everything you do is great and that you can do no wrong? Well, by doing little things like locking with cookies, you make it a little easier for the grader to think, "Oh, man, this Joe is a great guy."

Now, imagine that you don't implement the cookie. The grader will be inclined to think, "Oh, there's sloppy Joe again. He's always cutting corners."

So, even if you can't think of a good technical reason for implementing the functionality, you should implement it anyway. After all, that's what the interface expects.

It sounds like you have hidden the complexity of the locking mechanism from the client. I have done the same thing in my assignment. However, this doesn't free you from the need to use the cookie.

When doing the lock -> update -> unlock on the server side, you should probably use the cookie. If you don't, you probably won't fail automatically, but the grader would have a good reason for taking off points you'd rather keep.
These seem like perfectly reasonable questions to me.
It looks like your version is ok. See Sun's naming conventions for more information.
Beta versions look like this:
The following output indicates a beta, maintenance release having a build identifier of 09.
java version "1.3.1-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-beta-b09)
Java HotSpot(TM) Client VM (build 1.3.1_05-ea-b01, mixed mode)
Thanks for your responses. I will eat the exception and document it. I will also provide implementations for these methods. (I could hear Max saying: "If the Data class says that it can createRecord and deleteRecord, then it really should be able to do these things, even if nobody asks it to.")
Good eye, Mike. My actual code was written correctly, but the pseudocode I posted contained this subtle error. Thanks for pointing it out.
The createRecord and deleteRecord methods are prototyped in the DBAccess interface, but I am not required to provide these methods to the client. Some developers here have suggested that we should NOT provide implementations for these methods, because we are not required to do so by the specifications. Does this seem to be the prevailing opinion?
On a related note, my findByCriteria method calls a getRecords method that returns a list of all of the valid records in the file. It determines the number of possible records (n) in the file by computation, based on the size of the file, the size of the header, and the size of each record.
The getRecords method calls the readRecord method n times, once for each possible record. According to the specs, readRecord should throw a RecordNotFoundException if a record has its deleted flag set.
The situation look like this:

I'm still working on becoming better with exceptions. Is it ok to eat this exception?
Thank you very much! That seems to do the trick for now.
Thanks for the quick response! I've been giving a lot of consideration to your suggestion, and have developed a tentative plan. (How could one possibly develop such a project without planning? :shudders
Let's see: The GUIController requests a connection from the ConnectionFactory. The getLocalConnection returns a LocalConnection (from the db package), and the getRemoteConnection returns a RemoteConnection (from the remote package).
The Connection interface (in the db package) provides the same methods as the DBAccess interface, but ADAPTS the signatures to the needs of LocalConnection and RemoteConnection, perhaps by including "throws IOException" in the method signatures. The Connection interface maintains a reference to DBAccess (?).
Now, LocalConnection implements Connection directly, whereas RemoteConnection simply extends Connection and Remote. Therefore, DataImpl, which implements RemoteConnection, is allowed to include "throws RemoteException" in its method signatures.
It should look something like this:
Connection adapts DBAccess
LocalConnection implements Connection
RemoteConnection extends Connection, Remote
DataImpl implements RemoteConnection
ConnectionFactory returns Connections (RemoteConnection or LocalConnection)
Am I on the right trail?
I searched through the archives but did not find a satisfactory solution to this problem in Contractors.
I have created the DBAccess interface according to the specifications. The Data class implements this interface.
(Note: I am using Max's indispensable book as my primary resource for this assignment.) A DataAdapter class maintains a reference to a Data object, and shields clients from the complexity of locking and unlocking records. (Is this an adapter or a proxy?) The DataAdapter also implements the DBAccess interface.
Now, I have chosen to use RMI for the network layer. A DataRemote interface extends the DBAccess and Remote interfaces. A DataImpl class implements this interface and extends UnicastRemoteObject, and therefore is the class representing the remote object.
The client will request a connection via a ConnectionFactory, which will return a DBAccess.
Everything seems ok so far. However, rmic fails because the implementation of the methods in the DataImpl class do not throw RemoteException. Nor can they, because the DBAccess interface does not throw them.
How do we get around this? Several threads suggest having DuplicateKeyException and RecordNotFoundException extend RemoteException. This seems bad, because these are not necessarily RemoteExceptions. In addition, findByCriteria does not throw an exception.
This would work, but won't the client be forced to know the difference between the local and remote interface?

Also, be very careful about how you spell xerces. It is a very common mistake (i.e. one I have made myself) to accidentally add xerxes.jar to your classpath. I think this spelling is more natural to native English speakers than the correct spelling, xerces.
A quick google search reveals that there are at least nine web pages that accidentally include both spellings on the same page.
21 years ago

Does anyone know how to set a JTextArea to be uneditable, except for what i append to it?

The answer is: it depends. If you intend to update the JTextArea with its append method, you are free to do so even if the setEditable( false ) method has been called on it. The setEditable method prevents the user, not the programmer, from appending to the JTextArea.
If you want the functionality of a chat program, you could set up the GUI like this:

The user enters a string into the JTextField, and a listener waits for the ENTER key. When it hears the ENTER key, the listener updates the JTextArea using the append method.
[ July 05, 2002: Message edited by: Jason Ford ]
21 years ago
Do you mean like this?

For i18n, you may need to replace the "\n" with "\r\n". The "\n" represents the newline character.
BTW - You'll need to take the underscore out of your name and add a space in its place. There aren't many rules around here, but the naming policy is one of them. It looks like you've gotten by this long, though.
21 years ago

My question is calling a method from another method often causes performance hindrance or not..

If I'm reading this question correctly, you're asking if there is a performance hit associated with calling one method from another. First, calling one method from another is essential to all but the simplest programs. I doubt you'll be able to do anything useful without it. Second, there may be a significant performance hit, depending on the definitions of the methods. For instance, if the calling method calls another method from within a big for loop, you might see the performance drop.
With that said, you cannot begin to worry about performance until you have set service levels (i.e. this method must complete in 2 ms.) I recommend you write the code first, and if you find it isn't fast enough, refactor it.
21 years ago
If you want to create a byte array from a file, you just need to read in the file and store the result to an array:

If you really want a byte array instead of the char array, create a String with the char array and use the getBytes method on the String.
Unless I'm missing something...
21 years ago
And when you're done writing that nifty program for Dave's machine, I'd like a copy of it, too. Just make sure that you rewrite it so that it will work on my platform.
22 years ago