Java Method Declaration Convention

Is there any agreement in Java about where to declare fields - before or after methods?

+3
source share
7 answers

Class layout: see here http://java.sun.com/docs/codeconv/html/CodeConventions.doc2.html#1852

The following table describes the parts of a class or interface declaration in the order in which they should appear

  • Comment on the class / interface documentation (/*.../)
  • class or interface operator
  • Comment on the implementation of the class / interface (/.../), if necessary
  • Class (static) variables
  • Instance variables
  • Constructors
  • Methods
+5
source

.

0

. , , ( , :). , , . , . !

0

, , . , ++ , . ; , .

0

Sun " Java" , : , , , .

However, this part of the conventions is not quite as widely confirmed as the others: when using unclassified class names or variable names with capital letters, the overwhelming majority of Java programmers immediately protest, many of them agree to place fields next to the methods that act on them.

0
source

Source: https://habr.com/ru/post/1785531/


All Articles