Item11951: Foswiki::Address shouldn't carry any state. Work towards making instances immutable.

pencil
Priority: Enhancement
Current State: Being Worked On
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: FoswikiAddress
Branches: Release01x01 trunk
Reported By: PaulHarvey
Waiting For: PaulHarvey
Last Change By: PaulHarvey
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

 

ItemTemplate edit

Summary Foswiki::Address shouldn't carry any state. Work towards making instances immutable.
ReportedBy PaulHarvey
Codebase trunk
SVN Range
AppliesTo Extension
Component FoswikiAddress
Priority Enhancement
CurrentState Being Worked On
WaitingFor PaulHarvey
Checkins distro:9f0fd4d6920c distro:f1bbda239f5e distro:5e7898dedb8c
TargetRelease n/a
ReleasedIn n/a
CheckinsOnBranches Release01x01 trunk
trunkCheckins distro:9f0fd4d6920c distro:f1bbda239f5e
Release01x01Checkins distro:5e7898dedb8c
Topic revision: r4 - 16 Jun 2012, PaulHarvey
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy