• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can we add methods in Data.java?

 
Cathy Young
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am wondering if we can do this besides implementing the 3 methods (lock, unlock and criteriaFind) if we are modifying Data.java? Has anyone done this and passed (or not been penalized for this)?
Thanks!
Cathy
 
xiaoma wang
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can do it. I got 53 for the server design and i modified Data class by adding lock, unlock and CriteriaFind to it.
Good luck!
Xiaoma Wang
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can do it. I got 53 for the server design and i modified Data class by adding lock, unlock and CriteriaFind to it.

She was asking about methods besides those three. I modified mine by adding a helper private method to work with the criteriaFind method. I got 49/53 in server. I am not sure where I lost 4 points, as they where the only points I lost. But if I were to do it again, I would not add any extra methods to the Data class than what they had in the specs.
Mark
 
Cathy Young
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by xiaoma wang:
Yes, you can do it. I got 53 for the server design and i modified Data class by adding lock, unlock and CriteriaFind to it.

Thanks but I guess either of us may have misunderstood each other. What I want to do is to add another method like getCarrier() to Data.java to get all the carriers in the database. Can I add this method in Data.java?
Thanks!
Cathy
 
Siddharth Mehrotra
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i had two helper methods for my criteriafind method.
and guess what i cleared.
so i guess you can do it, and as such, it is always a better option to split the methods that get too long.
 
Horst Dehmer
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Cathy,
like Siddharth I added some method to the Data class (mostly criteriaFind related). I feel comfortable with this. But I think you should remember that Data is not responsible for one special database like fbn. I'd say searching carriers in Data is too close to business logic and therefore Data's not the appropriate place to put it. I'd rather have a method which does something like SELECT DISTINCT on any field. From the client you can call this on the carrier field.
Hope this helps, Horst.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My copy of the assignment (> 2 years ago) strongly hinted that you were to write code for re-use -- please correct me if this is no longer the case.
But regardless of whether this is still stated explicitly or not, please observe that the Data class is a completely generic miniature database engine, exposing low-level methods for record manipulation. What you are proposing is to add completely application-specific methods exposing high-level business functions to return carrier lists, book a flight, etc.
This is bad OO design in any case. If I were to dust off my Architect-O-Matic[tm] Java[tm] Technology Diagram:
user interface <==> business logic <==> persistence
Then Data is firmly in the "persistence" layer, exposing stuff like "lock this record" and "find a field like this". Functions like "book this flight" and "give me a list of carriers" are typically exposed by the business API. Conversely, the business API would never allow client code to bypass it by giving direct access to the underlying persistence mechanism. That would break a valuable bit of encapsulation, and besides, the functions are at a wildly different level of abstraction and genericity.
- Peter
 
Robin Underwood
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My locking and searching are not application specific at all. I have LockManager and SearchManager classes in the suncertify.db package that know how to use the Data classes to do their job. I'm not done with the assignment yet, so I don't know the graders feel about this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic