Bookmark Topic Watch Topic
  • New Topic

Object Model Design  RSS feed

 
YuenLian Wu
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi All,

I have an Object Model Design question and would like to brainstorm with you guys.

Users can View/Add/Delete a list of Security Instrument(with unique key) from GUI. I would like to construct an Object Model so that it will perform a diff action between Retrieved List and Modified List of Instrument Objects once user hit the save button from GUI, and the Model should return how many records that I should delete/insert or Do Nothing. For example, the list might contain Google, CITI and Microsoft originally, and then the user modified the list so that CITI was removed and GE was added.
What's the best way to implement such Data Model ? Should I override the Comparable Object and Implement my diff logc in there ?

Please let me know you thoughts, thanks.


Cheers,


Transistor
 
yancy yang
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Report post to moderator
I don't think you need to implement Comparable.
In my opion, overrides equals() hashCode(), then all you need is a utility, which could tell what is the difference between retrieved set and the modified set.
 
YuenLian Wu
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Report post to moderator
So under what kind of circumstances should I should Comparable Object?
 
John de Michele
Rancher
Posts: 600
  • Mark post as helpful
  • send pies
  • Report post to moderator
YuenLian,

Comparable is really most useful when there is the concept of a greater-than/less-than/equals between two objects of a class.

John.
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Report post to moderator
Do not cross-post the same question in multiple forums.
Lets continue the discussion in this thread.
 
It is sorta covered in the JavaRanch Style Guide.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!