chromatic's book explains how to do it the modern way (Moose), but does not say very much about object orientation in general.
Sure, that's not the point of the chapter. Even so, I like to think that principles such as "favor composition over inheritance", "take advantage of encapsulation", and "define your interfaces well" come across clearly. Then there's the Advanced Perl OO section which goes into LSP, DRY, and even immutability (which is present, though not made explicit, in almost all of the examples in the code and the rest of the book).
I thought about adding SOLID or at least Open-Closed, but couldn't find the right way to work it in in further detail.
| [reply] |
Hi chromatic,
I definitely agree with you. I hope you didn't interpret my comment as a critique of your book, which it is definitely not. In fact, I found Modern Perl so useful and good that I bought the paper copy after having read it on-line. I even co-translated it into French (https://perl.developpez.com/tutoriels/perl/modern-perl-2014/) about 3 years ago. And I have learned quite a lot from reading this book, including especially from the OOP chapter. My point was just that your book couldn't cover in just one chapter as much as what Damian is covering in a full book.
| [reply] |
No critique taken! I just wanted to give some context that's not always obvious to readers.
My goal is to teach good OO programming in Perl without having to focus on the mechanism of making objects; that's why I started with Moose first, went into design principles, returned to core syntax, and then gave pointers to advanced topics.
| [reply] |
You are absolutely correct. I really tried to follow-up in my post by adding other resources that were more about the theory and application of Object Oriented design. But unfortunately I couldn't come up with just one or two comprehensive resources. Even as I try now to list out a few that stand out for me I realize that there are simply too many, and although the Design Patterns gang of four book stands out, it is not an intro, or even a comprehensive explanation of OO. Someone newer to the concepts probably has a better recollection of the thing that really flicked the light bulb on.
| [reply] |
| [reply] |