Thursday 15 December 2016

New feature in IntelliJ


In the User Interface in the new version of IntelliJ1, version 2016.32, a new feature popped up called "Parameter hints"3.

My colleague at work has some strong feelings about it.

He feels that the feature provides the lazy programmer with an excuse not to provide properly typed parameters in a method definition (too many String/Boolean/Long and not enough OrderedItem for example). It also would allow the lazy programmer to create methods with 5 parameters or more, as the IDE helps you identify what they are.

Uncle Bob4 mentions that anything over three requires some serious soul searching.

My colleague and I both feel that a few of the methods in our software are suffering from an excess of parameters. Even worse, that a lot of these parameters are Booleans that function as switches to alter the behaviour of the method in some way. A code smell, to be sure.

Some solutions, although this blog post does not actually focus on it, is using either a configuration object that contains the parameters4 or perhaps a builder.

References

[1] IntelliJ IDEA the Java IDE
https://www.jetbrains.com/idea/
[2] What's New in IntelliJ IDEA 2016.3
https://www.jetbrains.com/idea/whatsnew/
[3] Parameter Hints in IntelliJ IDEA 2016.3 - YouTube
https://www.youtube.com/watch?v=ZfYOddEmaRw&feature=youtu.be
[4] Clean Code, page 40
Robert C. Martin
[5] Introduce parameter object
https://sourcemaking.com/refactoring/introduce-parameter-object

No comments:

Post a Comment