Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-964

Create fluent APIs where possible

    XMLWordPrintableJSON

Details

    • Task
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • 4.0
    • General
    • None

    Description

      A lot of commons-lang is design in an old fashioned way using static util methods. The problem of this design is, that it encodes a language into method names leading to lots of variations of the same method in one class. For example StringUtils has over 180 methods, 9 of which a related to splitting.

      Instead of overloading methods and creating method name variations, we should try to implement fluent APIs. Examples:

      Instead of:

      StringEscapeUtils.escapeHtml3(String)
      StringEscapeUtils.escapeHtml4(String)
      StringEscapeUtils.escapeXml(String)
      

      the API could look like:

      StringEscaping.escape(String).with(Escaping.HTML_3)
      StringEscaping.escape(String).with(Escaping.HTML_4)
      StringEscaping.escape(String).with(Escaping.XML)
      

      So no additional methods are necessary when adding new escaping. There are more examples in commons-lang where the fluent design can be applied.

      Attachments

        Activity

          People

            Unassigned Unassigned
            britter Benedikt Ritter
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: