Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Not A Problem
    • Affects Version/s: 0.3.0
    • Fix Version/s: 0.4.0
    • Component/s: core
    • Labels:
      None

      Description

      If we get optional parameters then the code using varargs gets messy:

      String tarurl = clusterSpec.getConfiguration().getString(
        HBaseConstants.KEY_TARBALL_URL);
      if (tarurl != null) {
        addRunUrl(event, hbaseInstallRunUrl,
          HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider(),
          HBaseConstants.PARAM_TARBALL_URL, tarurl);
      } else {
        addRunUrl(event, hbaseInstallRunUrl,
          HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
      }
      

      We should extend or add a builder pattern so that one can do something like

      RunUrl ru = RunUrl.create(event)
        .url(hbaseInstallRunUrl)
        .arg(HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
      if (tarUrl != null) {
        st.addArg(HBaseConstants.PARAM_TARBALL_URL, tarurl);
      }
      addRunUrl(ru);
      

      Or similar to http://stackoverflow.com/questions/3838053/mapmaker-design-pattern referring to the Guava MapMaker class.

        Activity

        Lars George made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Lars George [ larsgeorge ]
        Resolution Not A Problem [ 8 ]
        Lars George made changes -
        Field Original Value New Value
        Description If we get optional parameters then the code using varargs gets messy:

        {code}
            String tarurl = clusterSpec.getConfiguration().getString(
              HBaseConstants.KEY_TARBALL_URL);
            if (tarurl != null) {
              addRunUrl(event, hbaseInstallRunUrl,
                HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider(),
                HBaseConstants.PARAM_TARBALL_URL, tarurl);
            } else {
              addRunUrl(event, hbaseInstallRunUrl,
                HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
            }
        {code}

        We should extend or add a builder pattern so that one can do something like

        {code}
          RunUrl ru = RunUrl.create(event)
            .url(hbaseInstallRunUrl)
            .arg(HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
          if (tarUrl != null) {
            st.addArg(HBaseConstants.PARAM_TARBALL_URL, tarurl);
          }
          addRunUrl(ru);
        {code}

        Or similar to http://stackoverflow.com/questions/3838053/mapmaker-design-pattern referring to the Guava MapMaker class.
        If we get optional parameters then the code using varargs gets messy:

        {code}
        String tarurl = clusterSpec.getConfiguration().getString(
          HBaseConstants.KEY_TARBALL_URL);
        if (tarurl != null) {
          addRunUrl(event, hbaseInstallRunUrl,
            HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider(),
            HBaseConstants.PARAM_TARBALL_URL, tarurl);
        } else {
          addRunUrl(event, hbaseInstallRunUrl,
            HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
        }
        {code}

        We should extend or add a builder pattern so that one can do something like

        {code}
        RunUrl ru = RunUrl.create(event)
          .url(hbaseInstallRunUrl)
          .arg(HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
        if (tarUrl != null) {
          st.addArg(HBaseConstants.PARAM_TARBALL_URL, tarurl);
        }
        addRunUrl(ru);
        {code}

        Or similar to http://stackoverflow.com/questions/3838053/mapmaker-design-pattern referring to the Guava MapMaker class.
        Lars George created issue -

          People

          • Assignee:
            Lars George
            Reporter:
            Lars George
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development