Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5035587

Print{Stream,Writer} should have common interface

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P5
    • Resolution: Unresolved
    • Affects Version/s: 1.4.2
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Understanding:
      Fix Understood
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      Name: rmT116609 Date: 04/21/2004


      A DESCRIPTION OF THE REQUEST :
      To support PrintStream and PrintWriter properly in code libraries, it's often necessary to duplicate entire methods and change only the method signature. For example:

      void printContext(PrintStream x) {
      ... some code here ...
      }

      void printContext(PrintWriter x) {
      ... exact same code here! ...
      }


      JUSTIFICATION :
      To support PrintStream and PrintWriter properly you often end up with two identical methods (except the method signature). This leads to maintenance headaches if code needs to be changed, since it needs to be changed in two places. Having a common interface methods would help alleviate this maintenance problem.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      A new interface, perhaps called java.io.PrintCommon (okay so developers are _really_ bad at naming things), that combines the common methods in PrintStream and PrintWriter. Specifically, all the print(...), println(...) and flush() methods. Arguments could be made to also add close() and the write(...) methods, but these methods may stray from interfaces's ideal.

      CUSTOMER SUBMITTED WORKAROUND :
        Duplicate methods with different method signatures.
      (Incident Review ID: 255326)
      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              rmandalasunw Ranjith Mandala (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported:
                Indexed: