Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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

by tobyink (Canon)
on Jul 30, 2020 at 17:01 UTC ( [id://11120074]=note: print w/replies, xml ) Need Help??


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

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?

Replies are listed 'Best First'.
Re^4: oop, variable that counts the number of objects created
by perlfan (Vicar) on Jul 30, 2020 at 18:45 UTC
    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.

        Because encapsulation helps prevent action at a distance, structured naming helps prevent typos

        And here I go on an irrelevant-to-OP tirade again, sorry.

        Is Perl's business to prevent action at a distance and typos? Educate, supervise, mentor and pay a developer more and they will be more careful. Then, code reviews can reveal practices which are considered "bad" by management (i.e. action at a distance).

        IMO encapsulation means encapsulation of the program logic. Creating a black box which goes out and hunt. Encapsulation, for me, does not mean protecting each and every variable in there from sloppy devs, although I am sure there will be countless "software" "engineering" "books" out there promoting this hysteria. Hey, why don't we enclose each Object within a firewall for good measure? That's the nanny-state of programming.

        But that's exactly what it came to mean today. It's this industry alone which promoted all those sloppy devs or rather the sloppy dev processes and "key-hole programming". The current meaning of the word encapsulation brings to my mind all those phone chargers which have been encapsulated in raisin so hard one can not remove a single piece of copper from them or fix them. For safety, they claimed. But in the 3rd-world's dump heaps which inevitably said chargers end up they are "de-capsulated" really well in true Gordian fashion: burn the plastic and melt them in acid, which kills them poors and the planet too.

        Personally, I don't want to see Perl "polluted" by new keywords and new syntax. Aesthetically, at least, I am not comfortable with the "has" and friends. So I only use the minimalist (classic) OO provided by core Perl. KISS. But I also see the point of view of the others who do like or rather need, and use them. Fine.

        Subjective, personal opinions: I consider OOP a real step forward, like Man standing on 2 feet. Judging from PM questions (a very rough indicator) OOP+Perl is used by only few. Even using packages alone to encapsulate and separate program logic is not the commonest practice. I would concentrate on making these two things much more accessible than actually alienating users by enforcing extra nomenclature like "has" (see where make-a-keyword-a-day Java ended up). I said before, albeit being ignorant about the details: those who can, perhaps could spend their effort in modernising the perlguts instead. Or offer us mortals truly accessible, simple documentation to perlguts and XS so we can be educated and participate. "has" can wait AFAIC (and so can function signatures).

        I wake up each day in fear that Hashtables fall to the hands of "language revisionists" (sorry!) (re: typos of keys). That will be a slaughter.

        I welcome down-voting as a means of "silent" disagreement.

        bw, bliako

        I am not asking what it does. I am asking why it's literally "has" and the declarative pattern is used so widely.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-19 13:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found