Whether or not to name Boolean parameters in Scala def execute(parameterName : scala.Boolean = { /* compiled code */ })


When calling this method, you can go with

someobject.execute(true)


or

someobject.execute(parameterName = true)


If you use the former, IntelliJ pops up a recommendation stating that Boolean arguments should be named. But doesn't this introduce an unnecessary dependency on the name of the parameter? Essentially the name of the parameter becomes part of the interface.

If I then change the name of parameterName in execute() to something else, I potentially break a lot of code that is using the execute method.

I understand that it improves readability a bit (you can look at the code and see which Boolean is being set to true without having to look at the called method). But is it enough of an advantage?
Personally, I think it's a reasonable suggestion.


If you change the parameter name in a way that changes its meaning, it's a good thing that the code using the old name doesn't compile anymore.
If you change the parameter name, keep the meaning the same and all your code is in the same solution, then your IDE should be able to rename all usages at the same time.
If you change the parameter name, keep the meaning the same, but your code is not all in the same solution (e.g. when you're writing a library used by third parties), then somebody could be using this practice, no matter what you use. So, the name is already part of the interface, no matter what you use.


There is a middle ground where all your code is not in the same solution, but you have control over all of it (e.g. by specifying coding guidelines for your company). In this case, you might decide that it's an unnecessary dependency. But in all the other cases, I think that using named parameter often makes sense.