http://www.perlmonks.org?node_id=675653


in reply to Re^3: Moose - nalia
in thread Moose - nalia

Thanks again stvn,

You are too gracious, and too modest!

I see now exactly why builder was not doing what I needed.

Of course, if the attributes are not marked as 'lazy', then that insta +nce may not be built/initialized completely. My basic rule is that if + you want to use the value of another attribute in your 'default' or +'builder' then make that attribute 'lazy'.
Thanks so much for the clarification and help. I was uncomfortable using trigger for initialization although it served my immediate needs, and will switch to builder with the use of 'lazy'. Thanks for divining my needs.

My clients and I thank you for this very useful software. I just rewrote and cleaned up a module that was getting unwieldy. Moose does exaclty what good software should do; it allows me to work on higher order problems. And it makes for cleaner and more extensible software. It also allows for rapid development. I rewrote in a couple of mellow days what would have taken much longer and I have all the features that I need for rapid, reliable dev at my fingertips. Excellent work.

Also, thanks for the advice on overriding &new. Not an advantageous use of Moose.

One more question. Any advice on test driven development in Moose? Any preferred testing idioms? Any affordances or most optimal leveraging of Moose and testing idioms?

Replies are listed 'Best First'.
Re^5: Moose - nalia
by stvn (Monsignor) on Mar 23, 2008 at 01:28 UTC
    Any advice on test driven development in Moose? Any preferred testing idioms? Any affordances or most optimal leveraging of Moose and testing idioms?

    I write my tests with Moose the same way I wrote them without Moose actually, using Test::More and friends. We do have a Test::Moose module included in the distro which provides a few helpers, it is a relatively new module too, so any ideas for additional testing functions are welcome.

    The only real difference between my pre-Moose tests and the tests I write now is that I am no longer testing things like accessors or object creation or correct type usage, cause I know that Moose tests all that for me. The Moose test suite currently has 2926 test across 133 files, and the Class::MOP test suite has 1971 test across 56 files, in addition to this we regularly smoke test the MooseX:: modules in our svn repository which adds another thousand tests or so. Because of this, I feel pretty confident that I only need to test what it is my module does, and not that the OO is working correctly. This is not unlike writing tests in a compiled and statically typed language like Java, Haskell or OCaml, in those languages the compiler will do a kind of sanity check on the code, leaving you to just test what it is your code actually does.

    -stvn