Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Re: perl6 & OO

by hardburn (Abbot)
on Feb 19, 2004 at 20:28 UTC ( #330347=note: print w/replies, xml ) Need Help??


in reply to Re: perl6 & OO
in thread perl6 & OO

No. Thinking about objects in terms of fancy data strucutres tends to lead to bad OO design. One of my personal rules is that bad OO is worse than no OO at all. Perl's bless object system doesn't help this state, because it comes right out and says "Hi, I'm a datastructure, and now I'm an object, too!", whereas most languages have the good sense to hide this dirty little secret.

The trick to thinking in OO is to stop thinking about the underlieing data. You can know it's there, but you don't touch it yourself. Instead, you're calling methods that provide the means to munge the data in predefined ways.

----
: () { :|:& };:

Note: All code is untested, unless otherwise stated

Replies are listed 'Best First'.
Re: Re: Re: perl6 & OO
by awwaiid (Friar) on Feb 19, 2004 at 20:49 UTC

    I think you bring up a very important point about OOP. Perhaps this is the difference between an imperative view and a functional view. Your view, which I'm taking to be the imperative view, might say that we do things with objects. We command them to keep track of a new setting or to tell us about themselves.

    In the functional view we would instead say that an object is more of an expert -- an expert at manipulating a specific data structure. We give it the old data structure and ask for a manipulation and it gives us back a new data structure. You could think of each and every method as a function which maps the old datastructure onto the new one. Often functional languages which have objects use this viewpoint, and for me Perl does too.

    But thats one of the reasons that perl is so cool... you can look at it either way :)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2021-10-19 19:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (77 votes). Check out past polls.

    Notices?