Beefy Boxes and Bandwidth Generously Provided by pair Networks
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??


in reply to OOP's setter/getter method - is there a way to avoid them?

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 •Re: OO Getters/Setters

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?

See High level OOP query

Replies are listed 'Best First'.
Re^2: OOP's setter/getter method - is there a way to avoid them? ( what should be an object and what should it do)
by tiny_monk (Sexton) on Oct 27, 2015 at 10:27 UTC

    Thank you for generously suggesting different resources. And, yes, you have valid points and questions. They are all worth considering. I'm still learning that it takes a special way of looking at things when using an object-oriented style of programming. I'm afraid that my concept of class object has not fully evolved yet. It's hard to transition from the mundane concept of an object as a mere instance of a class to the concept that objects (even supposedly inanimate objects such as apple) could actually behave like living objects that bring forth methods or actions (i.e. saying "I am a red apple"). :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1146083]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-03-29 06:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found