api - Why does the Java List interface not support getLast()? -


I am trying to understand the API incompatibility in the Java standard storage library.

To get the last item in the list or in the AbstraList list, although one can simulate with size and getIndex ().

However, the Linkedist supports that function.

Any idea why it was decided not to support this method in the interface?

java.util.list interface getLast () because designers have 'minimal interface'

This is in contrast to a 'human interface' (such as used) that attempts to provide ways to do general Operations (e.g. getLast () ). As there are many uses, such a basic concept can be kept as a list, there can be more interfaces than this.

See Martin Fowler and details for more information.

  • The class provides equally designated methods to obtain, remove, and insert an element. These operations should be linked to the linked lists used in the form of stacks, qi, or double-end queue (decks) at the beginning and end of the list. Allows

    It was possibly felt that a general list for these specific uses would not be enough.

    As an insight into the mind of the Chief Designer of the Java Collections API (Joshua Bachch), he provides it through which he works. Most of these questions are related to this question:

    The initial drafts of the API should be low, usually a page with class and method signature and one-line description. This makes it easy to reconstruct the API when you do not receive it for the first time.

    When suspicion happens, leave it. If the API is a basic theorem of design, then that is it. This applies equally to functionality, class, methods, and parameters. Every aspect of the API should be as small as possible, but no small. You can always add things later, but you can not take them away. Conceptual weight loss is more important than class or method count.

    Keep APIs free of the implementation details they confuse users and prevent flexibility to grow. It is not always clear what an implementation statement is: Be careful of over-precision.

    Minimize access; When in doubt, make it private, this simplifies the API and reduces the coupling.

    Consider the results of API design decisions, but do not taunt the API to gain performance benefits. Fortunately, good APIs usually lend themselves to the rapid implementation.

    Although he also says:

    Do not do anything to the client who can do the library. In violation of this rule leads to the boilerplate code in the client, which is troublesome and error prone.

    Which only shows that design guides often struggle and the most difficult part of the job of API designers is the remaining conflicts


  • Comments

    Popular posts from this blog

    c++ - Linux and clipboard -

    What is expire header and how to achive them in ASP.NET and PHP? -

    sql server - How can I determine which of my SQL 2005 statistics are unused? -