开发者

package private static member class vs. package private class

I was writing two implementations of a Linked List for an assignment, a Doubly Linked List and a Circular Doubly Linked List. Now as the class representing a Link within the Linked List is the same in both implementations, I want to use it in both.

Now I wonder which approach would be better:

Implement the Link class as a package-private static member class i开发者_StackOverflown the first implementation and then use this class in the second implementation or make the Link class a package-private class.


You could move Link up as static member class of a common base class / interface (if you have one). This solution would express that Link is strongly associated with (both implementations of) the linked list.


There is no reason why the Link class should be more closely related to the first implementation than to the second, so I would recommend the second approach.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