Rag Srinivasan

Greenhorn
+ Follow
since Jun 05, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Rag Srinivasan

Thanks Jim. That was my initial impl, but I started to second guess myself.
regards
-- Rag

Originally posted by Jim Yingst:
I assumed AND.
"records where the name and/or location fields exactly match values specified by the user"
I think that the use of "and/or" here is just a nod to the fact that either name or location could be left blank, and so might need to search for
(records where name matches)
OR (records where location matches)
OR (record where name AND location match)
This interpretation was influenced by the description of the find() method, which implicitly ANDs all criteria specified (not left blank). It's certainly possible to add an OR button - but I don't think it's necessary. IMO of course.

Thanks Jim. That was my initial impl, but I started to second guess myself.
regards
-- Rag

Originally posted by Jim Yingst:
I assumed AND.
"records where the name and/or location fields exactly match values specified by the user"
I think that the use of "and/or" here is just a nod to the fact that either name or location could be left blank, and so might need to search for
(records where name matches)
OR (records where location matches)
OR (record where name AND location match)
This interpretation was influenced by the description of the find() method, which implicitly ANDs all criteria specified (not left blank). It's certainly possible to add an OR button - but I don't think it's necessary. IMO of course.

Hi all,
This is what my requirements have to say.
"It must allow the user to search the data for all records, or for records where the name and/or location fields exactly match values specified by the user."
What did you all implement (those who had similar requirement ofcourse). Did you assume AND or an OR or provide an UI flag to choose between the two ?
The problem is that I have created a Criteria.java class that encapsulates to some extent all the filteration rules and it only supports AND, but I do not know how to create a generic AND/OR expression for example
(parm1 == A OR parm2 == B) AND parm3 == C
The reason to think in this manner is that the find(String[] criteria) in DBMain.java is pretty much useless to capture any nuance and the requirements want this to be extensible. I cannot assume that only location and name fields will be in the expression such as
location == X AND name == Y
location == X OR name == Y

It could be any combination of the 7 DB columns.
Any clues
Thanks
-- Rag
Interesting thread.
I am also going through some soul searching on server-side vs client-side lock/unlock. No where in the requirements is there a reference to clients being able to do it. "Your server must be capable of handling multiple concurrent request, and as part of this capability, must provide locking functionality as specified in the interface provided above.", later, "therefore your locking system only needs to be concerned with multiple concurrent clients of your server. Any attempt to lock a resource that is already locked should cause the current thread to give up the CPU, consuming no CPU cycles until the desired resource becomes available."
I plan on writing an adapter class, as several others have mentioned. This adapter class resides on the server side and sits between the server thread and Data Object. When it gets a request (say) an "update" call, it calls lock, update, unlock on the Data object.

// data is a singleton instance of Data that the adapter holds
void update(int recNo) {
data.lock(recNo);
data.update(recNo);
data.unlock(recNo);
}
Any opinions if this is a sound approach ?
One doubt about the locking: What is the purpose of isLocked(int recNo) method ? I cannot figure out where to use it. My clients cannot access lock/unlock/isLocked anyway, unless I am supposed to use isLocked from inside lock itself (I mean use isLocked to check if the lock has been obtained by another thread and if so wait()). Considering that locking has a appallingly disproportionate weight in the grade than something more important as say OO design, it is worth hearing as many opinions as possible. So please comment freely.
thanks
-- Rag

Originally posted by Jim Yingst:
Oh, you're making the search case insensitive? I had decided not to, but I suppose it could be justified the same way I justify returning both "Fred" and "Freddy".. My feeling is case insensitivity would be preferable in the real world (or better yet, a checkbox to choose whether to use it or not), but I'm not sure it's such a good idea here. I may yet flip-flop some more before I turn in my assignment.
FileChannel - yeah, that's what I use. Pretty simple really - it's just unfamiliar to most of us initially.


I came to the same conclusion as you did regarding a facade to filter out the unwanted results that find may generate. And you are correct about the requirements being both vague in parts and totally over specified in others !! IMO details like lock() and unlock() should not be in the interface at all. I do not plan on exposing them to clients anyway. As you had suggested I plan on using a facade that implements CRUD and Find and that uses Data.java. The facade calls lock and unlock before making any other calls.
Thank you
-- Rag

Originally posted by Jim Yingst:
Right, I was talking about server mode vs. client mode - forgot to mention standalone mode.


