Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!

Martin Rea

+ Follow
since May 04, 2004
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 Martin Rea

Hi Stephen,
I can't see what the pack() method is? Is this because your GUI extends JFrame or ...

I don't use pack() in my application because it packs the GUI and I don't like to have different sizes depending on what I have started.

I Tried to put in a pack command on my main panel (JFrame) and start it severel times - no problems.

So the easy solution - why not just delete the pack() call?
The interface I was given in my assignment throws a SecurityException in the update, delete and unlock method.

The description says "..if the record is locked with a cookie other than lockCookie".

My first thought was to use java.lang.SecurityException, but this is a runtime Exception and I believe it is bad practice to throw a runtime exception in the middle of the code?

So I made my own SecurityException - does this seems ok?
Thanks for the responses.
I just got hold of Max' Book today.

There is a link to a place on Javasoft homepage (if someone else are interested) that explains it all:

Code Conventions for the Java Programming Language
This is a simple questions (and I should probably know the answer :roll: ):

When declaring a member final it is good java coding style to use UPPER_CASE_NAME (true?)

- but what about when declaring final references:

public static final dataClass Data;

- is the coding style also: DATA_CLASS or as above?

- Do anyone have a good reference to a java coding style guide (I have one from Sun but it's pretty old and surfacic) ?

- Are there points to loose on bad coding style?

Thanx in advance
Hi all,
Thanks - there goes my design.....
Anyway I thank you - it is a very interesting discussion and I can just wait some more time before submitting.

I thought I was done with my implementation but I will do some argumentation and hopefully someone will comment to see if it is useable or I have to change my design (and implementation):

1. My current application only supports search and book
2. I have nothing stated in my assignment regarding if name/location is the same then it is an identical record - therefore I assume that if all fields are equal then it is a duplicate record
3. I may assume that only 1 program accesses the DB at a time according to my assignment (nobody using the data access class at the same time my clients does - no alone mode usage when running networked etc.)
4. Therefore a delete can be safely done - no clients using the application at that time - so the situation Greg refers to can never happen
5. I am aware that in the future when the application must support delete / update in generel another approach might have to be implemented
6. I use notifications to tell clients when a record is booked from another client
7. 2 client cannot book the same record - I check to see if the field is booked after taking the lock for the record. If it is - the user will be noticed.

How does such an argumentation sound to you?
Hi Hanna,
I am not sure I understand the issue but here is how I have tackled it:
The primary key is simply the record number - that is the appearance in the DB file.
When deleting a record there will not anymore be an entry with that particular record number (say record nb 3 is deleted only 1,2, 4... is left)
When creating a record I just reclaim the deleted record or create one at the end of the DB if none has been deleted.
How can I compare if 2 records are the same? I state in my documentatio and code that I do not have the knowledge to judge but it does not give any meaning to have 2 records that holds exactly the same values.
But it might give meaning to have exactly the same entries only differing in price (for instance)
Therefore I compare all fields to all fields when creating and throw a RecordNotFoundException if a match is found - otherwise I crate it.
I don't know if this was what you intended but this is my approach to tackle this issue.
Hi Hanna,
I did exactly the same as you:
[*]Instantiating Data class
[*]From constructor I read the DB scheme (magic cookie, length of fields, fields in record...)
[*]For each method (read, find, create...) I open a file stream , read what I need and close it
I have also implemented locking and I haven't ran into problems using this approach.
One could argument that the open / closing for every access is costly. But on the other hand requirement states we should not be concerned of performance. During my tests I have had fine respons time both searching, creating etc.
Hope I can drop in on this discussion with a new question relating to this (thought it would be better than to start a new discussion thread)
Assuming the following:
  • I start server (inlcuding rmiregistry) on a machine
  • The client starts and connects to the server from a different machine

  • I let the client be able to give port number and server IP (or hostname)in order to connect to server.
    Is it ok to assume that the server is always started on

    I mean, is there any need for starting the server to use an IP or hostname?

    Reading my respons again I can see my formulation was quite unclear.
    I'm not using the logger API for property file - just Properties.
    What I meant was, that I am writing properties to current directory. Actually it is required that I do that - or at least changes made by the user is persisted in a property file residing in current directory.
    If this is a requirement I cannot see that there should be any problems writing another file (the log-file) to current directory.
    - but again I could be wrong...
    Hi Vishwa,
    I did almost identical to you - except I just made 1 handler for all modes. This works fine even running on the same machine. The logger itself just increases the number test.log.1 for each time the application request a new logger.
    I also have put the logger to log in current working directory. I also use this concept for writing my properties file ( Of course there can be IO problems when trying to write to current directory but I think it is resonable to assume that it is ok - how do we else handle property files and logging? It is not possible to use setup - at least not in my application - cause if it does not find a property file it will create one.
    My approach is to test it on a couple of machines (including a Unix box) and see if it works. Then I will document that the user must have rwx priveledges to the current working directory. I hope this is sufficient to pass SCDJ - but I will certainly follow this stream
    Hi Al,
    What assignment are you doing? I'm doing the Bodgitt & Scarper assignment.
    My package structure looks like the following:
    There are a lot of bindings between my packages - I mean starting up in the controller package which will setup classes from db, model, notification etc.
    I'm not too worried about this. I am asked to submit one runtime.jar which I will state should not be unpacked and exploded (I have some dependencies to images and html files in a fixed structure). If this was real life - yes I would try to make deployment diagrams, compiling without dependencies etc. but for this assignment it seems overkill.
    Hi ranch members,
    This is the first mail from me, but I have been following you for a while. I am workin on Bodgitt & Scarper assignment and I am almost done with the programming part. Just as you know it - the forum has been a fantastic place to get inspiration and help.
    Now to my question:
    I am doing all my configuration in a JTable - (property,value)-pairs - and one of my configuration parameters are what log-level to use (I use Java standard logger and only FINE, WARNING and ERROR). My problem is that I would like this choice to be a non-editable JComboBox residing inside a JTable. I have come so far that I have written my own cell editor:
    public class LogCellEditor extends DefaultCellEditor
    and I use this from inside my table model:

    But when I do this it apparently overrides my isCellEditable(int r, int c) method in my TableModel. In this way I can only choose to have all cells in a column using JComboBox (which was not the intention) or to have only the cell using my JComboBox editable - also not the intention.
    Before dropping the idea as a whole I though I would ask all of you - anybody has a good idea?
    [Andrew: put the source code between [code] and [/code] UBB tags]
    [ May 04, 2004: Message edited by: Andrew Monkhouse ]