Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

One thing that seems to be missing from the picture is why would the 'non-behavior-changing' aspect of attributes detract from their utility? (assuming this aspect is not in dispute).

It seems pretty straightforward to envision a circumstance where someone might want to redefine metadata about a subroutine or method, without necessarily changing its name.

If you will, please consider a simple illustration:

If you are familiar with Windows, you notice how a filename allows essentially a 'basename' plus an 'extension' ... there have been numerous times when I wished I could sort or view files based on something besides just that. In other words, don't treat all these files exactly the same just because they all have the same extension 'txt' ... I want to segment them even further.

The problem is the only workaround is to rename the files ... or append additional info to the filenames.

### before vacation_2003.txt vacation_2004.txt ### after vacation_2003.txt vacation_2004_hotels.ca.northern.txt vacation_2004_hotels.ca.southern.txt

This is unacceptable if you have external dependencies that specifically rely on the previous filenames.

The punchline is that naming files (and by analogy subroutines) is in large part an arbitrary choice, and entirely up to you. The only real constraint is that they be unique within the relevant scope. Therefore, talking about specific names people have used for their files in the past is never really going to illustrate the issue of *whether* a particular naming convention is useful for *you*.

Thus, the (at least one) point of attributes is the ability to obviate the need for name changes as the exclusive method of distinguishing certain methods and properties into arbitrary subgroups (without breaking your code).

No, this is not much more than adding little 'sticky notes' but still, that does not diminish their potential usefulness does it? This answers "how" they can be useful, but not "whether" they are useful in your specific project or circumstance, or according to your specific coding style.


In reply to Re: How Are Attributes Useful? by dimar
in thread How Are Attributes Useful? by Limbic~Region

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-04-19 09:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found