Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-2908

*LocalServiceUtil static methods have too many complex parameters - replace with Builder Pattern

    Details

    • Type: Bug
    • Status: Closed
    • Resolution: Won't Fix
    • Affects Version/s: 5.2.2
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Win XP, MySQL

      Description

      When using a *LocalServiceUtil objects methods, there are problems using the static method calls due to the complex number of parameters. For example see JournalArticleLocalServiceUtil static methods addArticle..

      http://docs.liferay.com/portal/5.2/javadocs/portal-service/com/liferay/portlet/journal/service/JournalArticleLocalServiceUtil.html

      This causes a developer major problems:
      1) Too many parameters in method calls anti-pattern
      2) variant of Telescoping constructor anti-pattern - many methods doing the same thing
      3) Difficulty in documenting which parms are required, and which are optional
      4) Difficulty in grokking which passed values relate to which parm in method calls
      5) Discerning how the multiple methods differ in signature and in their application/usage

      It is my understanding that these *LocalServiceUtil classes are generated code, (hence the lack of comment JavaDoc in them).
      Perhaps a better implementation would be if the code generated could implement the Builder pattern as extended by Josh Bloch in Effective Java:
      See Google Books for the specific pattern, at http://tinyurl.com/dgguse
      it's in the book Effective Java By Joshua Bloch Edition: 2 Published by Addison-Wesley, 2008 ISBN 0321356683, 9780321356680

      This enhancement request is for the *LocalServiceUtil static methods to be re-generated using this extended builder pattern to make usage easier.

      Refs:
      Implementation examples and discussion: http://xavimiro.blogspot.com/2008/04/new-builder-pattern.html
      and http://www.softonaut.com/2007/01/10/thoughts-about-builder-pattern/

        Attachments

          Activity

            People

            Assignee:
            support-lep@liferay.com SE Support
            Reporter:
            Anonymous
            Participants of an Issue:
            Recent user:
            Esther Sanz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              7 years, 40 weeks, 4 days ago

                Packages

                Version Package