Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
XP is just a number
 
PerlMonks  

(counter-intuitive) Re: a simple example OO script

by Anonymous Monk
on Sep 05, 2003 at 05:16 UTC ( [id://289140]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to A simple example OO script for total beginners

If I were a total beginner and I needed to know how to create an object, after this example I would be able to go through my first module.

However, if I were a total beginner, I would be also totally ignorant about objects and what they are.

More specifically, if I were a total beginner, I would be used to work with numbers in this way:

$n = 7; $n = $n + 3; # or if I am less than a beginner $n += 3; # $n = $n - 5; $n = 99999;

Therefore I would be more than puzzled with your example that changes my way of dealing with numbers from $n += 3 to $obj->add(3) without any visible benefit for this additional burden.

So, if I were a total beginner, from your example I would probably learn what to do, but not why.

What I am getting at is that Object Oriented programming is supposed to make things easier for the programmer, not more difficult. The purpose of OOP is to imitate reality. That's why there are objects. SO your example would have been more attractive if you were talking about something we can see and touch, such as cars or books.

There are some better examples available in the Monastery. Have a look at our Tutorials section.

Also, your example would look much bettere if it was properly formatted. Consider using perltidy, or some smart editor.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://289140]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.