Uploaded image for project: 'Click'
  1. Click
  2. CLK-565

Provide Control builder / factory class

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Minor
    • Resolution: Won't Fix
    • 2.1.0
    • 2.3.0
    • examples
    • None

    Description

      Using a factory or builder pattern to create controls is a great way to reduce the number of lines of code in an application and can also help standardize your application.

      There are 2 common pattners for doing this, one is the factory pattern, for example:

      Table sizesTable = new Table("sizes");
      ControlFactory.addColumn(table, "label", "Metric");
      ControlFactory.addColumn(table, "value");

      The other is the builder pattern, for example:

      Table sizesTable = TableBuilder.simpleBuilder("sizes").addColumn("label", "Metric").addColumn("value").build();

      Both of these styles have pros and cons. Please see attached examples.

      Attachments

        1. TableBuilder.java
          5 kB
          Malcolm Edgar
        2. ControlFactory.java
          10 kB
          Malcolm Edgar

        Activity

          People

            a_adrian Adrian A.
            medgar Malcolm Edgar
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: