Java Ads (Orders)

In Java, it’s usually the most common way to organize a class in terms of the order in which the declared data members and methods should be listed in the class file, bearing in mind the following and all you can think of is one for each:

  • his visibility
  • whether he is a constructor, method or member
  • if it is a method, does it overload or override other methods?
+3
source share
4 answers

I found that the conventions in the Code Conventions for the JavaTM programming language are quite suitable. Chapter 3 answers this question.

It basically ignores visibility or is an overloaded function, etc.

:

  • ()

, .

+4

, , "", - .
, Intellij IDEA ( ) Rearranger, , , , , .

+2

Eclipse (and I'm sure other IDEs) will automatically order ads (Source β†’ Sort Members) with options for types and visibility. Overloading and overriding are not available, at least in Eclipse. Thus, I would say to establish an agreement that includes the type and possibly visibility, but not overload / override status, and then configure your team IDE to impose this agreement. Automatically - and automated - standards are much easier for a team to adhere to.

+1
source

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


All Articles