mapsapi-codestyle icon indicating copy to clipboard operation
mapsapi-codestyle copied to clipboard

Mandatory return type for functions and methods

Open dmikis opened this issue 9 years ago • 3 comments

I suggest we add to the code style a requirement for functions and methods to always have return type specified explicitly. There're two points behind this.

  1. Signature of a function (and of a method) is documentation for fellow developers. Thus, leaving it to the compiler to infer adds a burden on a human who reads your code to do the same job.
  2. There's always a chance to get it plainly wrong with either a wrong guess (you meant one type, compiler inferred another) or break things later possibly in an ambiguous manner. I.e., let's say leave for the compiler to infer some types from function's return type that gets inferred itself. If it changes, compilation errors will arise from usage sights of those variables, not on call sights of the function.

dmikis avatar Jul 17 '17 14:07 dmikis

I agree in general, but when I need implement some interface I often omit return type, because specify its in each implementation is little annoying.

ikokostya avatar Jul 17 '17 14:07 ikokostya

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 26 '18 22:04 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 06 '18 22:07 stale[bot]