Kuali Rice Development
  1. Kuali Rice Development
  2. KULRICE-4897

Removal of toStringMapper, toStringBuilder, from BusinessObjectBase

    Details

    • Type: Task Task
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0
    • Component/s: Modularity
    • Security Level: Public (Public: Anyone can view)
    • Labels:
      None
    • Similar issues:
      KULRICE-10178Remove SessionDocumentService from KRAD
      KULRICE-5005Remove getDefaultCountry from CountryService
      KULRICE-5121Remove JsValue from ValidCharactersConstraint
      KULRICE-1767Remove org.kuali.core.util.UnitTestSqlDao from Rice
      KULRICE-3381Remove "setSearchableAttributes" from the DocumentSearchGenerator
      KULRICE-1996Remove lockCode from DocumentRouteHeaderValue
      KULRICE-1994Remove overrideIndicator from DocumentRouteHeaderValue
      KULRICE-2537Remove KEWUserNotFoundException from the codebase
      KULRICE-2248Remove KOM module from Rice
      KULRICE-12617Remove updateActionAttributes from AgendaBoServiceImpl
    • Rice Module:
      KNS
    • Application Requirement:
      Rice
    • KAI Review Status:
      Not Required
    • KTI Review Status:
      Not Required

      Description

      The rice team would like to remove the following methods from BusinessObjectBase

      toStringMapper() - abstract method that clients must override and fill in with all the field names/values in their BO, used by toString.
      toStringBuilder() - protected method that is used by toString, clients generally do not override

      Both methods are troublesome for a few reasons:

      1) toStringMapper gets out-of-date really quickly. For example when a new field is added to a BO often times the developer forgets to add the field to the toStringMapper method. KC in some cases created unit tests counting the fields in map returned from the toStringMapper versus the field count in a BO. Rice also has unit tests to make sure certain fields are present in the map returned from the toStringMapper. This is crazy!
      2) toStringBuilder does not handle recursive/cyclic references so devs have to be careful not to introduce infinite recursion.
      3) toStringMapper is just more boilerplate!

      We would like to remove these methods and replace the toString method with a default implementation that does the following:

      import org.apache.commons.lang.builder.ToStringBuilder;

      ...snip...

      @Override
      public String toString()

      { return ToStringBuilder.reflectionToString(this); }

      We've tested this implementation and it does work with recursive/cyclic references. If client apps want to do their own thing with toString they would be free to override our base implementation.

      The only downside we can think of is with performance (reflection based, lazy proxies) but really toString is mainly used for debugging/logging purposes. Following good logging practices (ie code guards, correct levels) should mitigate any problems.

        Issue Links

          Activity

          Hide
          Travis Schneeberger added a comment -

          btw. we might initially just change toStringMapper(), toStringBuilder() to empty final methods to make it easier to find all the cases where these methods are overriden but not marked with @Override.

          Show
          Travis Schneeberger added a comment - btw. we might initially just change toStringMapper(), toStringBuilder() to empty final methods to make it easier to find all the cases where these methods are overriden but not marked with @Override.
          Hide
          Jessica Coltrin (Inactive) added a comment -

          Closing since these items are now in the release notes.

          Show
          Jessica Coltrin (Inactive) added a comment - Closing since these items are now in the release notes.

            People

            • Assignee:
              Travis Schneeberger
              Reporter:
              Travis Schneeberger
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Structure Helper Panel