Uploaded image for project: 'Tapestry'
  1. Tapestry
  2. TAPESTRY-1111

Throw an exception when trying to access an uninitialized property

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Reopened
    • Major
    • Resolution: Unresolved
    • 4.0
    • 4.1.7
    • tapestry-core
    • None

    Description

      If you do not specify a default value for a property (e.g. with @InitialValue), it gets initialized to a default value selected by Tapestry. This creates lots of opportunities for confusion and bugs. I suggest that instead, the property should be marked internally as "uninitialized". If you attempt to get its value while it is in that state, it should throw an exception. Looking up a property before its value has been set is almost always an error. It is much better to immediately alert the user so they can fix the bug, rather than letting their program appear to work, but misbehave in some possibly subtle way.

      This applies to any situation where you try to access a value that is not currently available. For example, if you try to access a persistent property inside pageAttached(), it should throw an exception rather than simply returning null.

      Attachments

        Activity

          People

            jkuhnert Jesse Kuhnert
            peastman Peter Eastman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: