Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    FacetChart static properties

    SmartClient Version: v9.1p_2014-08-31/Pro Deployment (built 2014-08-31)

    Quick question. We declare our properties for FacetCharts in a static way rather always creating a new properties objects. Just want to confirm there are no problems with doing this.

    Code:
        protected static final DrawRect BAR_PROPERTIES = new DrawRect();
        static {
            BAR_PROPERTIES.setLineOpacity(0);
        }
    Thanks

    #2
    It's hard to comment without a clearer picture of how these properties are being used. The concern would be if you are reusing the same object as a config for multiple actual UI components, you could possibly end up with more than one live component referring back to the same underlying properties object, so changes to one component could inadvertently effect other components on the page.
    If you think that would be a concern, or would like us to comment further, please flesh out the use case a bit more, perhaps with some sample code or pseudo code so we can understand exactly what the scenario you're dealing with is.

    Regards
    Isomorphic Software

    Comment


      #3
      Here are some more details.

      Consider you have some bar properties that never change, and rather than re-creating the DrawRect object per FacetChart instance, we declare a static final BAR_PROPERTIES which is used by every SampleFacetChart instance.

      Code:
      public class SampleFacetChart extends FacetChart {
      
          protected static final DrawRect BAR_PROPERTIES = new DrawRect();
          static {
              BAR_PROPERTIES.setLineOpacity(0);
          }
      
          public SampleFacetChart() {
              init();
          }
      
          private void init() {
              setBarProperties(BAR_PROPERTIES);
          }
      }

      Comment


        #4
        Just to get back to you on this - yes this should be OK.
        Regards
        Isomorphic Software

        Comment

        Working...
        X