in reply to Anyone migrated to the new 'class' way of OOP?

I'm refraining. I've contributed to arguments on this topic, but I particularly don't like the constructor pattern. One of the things that makes Moo an improvement over Java/C++ is that Java and C++ require you to have all your arguments prepared and organized before the constructor runs. That can get really hard sometimes when there are complex dependencies between attributes, and Object::Pad falls into this trap. Moo's (and Moose's) feature of lazy-built attributes is a very elegant solution to the problem because it automatically figures out what order to initialize the attributes, and that order can change depending on the subclass.

While I have to admit that the new syntax looks a lot nicer, a downside is that I feel obligated to indent everything inside the class{} block which means my entire implementation ends up with an extra layer of indent.

Combined with the version requirements (and how most of my CPAN modules aim for older compatibility) and the fact that I'm constantly using lazy-build and coerce, I don't think I'll be using it any time soon.

  • Comment on Re: Anyone migrated to the new 'class' way of OOP?

Replies are listed 'Best First'.
Re^2: Anyone migrated to the new 'class' way of OOP?
by jo37 (Curate) on Aug 10, 2025 at 18:17 UTC

    As an old-school, stubborn bless adherer I'm not going to advocate for the new class system. But I don't think that

    a downside is that I feel obligated to indent everything inside the class{} block

    is an issue. class can be used the same way as package in block or statement syntax. See class.

    Greetings,
    🐻

    $gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$
      I feel the same about package with a block.
      Oh interesting, I hadn't seen that syntax option before. Clearly I'm not keeping very close tabs on the progress of the feature.