On 23 January 2014 07:34, Emmanuel Bourg <ebo...@apache.org> wrote: > Le 23/01/2014 08:03, Benedikt Ritter a écrit : >> I personally don't like alphabetically sorted classes. For example if a >> public method calls a private method, I like to have the private method >> beneath the public method that uses it. This way I can read through a claa >> top to bottom without out to much jumping back and forth. But that's just a >> matter of taste, I guess. >> >> What do others think? > > +1
As far as methods are concerned, usually I find it helpful to group them into the following general sections: group + protected package private Within a group, alphaorder is not always the most appropriate - for example getter/setter pairs more naturally belong together. Also getter/setters are not generally the most interesting methods, so can be relegated further down the file. I prefer to see related methods together (which may involve mixing private/public in the same section) I don't see the point of sorting the methods just for the sake of it. If the methods are logically grouped it can make the code much easier to follow. As far as data items are concerned, I do find it easier if they are organised in sections. Even here, there may be private fields that relate directly to a public field, in which case they should be together. Within a data section, generally the fields should be sorted, but only within functional groups. I favour logical ordering rather than strict lexicographical ordering. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org