janvy wei

Greenhorn
+ Follow
since Jan 03, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by janvy wei

Hi,javini.Thanks your reply first.
My OS is windows 2000 SP4,the browser is IE6 and JRE is 1.4.
My connection is fast and the size of the file is 286KB.
Are these compatible?
Hi,ranchers.
After a long waiting,I receive my result today,how discouraging it is!
I failed and the reason is following:
Automatic failure. Your submission archive file as we received it was corrupt. Please submit again. You will not be charged for this. If you have any questions, send email to who2contact@central.sun.com.
I know I could resubmit free,but there is little probability that my submission archive file was corrupt.My archive was tested before submited,and I tested my archive in my computer just now,It runs fine too.
Then,my corrupt file is due to the network transmission,but I remembered that after submitting,sun's web tells me that the submission is successfully.
Is there any probability of sun's mistake?
What I should do,resubmit or write to sun?
Resubmit the file will take me long time to wait for the result again.
Any opinion is appreciated!
[ June 30, 2004: Message edited by: janvy wei ]
Hi,Andrew,thanks for you reply.
1)

Originally posted by Andrew Monkhouse:

Why are you reloading the contractor within the while loop:



en,it's a bug.thanks!

Originally posted by Andrew Monkhouse:

Why are you generating the lock cookie inside your synchronized block?
If you do get an InterruptedException, the code which called the lockRecord() method will get back a lockCookie - is this reasonable?


The two questions have the same answer,as you know,I use -1 indicates that the contractor isn't locked,so if get an InterruptedException,the method will return -1 represents that the contractor wasn't locked yet,then the method which invokes lock should do something for it.That also is why I generate the lock cookie inside the synchronized block.
Hi,Andrew.
Sorry for my careless.You do the right thing.
And I am waiting for you opion.
Hi,Stephen.
Thanks for you reply.
The getRecord() method will just return a Contractor instance from the cache which is a List without changing the cache's structure,so I think the
method will be thread-safe.
Hi,Jay.
The DBRemote interface could extends Remote interface only,and The DBRemoteImpl class which implements DBRemote interface could keep an DBMain instance which access the data file.
And the DBAdapter interface should be implemented according the mode.
in local mode,the implementation could keep an DBMain instance,
in network mode could keep a DBRemote instance.
Then you can have the client always refer to DBAdapter, and it does not know if it is using a remote or nonremote class
Hope this helps.
[ April 09, 2004: Message edited by: janvy wei ]
Hi,Fellow Ranchers.
I know that most ranchers use something like lock manager to lock and unlock records.
This solution works fine but seems innecessary to use an additional class to lock and unlock records,IMO.And the solution may synchronize a big object if there's many records in the database,which bring some performance issues.
So,I use another solution.
First I used a Contractor class to put an O-O framework around the String arrays that reprent the record data.The Contractor class has a long field called lockCookie,which is the cookie the record is locked with,and lockCookie is -1 indicate that the record isn't locked.
Then,my lock and unlock method in the Data class is below:

Is there anything wrong with my solution?Any opinion is appreciated.
[Andrew: Removed some of the code]
[ April 09, 2004: Message edited by: Andrew Monkhouse ]
what's wrong?i could see it at all time
[ February 23, 2004: Message edited by: janvy wei ]
hi,Maria.

1.I am not sure if my implementation to open the RandomAccessFile is ok.
I have a separate class, DataInfo with only static variablen and methods to read the lenght of fields, header etc. I have also a static getRaf() method
witch returns new RandomAccessFile(dbFile, "rw"); I use this method every time I need the raf.


it sounds good.

My find method returns the records depending on the exactMatch flag. The default is true. I have another constructor in the Data class with an additional boolean parameter to can set the exactMatch to false. In the case that the client will be later extended to search for inexact matches, than this constructor has to be used. Is this OK?


Don't you have something like this in your DBAccess interface:


