Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

some qns...help appreciated

 
Sarita Gupta
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My concern...
(1) criteriaFind : it's mentioned that the criteria string take the form of <field name>=<value to match> specification. I'd like to check, do we have to handle the case where the field name in the criteria string repeats for example Origin='SFO',Carrier='SpeedyAir', Carrier='PromptAir'. This is possible if in the UI the carrier selection is a list box allowing for multiple selection(though i have not).
(2) search alogrithm : its given a total of 15 mark. I need some pointers on how best to implement the criteria search.

And a problem...
(1) I've actually implemented my gui to display the flight information in a JTable. However, for some of the columns, i see this square boxes appended at the end. Now tell me what am i to do to remove it. What i've done now is find for (char)0 and do a substring(). works fine but is that how it's suppose to be done.
Please any help will be greatly appreciated...
 
Nate Johnson
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) I dont allow for multiple selection, so I have never tested my algorithm for that situation.
2) My algo is simple... just scan the db once over, checking if any matches occur.
3) I just used the trim() method and the boxes went away.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi sarita,
I'd agree with everything Nate said. Now if you really want to implement the more complicated criteriaFind allowing for multiple values of the same field, that's up to you. But as you pointed out, it's only 15 points which I received all of with a very simple algorithm. If you don't, then you should consider using a single selection combobox for each criterion.
Hope this helps,
Michael Morris
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"sarita"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it
here.
Thanks! and welcome to the JavaRanch!
Mark
 
Sarita Gupta
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much Nate and Mark... Thot I should clarify before i put my hand into coding criteriaFind(). It's a relief indeed that the search algo other's hv implemented is kept simple.
As for the criteria string, in that case I'll just document it saying it should not repeat. Will that be ok, sufficient?
Btw can anyone explain how PropertyChangeListener is used effectively. An example could help else suggest a link where i can find out more.
a call for all scjp nd scjd on this again....
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sarita,

As for the criteria string, in that case I'll just document it saying it should not repeat. Will that be ok, sufficient?

There is no requirement that it repeat so you really don't need to document it.

Btw can anyone explain how PropertyChangeListener is used effectively. An example could help else suggest a link where i can find out more

Here is my ComponentMediator class which illustrates how to use PropertyChangeListener and PropertyChangeSupport:

Now all a class has to do is implement PropertyChangeListener, have a reference to an object of the above class and register itself with the properties it is interested in. For example:

Now when a bookingComplete property is dispatched, then the propertyChange method will be called on all registered PropertyChangeListener.
Hope this helps,
Michael Morris
 
Sarita Gupta
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michael,
Thanks for the example(actually I should hv thanked u earlier)...
Now, here you hv explained how to register a PropertyChangeListener... but how do u handle the event received... currently what am doing is when a book complete event is received, i retrieve all the flight records again and do a setModel in my JTable... any suggestion from ur side to improve on this... btw at present am not using PropertyChangeListener... but if it proves to simplify things i would definitely change
As for the criteriaFind() method, reason why I asked if fields can be repeated is b'cos i was taking Data class as a generic class not specific to just this application.... I agree this not a requirement... I mean don't we want to make reusable components...
Sarita
[ August 14, 2002: Message edited by: Sarita Gupta ]
[ August 14, 2002: Message edited by: Sarita Gupta ]
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sarita,
Here is an excerpt from one of the classes that comprised my DataFacade:

Here's an excerpt from my table model class:

The class that dispatches the property just calls one of the dispatch methods on the ComponentMediator and any class that has registered for that property will have their propertyChange method called. Note that in my scheme there were stateless and stateful property changes. Most of the time stateful property changes were fired. In the above example, the dataChanged property carried an array of DataInfo as its state. The table model unwrapped that state (cast it back from Object to DataInfo[]) and used that state to update the data in the table model.
Hope this helps,
Michael Morris
 
Sarita Gupta
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michael,
What shall I say, ur mediator class is too good... I did try out on a sample program and I guess I'm picking up slowly on the use of PropertyChangeListener....
Btw any reason why u have a timer in ur mediator class... couldn't u hv simply called the fireChangeProperty() after the wait().
As for updating of the JTable thanx for the tip... however, since am new to this I won't be too ambitious here...I'll first stick to getting the tables updated correctly the way u have suggested....
Again, ur example has definitely been a good guide....
Sarita
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sarita,

