News for hackers. Stuff that matters.
Re:More Dirty Coding Tricks from Game Developers (2010) by shoo on Sunday August 02, 2015 @08:31PM (#9993105)
Curious. I haven't written anything in Java for a long time so I wasn't aware that you could mark parameters as `final`, or what that would mean.

If you are working with code where you know that functions never modify their parameters then it is simpler to reason about what it does. I prefer to write code this way myself if there is no language mechanism to enforce it.

Other possible uses of `final` (to tag methods or classes) have the downside of reducing the flexibility of code by removing interfaces / "seams" that can be overridden. This reduction of flexibility will generally make things harder to test, which may or may not matter. Michael Feathers has a short article discussing this [1].

[1] Michael Feathers' "Testable Java" : http://www.objectmentor.com/resources/articles/TestableJava....

There are no comments on this comment yet.