Uploaded image for project: 'The Virtual Brain'
  1. The Virtual Brain
  2. TVB-1620

Review use of properties in datatypes

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      An antipattern in some datatypes is using the setter of a property to compute the property value, but the value sent to the setter is not what is returned from the getter.

      The patterns is an example, where one sees in SpatioTemporalPatternSci.configure_time

      self.temporal_pattern = self.time

      which causes results in self._set_temporal_pattern(self.time) which actually computes the pattern. This result is returned by the corresponding get method.

      The problem is two-fold, 1) properties setter & getter should handle take and return semantically equivalent things 2) code can be much simpler, i.e. configure_time shuold just compute the temporal pattern directly and set self.temporal_pattern as a regular attribute.

      I think this occurs in several places, so this should be gotten rid of. Data descriptor should only really be used to make attributes part of a stable api.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                marmaduke.woodman Marmaduke Woodman
                Reporter:
                marmaduke.woodman Marmaduke Woodman
                Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:

                    Time Tracking

                    Estimated:
                    Original Estimate - 1 day
                    1d
                    Remaining:
                    0m
                    Logged:
                    Time Not Required
                    Not Specified