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

Re^3: Can a Perl module "inspect" itself and provide details about methods and parameters?

by stevieb (Canon)
on Sep 21, 2019 at 22:42 UTC ( [id://11106522]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Can a Perl module "inspect" itself and provide details about methods and parameters?
in thread Can a Perl module "inspect" itself and provide details about methods and parameters?

"This part is just sad: if objects were self-documenting, then they wouldn't have to rely on the existence of (good) external documentation."

When I'm writing against an object, my IDE pops up with a list of valid methods to choose from, and autocompletes if I desire. To boot, once I've typed in the method name, it'll display to me what arguments the method (or function) accepts. Now, if the function/method is accepting a single hash for example, there's no way to know at all what key/value pairs are used within that hash. However, if all of the parameters are individual scalars in a specific order, it will list those (with their names included).

Here's an image showing the IDE displaying a list of available methods to an external class (works on objects all the same).

...and here's an image showing the parameters for an object's method.

A good IDE can help tremendously, especially when you're working with numerous classes at the same time. You can CTRL-click on any variable, method, function or anything, and you can make one click to go to the definition of it immediately.

Rarely do I need to view documentation online, or the command line. Typically in Perl, we gather up all of our parameters at the top of each subroutine, so being able to go directly to the definition of a sub makes it trivial to see exactly how params are being used.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-03-29 12:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found