3 ms·
Yes totally agree. The best way that I learned OO was when it was explained that, in most cases, its best to take objects as nouns (ie Item, Book, Prices etc)
by cubano 11y ago
Yes totally agree.
The best way that I learned OO was when it was explained that, in most cases, its best to take objects as nouns (ie Item, Book, Prices etc) and the object methods should be verbs (ie do_something() or act_on_this() etc)
- thomasahle 11y ago'item.add_to(cart)' seems to work fine from a gramatical point of view. It's only when we think in terms of ownership "The cart should own the item" that we choose the right order, no?
- wvenable 11y agocart.add(item) is also grammatical and less conceptually complex than any sort of "add_to" construct.