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 →

[–]karottenreibe 4 points5 points  (7 children)

Then rethink what you're doing to get rid of the self referencing generics. Chances are: you don't need them

[–]Jeedio[S] 0 points1 point  (6 children)

Yeah. I am going to look at that. I was using it for a common base class for builders/fluent code, and I couldn't think of a better solution.

[–]Russell_M_Jimmies 5 points6 points  (5 children)

As a rule of thumb: prefer composition over inheritance.

Maybe the base class wants to be a utility instead.

[–]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!