method names with fluent interface

Posted by deamon on Stack Overflow See other posts from Stack Overflow or by deamon
Published on 2010-03-19T09:52:42Z Indexed on 2010/03/19 10:01 UTC
Read the original article Hit count: 369

Filed under:
|
|
|

I have a Permissions class with methods in fluent style like this:

somePermissions.setRead(true).setWrite(false).setExecute(true)

The question is, whether I should name these methods set{Property} or only {property}. The latter would look like this:

somePermissions.read(true).write(false).execute(true)

If I look at these methods separately I would expect that read reads something, but on the other hand it is closer to the intention to have something like named paramaters like in Scala:

Permission(read=true, write=false, execute=true)

© Stack Overflow or respective owner

Related posts about naming

Related posts about fluent-interface