Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^5: Unclear about 'our'

by haukex (Archbishop)
on Dec 28, 2022 at 17:55 UTC ( [id://11149173]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Unclear about 'our'
in thread Unclear about 'our'

I think it's fair to say that, in object-oriented design, the fields/attributes/properties/member variables of a class are a common pool of variables shared by subroutines/methods.

I'd look at it differently - while of course the subs are part of the class and technically all objects of the class share them, each object is a separate entity, so I'd look at it as each object having its own copy of the instance variables - or in Perl, really just one variable, typically referred to as $self. I would not expect to see any variables declared outside of the subs of the class, perhaps the only exception being default settings like I showed here.

(The concept of Inside Out objects also exists, but I practically never see that in the wild and personally wouldn't suggest it.)

Replies are listed 'Best First'.
Re^6: Unclear about 'our'
by ibm1620 (Hermit) on Dec 28, 2022 at 20:48 UTC
    I see what you mean. Now that I have read a bit about OO Perl I see that what I've been creating would be considered "class variables" (a.k.a. static member variables) in C++, which is the extent of my OO experience. As you point out, they have their place, but they're not the same as instance variables.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-03-29 02:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found