Boost logo

Boost :

From: Paul A Bristow (pbristow_at_[hidden])
Date: 2007-05-24 09:09:53


>-----Original Message-----
>From: boost-bounces_at_[hidden]
>[mailto:boost-bounces_at_[hidden]] On Behalf Of Jake Voytko
>Sent: 24 May 2007 03:37
>To: boost_at_[hidden]
>Subject: Re: [boost] GSoC project "Visualization of
>STLContainers as SVG" -setting options using << or
>.axis_color(red).title_font(14)...
>
>> my_graph.line_color(black).point_color(blue).x_range(-10,
>10).y_range(0, 5);
>
>Overall, I'm not against letting users use method calls to set
>parameters of classes.. sometimes, that's what they're there for.
>However, I don't feel that this is an alternative that is intuitive to
>users. When a user normally does chaining, like
>my_vector[0].to_string().find(...), they aren't expecting my_vector[0]
>to be affected. However, show a beginner the longest cout statement
>you can think of with as much chaining as you want and they'll
>understand that it all affects the printout, even if they don't know
>what a stream is! I feel that the stream operator chaining can
>immediately be grasped by beginners, as they know that since it looks
>like cout and file streams, it must affect a file somehow.

I'm surprised by this view of beginners expectations.
Using a set function is surely very common.

Although chaining is less common,
you don't have to chain, you can write:

my_graph.line_color(black);
my_graph.point_color(blue);
...

whose meaning is surely quite obvious?

but once you see an example of chaining, I feel it is obvious what to do to save a bit of typing - always popular!

Other peoples views on this?

Paul

PS Your prototype code doesn't permit chaining freely - it would intolerable in real-life use. But I'm sure you will be working on
it ;-)


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk