usability implications of requiring parameters in objects
play

Usability Implications of Requiring Parameters in Objects' - PowerPoint PPT Presentation

Usability Implications of Requiring Parameters in Objects' Constructors written by Jeffrey Stylos and Steven Clarke published at ICSE 2007 talk by Dino Wernli Intent of Paper Inspect influence of constructors on API usability Default


  1. Usability Implications of Requiring Parameters in Objects' Constructors written by Jeffrey Stylos and Steven Clarke published at ICSE 2007 talk by Dino Wernli

  2. Intent of Paper  Inspect influence of constructors on API usability  Default constructor vs. required constructor  Perform study to analyze programmers at work  Draw conclusions for future API design 2

  3. Default Constructor Approach  Also called ”create-set-call” - approach  Allows objects to be created and then initialized  Uniform construction approach among all objects  Use exceptions at call time if necessary FooClass foo = new FooClass(); foo.setBar(barValue); try { foo.use(); } catch (NoBarException e) { // react approprately } 3 Default constructor example

  4. Required Constructor Approach  Only provide specific constructors  Method of ensuring proper initialization  Can guide the programmer to correct use  Less flexible, but helps enforce invariants FooClass foo = new FooClass(barValue); foo.use(); Required constructor example 4

  5. Required vs. Default Constructor  Compilte time vs. runtime handling public class Socket { public class Socket { public Socket(String host) { public Socket() { ... ... this.setHost(host); } } private String host; private String host; ... // getters and setters ... // getters and setters public void connect() public void connect() { throws NoHostException ... { } ... } } } Socket with required constructor Socket with create-set-call 5

  6. Paper Conjecture  Conjecture that required constructors  ... create more usable and self-documenting APIs  … guide programmers toward correct use  … are therefore the correct approach for APIs 6

  7. Study Methodology  Recruit 30 professional programmers  Give them programming tasks  Using APIs with default / required constructors  Debugging code written in such APIs  Gather audio and video material  Interview participants after the tasks 7

  8. Study Setup  Room with one-way mirror  Cameras, audio recorder  Instructions to think out loud 8

  9. Programming Personas  Observation: different styles of programming  Persona reflects work style only , not programming proficiency  3 different personas were analyzed in this study Programmer Systematic Opportunistic Pragmatic 9

  10. 3 Programming Personas  Systematic programmer  Top down, understand system as a whole  Pragmatic programmer  Bottom-up, but switch to top-down on fail  Opportunistic programmer  Get code working as quickly as possible  Don't understand more than necessary 10

  11. Selection Procedure Pragmatic Opportunistic Systematic Experience > 5 years > 2 years > 2 years Main C / C++ C# Visual Basic language GUI Large, focus Web Projects applications on reliability applications for windows Recruitment criteria for different persona 11

  12. General Results Reminder: conjecture stated that required constructors are superior to create-set-call  Conjecture was not confirmed  Results of the study suggest  More efficiency while using create-set-call  Programmers preferred create-set-call 12

  13. Task: File API Usage/Design  Systematic programmers: design a file API  Others: write code without IDE  Using file API the programmer would expect  Code should send contents of file by e-mail Results  All participants provided/used default constructors  Designed APIs also contained required constructors 13

  14. Task: Domain-Independent Classes  Using objects in a setting with no prior intuition  Plausible, but not understandable class names  Task consisted of correctly initializing object and then calling use() function  Compiler error vs. runtime exception Results  Many attempts to simply pass null  Exceptions more useful than compile errors 14

  15. Interview Results  Nearly all participants preferred create-set-call  Initialization flexibility – independent of creation  More control – error handling with return codes  Consistency  Less restrictive 15

  16. Study Limitations  Official limitations  Short tasks – advantage for default constructor ?  Generalization to other programming languages ?  My opinion  Very few participants – representative ?  Recruitment procedure justified ? 16

  17. Conclusion  Study suggests that create-set-call  ... is expected by many programmers  ... provides greater readability and debugability  ... gives the programmer control and flexibility → Write your APIs using default constructors! 17

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend