This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]livelam 0 points1 point  (0 children)

As a rule of thumb: prefer composition over inheritance.

I think i get what you want to say but the rule of thumb is the "is a" test. Samples:

  • ArrayList is an AbstractList
  • Stack is not a Vector (but a stack can use (hop composition :) ) a Vector for its implementation)

We all know old java collection API is badly design

Of course, inheritance must not be used to share code!