Btw any reason why u have a timer in ur mediator class... couldn't u hv simply called the fireChangeProperty() after the wait().

Yep. Do you remember that swing components are not thread safe? Many of my PropertyChangeListeners were swing components so to avoid the risk of corrupting their state, I used a javax.swing.Timer which runs on the swing event thread.
Hope this helps,
Michael Morris
 
Sarita Gupta
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michael
Do you remember that swing components are not thread safe?

Gosh I forgot all about that... u just reminded me.
OK then, now for the RMI part. Pls tell if am going in the right direction.
- DataInferface which extends Remote defining all public methods in Data.
- Data implements DataInterface.
- RemoteData implements DataInterface.
- RMIFactory to make a connection to the server. and get the remote data.
- LockManager to basically store all the locking information for each Remote Data instance.
Anything else in particular that I need to keep in mind or hv missed out...
Btw by using PropertyChangeListener, I really simplified much of my codes... looks neater now.
Sarita
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sarita,

- Data implements DataInterface.

I don't think that's the best way to go. You're better off having an implementation class that holds a private reference to the Data and LockManager objects that extends UnicastRemoteObject (or Activatable). That will easily allow you to not change the signature on lock and unlock, ie the client calls lock(record) and the implementation class then calls lockManager.lock(record, clientID). Also, the criteriaFind method can then be implemented in the implementation class or a different class which the implementation class holds a reference to.
You can do all this as you propose, but as the application grows, extensibility becomes more difficult: you have to keep adding code to the Data class instead of adding new specialized classes for use by the implemetation class(es). You could also employ inheritance, but once again you run the risk of locking future developers into an inflexible static design which is also hard to extend.
Btw sorry for the delay on answering this, but the ultimate tragedy struck here : I COULDN'T GET THRU TO JAVARANCH!!!
Hope this helps,
Michael Morris
 
Sarita Gupta
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Micheal,
Seems like I didn't get my idea across effectively...
ok look at this then...

The reason why both my Data and RemoteData implements DataInferface is so that I only have to deal with one interface at all times.
As for the criteriaFind, I've implemented the method in the Data class. And its generic enuf to perform any kind of search not only on the origin and destination which is specific to just this application.
You can do all this as you propose, but as the application grows, extensibility becomes more difficult: you have to keep adding code to the Data class instead of adding new specialized classes for use by the implemetation class(es).

Could u explain. Am a little confused here cos from my understanding whatever functionalities provided in the local connection should be the same as that for remote connection. So the easy way out I could think of is RemoteData having a reference to Data. Meaning that when a method is called in RemoteData it will eventually call the methods in the Data class.
Besides this, I was also thinking but hv not done anything abt is probably it'll be good if my implementation can easily allow to change by data source from a data file to a relational database... probably with the necessary interfaces defined... I mean come to think of in for a real application... a relational database will be a better choice... don't u agree?
Sarita
[ August 16, 2002: Message edited by: Sarita Gupta ]
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sarita,
Your design certainly meets the requirements of this assignment and I don't want you to fret too much on this matter. What I posted is probably more personal opinion based on my experience than on proven fact. I feel pretty strongly about limiting size and scope of classes and keeping inheritance trees very small. These issues deal with static design which you have no way of changing once set. The developer/maintainer is stuck with it. I prefer to design aplications as dynamically as possible, deferring as much as I can to runtime as opposed to compile time. Composites are one way of doing that which is what your RemoteData class employs by holding a reference to Data. I was only suggesting that you also have a LocalData class that does the same thing in order to decouple the Data class from the client. That way Data need not implement DataInterface. But as I said earlier, your design meets the requirements and don't fret over this if you are comfortable with what you have done.
Hope this helps,
Michael Morris
 
Sarita Gupta
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michael,
Now I got your point abt what u mean by static design. I'll see how I can make some improvements.
The reason why I discussed my ideas is so that someone can point out the flaws. I definitely would like to pick up some good tips at the end of the day after completing this assignment.
I can always choose to come up with a simple solution which fulfills all the requirements but I'd rather take some time and give it a careful thought.
Thanks for sharing ur views.
Sarita
 
Gurpreet Saini
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi sarita,
I tried to e-mail you but your e-mail address is not functional. Make it functional such that I may send you e-mails.
Thank you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic