Assumes that I want to have a list of members, if I use Java, I can use
List<Member>
or create my own MemberList
to store all members. If I want to have more features than the standard List<Member>
provides, of course, I need to create my own MemberList
, which bases on List<Member>
. But what will I do if I only need a read-only list? A List<Member>
cannot do it. To have a read-only list, I need to use Collections.unmodifiableList(myMemberList)
or create MemberList
which supports read-only only.Now consider that I only need to use the read-only list inside my application, which solution can I choose? One of two but maybe one of three. I also can use
List<Member>
and forget about its "edit" methods.To have a clearer design, using
MemberList
will be the best solution but it needs time to implement. To be lazy, using Collections.unmodifiableList(myMemberList)
or List<Member>
without using its "edit" methods is an acceptable answer.
No comments:
Post a Comment