Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^3: Packages with subs using fully qualified class names, not always their own.

by roboticus (Chancellor)
on Aug 31, 2017 at 17:25 UTC ( [id://1198445]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Packages with subs using fully qualified class names, not always their own.
in thread Packages with subs using fully qualified class names, not always their own.

karlgoethebier:

You're not wrong at all. Roles could be a good way to do it.

Generally I do it when:

  • It's purely a one-off thing that I'm trying to solve, and don't expect to ever need it for the class again. A frequent case is when I'm debugging something complicated that relies on a little bit of inner state of the class and a custom "toString" function in the class for logging could give me the data I need to solve the problem.
  • The class API isn't fully resolved and some of the implementation is a bit hacky. I don't want to expose the hackiness to the classes API but I need to get a problem solved. So I have no problem accessing the internals in an ugly fashion to make something happen, and let the class evolve normally without putting an ugly hack in the API that may be troublesome to remove later. (Such as when John Smith sees it and immediately uses it in production....)

I'm not saying it's a good/best practice, but that it sure is convenient.

Sorry for the long delay in replying. I've ignored my Chatterbox queue a bit too long, and now I'm trying to work through the backlog...

...roboticus

When your only tool is a hammer, all problems look like your thumb.

  • Comment on Re^3: Packages with subs using fully qualified class names, not always their own.

Replies are listed 'Best First'.
Re^4: Packages with subs using fully qualified class names, not always their own.
by karlgoethebier (Abbot) on Sep 01, 2017 at 06:32 UTC
    "...I'm not saying it's a good/best practice..."

    Thank you very much roboticus for your kind reply and the good advice.

    I'm convinced that simplicity is one of the hardest things to accomplish - in any metier.

    And i think that the combination of Class::Tiny/Role::Tiny is very close to this magic "One Size Fits All" pattern AKA the Holy Grail ;-)

    Best regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

    perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-25 05:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found