// 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 long[] findByCriteria(String[] criteria);


are you saying that the findByCriteria method in the Data class will return
records depending on the exactMatch flag which can be set in the Data class?
if so,i don't think it is a good design,cos your implementation of the DBAccess interface should be according to the method comments provided in the interface,and i think your implementation of the find method is inconsistent to the comment of the findByCriteria method which had told you definitely the match rule.
so,IMO,you should use a Adapter class to provide the exactly matches rather than provide it directly in the Data class.

3. It is necessary to implement the create and delete methods? In GUI I don't need them. For the update method I have to update besides the owner field also the other fields? It is possible only to update the owner.


base on the same reason above

your implementation of the DBAccess interface should be according to the method comments provided in the interface

,
i think you should implement the create and delete methods fully.
hope this help.
[ February 22, 2004: Message edited by: janvy wei ]
hi,George.
thanks your reply.
you are always the first guy replys me ,your opinion is important to me.
if you use IE,you may right-click and select "show picture" to show my class diagram.
and anybody's any opion is appreciated,thanks in advanced.
[ February 22, 2004: Message edited by: janvy wei ]
hi,jon.
Jacques's example is good.
and I have a few comments in addition to those offered by Jacques.
if the method return void,then you should not have a @return tag.
last,you should use a IDE such as "IntelliJ IDEA" or "JBuilder" to check your javadoc
hope this helps
hi,javini.
IMO,i think the whole instructions don't tell us Data must or must not expose it's methods to
the client.
it's free for us to expose it's methods to the client or not,it's just our design.

A data access system called Data that provides record locking and a flexible search
mechanism


we could has only one Data class to represent the data access system,or have some
classes to do it.the emphasis is "record locking and flexible search".

Let's draw a chart:

code:
--------------------------------------------------------------------------------
Client says "Give me data" --RMI--> Business Methods --> Data --> Database representation.
--------------------------------------------------------------------------------
Does the above diagram conflict with the use of the phrase " 'top level' features"? Or would
the following diagram be more accurate?

code:
--------------------------------------------------------------------------------
Client says "Give me data" --RMI--> Data --> Database representation
--------------------------------------------------------------------------------
Or do both diagrams make sense?


i believe that both diagrams are OK,but the first is better.

hi,Fellow Ranchers.
above is my class diagram . any opinion is appreciated.
i use three tiers and apply MVC pattern.
the model interface is a abstract class -- BookerModel
as you know,the programe has three mode,so i have three concrete model classes -- AloneBookerModel,DefaultBookModel,ServerBookerModel.
as the programe should show different dialog accroding to different mode when it is launched to gain the info such as db location and so on.
so,i have three classes --DefaultModeInfoPanel,ServerModelInfoPanel,AloneModeInfoPanel which extend JPanel.
and,i apply the abstract factory pattern,the abstractfactory is BookerFactory,it has two abstract methods --- createModeInfoPanel() and createBookerModel(),and it has three concretefactories --- DefaultBookerFactory,ServerBookerFactory and AlonebookerFactory.
ok,the next is the main client ui,i have a interface bookerPanel extends Observer interface to provide the method setBookerModel(BookerModel bm),and have four classes implement it,they are SearchPanel, BookPanel,StatusPanel,ResultPanel,which extend JPanel.
they are the view part of the MVC.
and i'll provide some event handlers such as SearchAction,BookAction,which are the controllers.
next is the server package.
it's so simple,only a Server interface which provides the book() method and the search() method.and a ServerImpl which implements the interface.
the last is the db package.
Data implements DBAccess interface
in AloneBookerModel,it accesses the Data class directly by keep a Data reference,
in DefaultBookerModel,it delegates the request of search and book to the ServerImpl by keep a ServerImpl reference
[ February 23, 2004: Message edited by: janvy wei ]
congratulations!
great score
20 years ago
george,congratulations!
Would you mind sharing your point total broken down by category?