r678354 added yet another mutator to HttpResponse.  Kevin suggested
that this is less than ideal:

-----------
Why add a new method for this instead of passing the headers in the ctor?
HttpResponse is already very problematic, as it should be immutable, but we
keep adding mutators to it. It's very hard to implement a cache of objects
when the data in the cache can be modified, and as a result most caches have
to be written more defensively than necessary, with copies being produced on
every read.
-----------

We keep adding mutators to it because it's a serious pain to construct
objects using umpteen different parameters, especially when all of
those parameters are strings.  I feel your pain about it's lack of
immutability, though.  I'm not sure of the best way to handle this.
Maybe a freeze() method that marks the object as immutable at some
point after contruction?  Maybe bite the bullet, declare it really
truly immutable, and forbid attempts to make it otherwise?

HTTP responses are complicated beasts.  I don't know of any
programming framework that tries to make them immutable, it's just too
annoying to work with.

Cheers,
Brian

Reply via email to