I’m having trouble understanding how classes relate to their methods. Is a method something that the object does, or something that’s done to it? Or is this a different concept entirely?
Specifically, in a library’s software system, should the borrow()
method belong to the class representing the library patron, or the class representing the item that the patron is borrowing? My intuition is that it should read like patron.borrow(copy)
, like English sentence structure, subject.verb(object)
; but my instructor says that’s Wrong, and I don’t understand why he would have borrow()
belong to the Copy
class (and he doesn’t really explain things too well). I’m not looking for justification, but can someone just explain the proper relationship?
Edit: This question was closed as “off topic”. I don’t understand. Are software design questions not appropriate for this site?
library.loan(patron, copy)
maybe? There are a lot of designs that would work. Why don't you ask him if you don't understand? – Gilbyecopy.borrowCopy(account)
. And I already said he doesn’t explain things too well. – Rosmunda