in reply to const correctness
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.
My criteria for good software:
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:
- Does it work?
- Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: const correctness
by fergal (Chaplain) on May 14, 2008 at 13:56 UTC | |
by BrowserUk (Patriarch) on May 14, 2008 at 14:47 UTC | |
Re^2: const correctness
by amarquis (Curate) on May 14, 2008 at 14:00 UTC |
In Section
Meditations