Are booleans as method arguments unacceptable?
Posted
by koschi
on Stack Overflow
See other posts from Stack Overflow
or by koschi
Published on 2008-09-25T20:31:26Z
Indexed on
2010/03/26
18:23 UTC
Read the original article
Hit count: 118
A colleague of mine states that booleans as method arguments are not acceptable. They shall be replaced by enumerations. At first I did not see any benefit, but he gave me an example.
What's easier to understand?
file.writeData( data, true );
Or
enum WriteMode {
Append,
Overwrite
};
file.writeData( data, Append );
Now I got it! ;-)
This is definitely an example where an enumeration as second parameter makes the code much more readable.
So, what's your opinion on this topic?
© Stack Overflow or respective owner