[Marble-devel] Marble FileStorageWatcher
Torsten Rahn
rahn at kde.org
Fri Mar 13 08:59:51 CET 2009
On Friday 13 March 2009 07:54:42 Mülner, Helmut wrote:
> > setFeature(bool)
> Do you mean "The Boolean Parameter Trap"? ;-)
Actually no :-)
There is a pretty strict line between providing getters and setters for a
boolean property and the scenario of the "Boolean Parameter Trap". And both
gets covered in the link that I've sent:
For boolean properties it makes sense of course to have setters and getters
along the line of:
void setBoolProperty( bool )
bool boolProperty() const
.... as long as the function name clearly and unmistakenly indicates what the
bool is about:
See the subchapter "Naming Boolean Getters, Setters, and Properties" for some
details (you need to scroll down a bit):
http://doc.trolltech.com/qq/qq13-apis.html#theartofnaming
The boolean parameter trap on the other hand is the scenario where people add
a bool (or an int) to an existing function where the semantic relationship
between the primary intent of the method and the parameter gets lost (or even
worse: is misleading, see the widget->repaint(false); ) method in the article.
Once the semantic is lost for a function it's just convenient to add even more
boolean parameters and that's where the boolean parameter trap starts to
become very apparent. See:
http://doc.trolltech.com/qq/qq13-apis.html#thebooleanparametertrap
One solution to deal with meaningless boolean parameters is the usage of flags:
http://techbase.kde.org/Policies/Library_Code_Policy#Flags
Best Regards,
Torsten
> Best regards,
>
> Helmut
More information about the Marble-devel
mailing list