Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

inheritance unnecessary?

 
Sanly Fang
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From previous posts, there are a lot of experience saying that no class inheritance can be ok, and it's not good to introduce inheritance too early in the design.

But this confuses me. How to deal with the Payment? I do think there are two types of Payment, CreditCardPayment and MileageAwardPayment, respectively, am I wrong?

Hope this question do not violate the forum's rules.
 
Yong How, Lim
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a general design rule, composite is preferred over inheritance.
As far as the assignment is concern, there is no rule forbidding you from using inheritance, just remember to justify your decisions.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!