Leo Sutic wrote:
<snip/>

and another good read! Is this all part of a "let's keep Berin around" campaign? :D

summary: we want to write just a little bit of code to handle configuration, and with that, have strong validation of our invariants and other types of assertions.

You highlight one way it could be done using javadoc tags, reflection and a configure() method which is essentially a validateInvariants() method.

IMHO: Too Much Magic!

You probably already knew that I was going to say that ;). Maybe we need to delve into .Net, where we wouldn't be needing a language extension...

Other possible 'solutions' include AOP-based validation (lots of AspectJ samples around), ugly xml-based interceptor validation (XWork, I think HiveMind as well), and...constructor dependency injection:

    public class Radar {
        private int minRange;
        private int maxRange;

        public Radar( int maxRange, int minRange )
        {
          // easy to do the ordering here :D
          setMaxRange( maxRange );
          setMinRange( minRange );
        }

        // made these protected; you could make them private
        protected void setMaxRange (int _maxRange)
        {
            if (_maxRange < minRange)
                throw new IllegalArgumentException(
                  "maxRange < minRange");

            maxRange = _maxRange;
        }

        protected void setMinRange (int _minRange)
        {
            if (_minRange > maxRange)
                throw new IllegalArgumentException(
                  "minRange > maxRange");

            minRange = _minRange;
        }

        // ...
    }
--
cheers,

- Leo Simons

-----------------------------------------------------------------------
Weblog              -- http://leosimons.com/
IoC Component Glue  -- http://jicarilla.org/
Articles & Opinions -- http://articles.leosimons.com/
-----------------------------------------------------------------------
"We started off trying to set up a small anarchist community, but
 people wouldn't obey the rules."
                                                        -- Alan Bennett



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to