Item11951: Foswiki::Address shouldn't carry any state. Work towards making instances immutable.
Priority: Enhancement
Current State: Being Worked On
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: FoswikiAddress
Branches: Release01x01 trunk
I've been using Moose a lot lately, which has a kind-of-not-really-type system that only (properly) works without caveats at create-time.
Apart from that, objects shouldn't carry any state they don't need. Also, we might want to make
Foswiki::Address->new()
return the same instance for the same resource, which isn't possible if we're carrying around state that's not relevant to the resource.
See also
http://www.modernperlbooks.com/mt/2012/05/when-you-cant-misuse-the-immutable.html
Basically, I'm:
- Deleting parse state & options as data members
- Making
parse()
a private method
-
stringify()
no longer takes any options. You get what you're given (in terms of web & topic separators).
- If you believe the
AddressTests::test_timing_foo
results, this has resulted in speedups of a few percent up to almost 20%.
--
PaulHarvey - 15 Jun 2012