P is for Practical | |
PerlMonks |
Re: OOP's setter/getter method - is there a way to avoid them? ( what should be an object and what should it do)by Anonymous Monk |
on Oct 27, 2015 at 09:30 UTC ( [id://1146083]=note: print w/replies, xml ) | Need Help?? |
It’s also possible that I have failed to understand some key points in the chapter. not really, this book is only teaching the simplest way to write "OOP" stuff in perl in 2003 Its not trying to teach you OOP/OOAD/what should be an object, what should be a method, should I provide accessors... See http://perldoc.perl.org/perlootut.html#When-to-Use-OO See Perl Book OOPS / kind of effort required for learning OO perl ?! Is OOP considered a universal subject that it could be discussed without any reference to a particular programming language? Are there books that you could recommend on the subject? Thank you. :) yes its universal, when you search for "perl oo" or "language OO" you end up with very little discussion of WHY-oo only of "how oo", as in "bless {}" ... mechanics The book you want is https://en.wikipedia.org/wiki/Object-oriented_Software_Construction See Re: kind of effort required for learning OO perl ?! See I dislike object-oriented programming in general Damian Conway's ten rules for when to use OO See your real problem is you're thinking of objects as bags of attributes. you should be designing about responsibility, and the actions(methods) needed for such responsibility why should a Fruit be an object ? Why should a Fruit have a color and name attribute? Why should color/name have getters/setters? A Fruit should be an object that does stuff, like describe itself, it should have a describe method that returns a description like "red apple" See How do I go from procedural to object oriented programming?
In Section
Seekers of Perl Wisdom
|
|