That's why there are so many modules on CPAN providing object-oriented feature for Perl. Class::InsideOut, Object::InsideOut,Class::Struct, Class::Methodmaker, Class::Generate etc.. Class::Accessor may be the simplest and easiest module for "easy-coding accessors". However, when I was writing my module"Net::Douban", I found setting default value for the feilds for the package is so important, which Class::Accessor dose not provide. So I spent some time hacking on this module, and wrote a module called "Class::Accessor::WithDefault" which can provide setting default value ability to Class::Accessor. It has some drawbacks because Class::Accessor using "Closure" to build the accessor and mutator but I think it is useful, right now it can be found at github here. Then I submitted this module request to CPA, sadly some days passed and I got no return message from that side.
By the way, after some coding experience with "Net::Douban", I realized that Moose should be the best choice for a Perl Progammer to write object-oriented code.

没有评论:
发表评论