Usability Implications of Requiring Parameters in Objects’ Constructors
Interesting finding from a research article by Jeffrey Stylos and Steven Clarke
A comparative study was
performed to assess how professional programmers
use APIs with required parameters in objects’
constructors as opposed to parameterless “default”
constructors. It was hypothesized that required
parameters would create more usable and selfdocumenting
APIs by guiding programmers toward the
correct use of objects and preventing errors. However,
in the study, it was found that, contrary to
expectations, programmers strongly preferred and
were more effective with APIs that did not require
constructor parameters.
So essentially the explicit approach of
1 2 3 | var foo = new FooClass(); foo.Bar = barValue; foo.Use(); |
was better than the denser
1 2 | var foo = new FooClass(barValue); foo.Use(); |
(code examples straight from the article.)
Tags: best practice
No Comments
Comments RSS
TrackBack Identifier URI
No comments. Be the first.
Leave a comment




