4 ms·
Nope. I'm right with you on this. Personally, I would go farther--I would say that Moose stuff is actually value negative. For a simple thing like this, it m
by dstorrs 17y ago
Nope. I'm right with you on this. Personally, I would go farther--I would say that Moose stuff is actually value negative.
For a simple thing like this, it makes perfect sense to use a simple procedural style and keep it in one file. The Moose version just complicates it beyond necessity. That's true of plenty of real-world programs, too.
- draegtun 17y agoThe Moose example separates the business & display logic. So its easy to slot in another display class when needed: extends qw(AnimalsGame HTMLGame); NB. Personally I would probably have used roles rather than multiple inheritance though.
- jrockway 17y agoThe Moose version just complicates it beyond necessity. That's true of plenty of real-world programs, too. Learn what object-oriented programming is, then come back and tell us what you think.
- chromatic 17y agoFor the example given? Nonsense. It's very difficult to choose good examples for programming tutorials. In this case, the example was too small and self-contained to support modern Perl practices intended to help manage programs of hundreds of lines or more.
- jrockway 17y agoDunno, I use Moose for my small scripts and find them to be significantly more maintainable than they would be if they were a bunch of code in a file. Hence MooseX::Runnable. "Procedural programming" is a generally meaningless term (even less meaningful than "object-oriented programming"), but I find opportunities for abstraction even in small programs. The procedural makes it difficult to exploit these opportunities.
- ajross 17y agoAgain, that's kind of a straw man. All scripts are "just a bunch of code in a file". You're equating your organization using Moose to the inability to organize code without it, which is silly. You're also equating "abstration" with "good", which it isn't. You abstract for practical reasons, not for its own sake.
- jrockway 17y agoThe abstraction makes it easy to reuse parts of your "one-off" scripts. For example, look at the number of CPAN modules/programs that implement some sort "restart when file is changed" functionality. There are a lot. If you use MooseX::Runnable, though, you write an introspectable class instead of a script. Now a plugin can handle adding this functionality to your script in a structured way, and all you, the developer, have to do is say "mx-run +Restart::Auto My::Class" instead of implementing that functionality manually in your script. Reuse is always good. Not writing code is even better.
- ajross 17y agoBut... the example was all there was. This wasn't an article with a core point that simply picked a bad example. There's almost no text. If the code exhibited isn't good enough to make the point, then what point is there to be made?
- chromatic 17y agoI understood the point only because I have practical experience working with large amounts of Perl 5 code in every stage of the mentioned enlightenment. The example worked for me; it won't work for people without that experience.