Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

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.


In reply to (counter-intuitive) Re: a simple example OO script by Anonymous Monk
in thread A simple example OO script for total beginners by bl0rf

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (11)
    As of 2014-10-01 16:47 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      What is your favourite meta-syntactic variable name?














      Results (29 votes), past polls