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

Re: Re: Re: Re: Classes Are Killing Me

by Anonymous Monk
on May 20, 2002 at 00:02 UTC ( [id://167742]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Classes Are Killing Me
in thread Classes Are Killing Me

I take all your points with the humility of a learner, but I must retort something you mistook my wordings. I never once said that book was wrong, I only stated that the code in the book was not working. There is a fine line betwixt the two, but i never really even meant to imply that the book was in any way wrong.Besides, please state the wrong assumptions that I made. If you expect to teach someone, you must define the wrong assumptions the student has made. And once more, I can read. The code you replace with mine is that of the Cookbook, from which the error was generated: cannot find object "Person" in package main. I was forced in to main before I even made my wrong assumptions. I also tried very hard to copy code correctly and right any typos on the <bold>four</bold> different modules I tried. If you read this please respond but stating the assumptions I made and correcting them. Even if you flame me at least I can move on with my lessons

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Classes Are Killing Me
by Anonymous Monk on May 20, 2002 at 03:34 UTC
    Post the code that lead you to believe that the Cookbook was wrong, and I will try to get back to you Monday evening with an explanation of why you got an error if nobody else does first.

    Based on what I know, I find it very likely that your mistaken code was something like:

    sub new { my $class = shift; return bless({},shift); }
    which resulted in an error message like:
    Can't locate object method "name" via package "main" at line 4.
    Very confusing. So you you fiddled around with the code, somehow decided that you needed to use a global before eventually hitting on changing that line by adding Person:: to the method name, which hid the underlying problem. Your experiments probably were mostly variations on the theme of telling it that you want, "Person, not main you moron!" And by the time it finally listened, you had what you posted.

    BTW that was not meant as a flame. It describes a common programming trap. Something doesn't work like it is supposed to, blame is assigned early, and the person goes into a pattern of somewhat random experimentation until something (hopefully) works. This is a natural tendancy but is horrible for programming. You need to change one thing and only one thing at a time. And random changes are probably bad ones.

    In this case, when you tried to type in examples from the book and they didn't work, you should have looked closely for how your code didn't match, and if you couldn't see it then post showing your exact code, your error message, name the book and page you are trying to copy, and say, "I don't understand why this is giving me this error message, the book says it should work?" Then someone would have told you what your mistake was, and why your mistake resulted in that error.

    Just remember this for the future. If you find yourself doing random things to get something to work, you are trapped and need to back up, break down what is happening into small logical pieces, take a break, or get outside help. Random is bad.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2024-03-28 17:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found