Method parameters confusion

Posted by elec on Stack Overflow See other posts from Stack Overflow or by elec
Published on 2010-06-10T10:40:12Z Indexed on 2010/06/10 10:52 UTC
Read the original article Hit count: 194

Filed under:

Often time methods take more than 3 parameters which are all of the same type, eg.

void mymethod (String param1, String param2, String param3)

then it's very easy for the client to mix up the parameters orders, for instance inverting param1 and param2:

mymethod (param2, param1, param3);

...which can be the cause of much time spent debugging what should be a trivial matter.

Any tips on how to avoid this sort of mistake (apart from unit tests) ?

© Stack Overflow or respective owner

Related posts about java