Java – place instance variable declarations

I've seen some developers put instance variable declarations at the end of the class, although I mainly see them at the top The only reason I can think of doing this is style preferences, or making them easier to use in the ide in some way Is there a more reasonable reason to choose this style?

Solution

Because "program to a" interface, not an "implementation" (Gang of Four 1995:18)( http://en.wikipedia.org/wiki/Design_Patterns#Introduction.2C_Chapter_1 ), some people like to declare instance variables at the bottom of a class The theory is that users of a class are more interested in what the class (method) can do than what (variable) When methods are placed at the top of a class, they are first exposed to the user when the user views the code

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>