3 Replies Latest reply on Aug 6, 2007 7:28 AM by tom.baeyens

    Wire Descriptors

    porcherg

      Hi,

      I am trying to understand how the wiring context works and to document the files.

      In the Descriptors implementations (for example BooleanDescriptor), we have a no-arg constructor, setters and getters. Should we use these methods only for the persistence framework ?

      Because in the constructor BooleanDescriptor(Boolean b) we check that b is not null and we throw an exception if it's null.
      In setValue(Boolean b) no such check is performed.

      If the setValue method can be used directly, maybe we should add the check.

      regards, Guillaume

        • 1. Re: Wire Descriptors
          tom.baeyens

          for persistence i want to use field injection

          as for the exceptions, i'm not a fan of preventive exceptions. throw only an exception when you have to. otherwise you always end up in situations where you want to do something strange to make it work and then you're blocked by some exception.

          also, since all of the code is under our control, it is another reason why i don't think boolean discriptor null checking should require an exception. i mean that the parsers that create the boolean descriptor is written by us, not users of our code. if we test that properly, we don't need the extra kilobytes of jar for checking all these things.

          when thinking of exceptions, always put yourself in the perspective of the client. what kind of exception does he need to see ? in this case, it's an exception that the client should never see.

          • 2. Re: Wire Descriptors
            porcherg

            Do you mean we should remove the Exception from Constructors ?

            This way we would have the same behavior in constructors and in the setter methods (and the user will never get this kind of exception when creating context).

            Guillaume

            • 3. Re: Wire Descriptors
              tom.baeyens

              (ah... only now i saw that i did the original check and exception throwing :)

              indeed. using only default constructors in combination with plain setters is better.

              if you want you can bring the descriptors all in sync with that approach.