Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: oop, variable that counts the number of objects created

by perlfan (Vicar)
on Jul 30, 2020 at 16:22 UTC ( [id://11120071]=note: print w/replies, xml ) Need Help??


in reply to Re: oop, variable that counts the number of objects created
in thread oop, variable that counts the number of objects created

not germane to OP but generally relevant

Nice to see this example. I should probably ask this in another thread, but what's the obsession with has? Can't we (everyone not just your modules) just have blocks all the way down or superficially support something that's familiar to JAVA programmers? At this point we're just cargo culting a failed declarative approach (IMO). What are we getting beyond classic Perl OO? (sincerely want to break this down for the benefit of the overall discussion):

  • protected methods
  • strong types/checking
  • strong data encapsulation
What else? If this has been hashed out before (a true breakdown), I'd be satisfied with a link. TY!

Replies are listed 'Best First'.
Re^3: oop, variable that counts the number of objects created
by tobyink (Canon) on Jul 30, 2020 at 17:01 UTC

    Why would declaring object member variables with blocks be familiar to Java programmers?

    # Java class Car { public String name; public int price; public int speed; } # Zydeco class Car { has name ( type => Str ); has price ( type => Int ); has speed ( type => Int ); }

    Where would you add blocks to the Zydeco example to make it more like Java?

      Just a general thought, why is has so pervasive? Idk I probably should think more about what I am really trying to figure out. This is not about your modules specifically.
        why is has so pervasive?

        Because encapsulation helps prevent action at a distance, structured naming helps prevent typos in operator-typed languages such as Perl, and syntax helps disambiguate semantically different things.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2024-04-26 03:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found