|
![](/i/fill.gif) |
On 5/14/2011 0:53, Warp wrote:
> Invisible<voi### [at] dev null> wrote:
>> 1. Writing
>
>> Iterator<Foo> it = list1.iterator();
>> ArrayList<Foo> list2 = new ArrayList<Foo>();
>> while (it.hasNext()) list2.add(bar(it.next()));
>
>> is way more work than writing
>
>> list2 = map bar list1
>
> Argument from verbosity is seldom a good argument in programming.
> Just because something is shorter doesn't necessarily mean it's better.
I would say in this case it is, because all the extra stuff is just
verbiage. It obscures the algorithm you're actually interested in, which is
to make a new list where each element is the old list with 'bar' applied to
it. All the stuff with the iterator and the types and all is just junk you
have to repeat wherever you need to do this.
--
Darren New, San Diego CA, USA (PST)
"Coding without comments is like
driving without turn signals."
Post a reply to this message
|
![](/i/fill.gif) |