Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
First off, Perl has Readonly and constant which provide the same functionality. And, every single (usable) OO framework on CPAN allows you to specify accessors as separate from mutators, should you so choose.

Now, to some commentary.

  • Proper objects don't give you access to their state. That is a first-order violation of encapsulation. If you're peeking and poking at internal state, you don't have an object - you have a data structure with behavior. This is no better than the OO provided by Javascript. While I'm a fan of the prototype style of OO, it's not very useful from a sanity perspective.
  • I understand the sanity perspective when dealing with constants. But, I gotta tell you - I've been coding Perl for almost 13 years now and I have yet to run into a situation where I needed constants. The fact that I have never used Readonly and don't reach for constant in my own code should be telling. Frankly, I tend to use some sort of configuration object that exposes appropriate values through methods (not accessors!) and takes its initialization from some sort of config process (file, commandline, %ENV, etc). This is what DBM::Deep does and it works quite nicely.

My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

In reply to Re: const correctness by dragonchild
in thread const correctness by John M. Dlugosz

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 learning in the Monastery: (8)
As of 2024-04-24 10:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found