Yes it makes sense !!
I am sorry Mark, I did not read your message till today since I saw light at the end of the tunnel after I saw Jim's earlier reply.
Thanks for your clarification both of you.
regards
-- Rag
One of the "must" for the user interface is as follows "It must allow the user to search the data for all records, or for records where the name and/or location fields exactly match values specified by the user." Please note the use of the words "exactly match"
But the data access class must support the following method.
/*
Returns an array of record numbers that match the specified criteria. Field n in the database file is described by criteria[n]. A null value in criteria[n] matches any field value. A non-null value in criteria[n] matches any field value that begins with criteria[n]. (For example, "Fred" matches "Fred" or "Freddy".)
*/
public int [] find(String [] criteria) throws RecordNotFoundException;
How does one reconcile what I perceive as inconsistent ? If a name "Fred" is specified then only a record that contains "Fred" should be returned according to the UI, but the Data Access Class will return all records that satisfy "Fred*" (say "Fred" andd "Freddy" assuming those two records exist) To have to do more processing in an intermediate layer that takes in both the records and throw out everything (in this case, record containing "Freddy") except "Fred" (which is then passed to the UI) seems to be wasteful.
Can some enlighten :-)
thanks in advance.
-- Rag

Originally posted by Jim Yingst:
Yes, I think host and port is probably what is meant by "location". You could allow them to specify file path too, but it complicates things, and requires them to ba able to browse the server's file structure, which is probably none of their business. Simpler to let the person who starts the client choose what server they connect to (host and port), and let the person who starts the server choose which file (path) they want to access.


Thanks a lot. That clarifies a lot.
regards
-- Raghavan

Originally posted by Mark Spritzler:
In this thread Zhi's instructions say that you must allow the user to select the database location, which would mean that that same gui for the properties should have an area for them to specify the location of the database file. Now you can have a "browse" button next to it and use the JFileChooser class to allow them to select it.
Good Luck
Mark


Sorry to belabour the point, but if the client specifies the name of the db file that the server is supposed to use then we could have the following complex scenario.
Several clients taking to the same server, but each telling the server to read data from a different file !! What I mean is, a server process running on a host and a specified port that has to support access to multiple database file. So a client has to consequently (in a stateless protocol between client and server) mention the name of the data file along with each request.
When the requirements say that the "program must allow the user to specify the location of the database", could it mean that the client should be able to specify the "host" and "port" not the actual file that the data resides in ?
thanks
-- raghavan

Originally posted by Perry Board:
I think RMI is much simpler than sockets. You can call methods on a remote object just like it were a local object. With sockets, you'll need to do all the hard work yourself of inventing a protocol for your messages, then interpreting it at either end and doing the appropriate thing.
Try the RMI tutorial on the Sun site and you'll see how easy it is.
If you are set on sockets, why not just pick an arbitrary high port number to use and don't change it unless the user specifically says to use a special port.
[ May 08, 2003: Message edited by: Perry Board ]


Please clarify "unless the user specifically says to use a special port".
Once a server starts how could the user (or client) choose a different port ? Actually I am not sure how even the socket based server can choose the port at run time, since my application cannot set any command line arguments other than the "mode flag". So as I understand we just pick a port number > 1023 and bake it in the server code !! Then in the client we set this code as a config parameter (not baked in code).
Is my understanding correct or am I way off base?
thanks in advance
-- Raghavan
Here are some instructions taken from my assignment.
*** BEGIN ***
When you submit your assignment, each part (client and server) must be executable using a command of this exact form:
java -jar <path_and_filename> [<mode>]
Your programs must not require use of command line arguments other than the single mode flag, which must be supported. Your programs must not require use of command line property specifications. All configuration must be done via a GUI, and must be persistent between runs of the program. Such configuration information must be stored in a file called suncertify.properties which must be located in the current working directory.
The mode flag must be either "server", indicating the server program must run, "alone", indicating standalone mode, or left out entirely, in which case the network client and gui must run.
*** END ***
How do I specify the actual db file itself (in my case the file is db-1x2.db) ? Is it hard coded in source code ? There is no ambiguity in the requirements where it says "must not require use of command line arguments other than the single mode flag". I see other threads on this subject, but the responses leave me more confused
It makes little sense (atleast to me) for clients to tell the server where the file containing data resides. The only config info that the client needs is "hostname" and "port".
thanks
-- Raghavan