Optimization of Distance Between Methods in Single Java Class

33 views
Skip to first unread message

Owen Shadburne

unread,
Mar 1, 2024, 4:26:36 PMMar 1
to checkstyle-devel
Hey everyone! I'm Owen Shadburne. I am really interested in this project idea for the Google Summer of Code 2024 and would love to discuss this idea with mentors. I mainly wanted to discuss the basis of the algorithm being used for this idea and the positions of important methods in a class. I wanted info particularly on the following:

1. Should accessor methods be reordered, or should they stay at the top of classes?

2. Should every "parent" method that calls a "child" method appear first, even if it increases the distance between the methods? Example: 

Method A() {
    C();
}
Method C() {}
Method B() {
    C();
}

This order uses the minimal distance, but highly disrupts the regular, hierarchical-like order to writing methods we typically see.

3. "Helper" methods -- methods that are called several times throughout the class, by multiple different methods -- where should they go? The minimal distance that follows appearing below every one of its "parents" would be directly after its final parent, but this may disrupt more relevant children that follow this last parent. Would it be better to place this helper method at the bottom or closer to the bottom of the file since it is used so commonly, or is there a better solution?

Thanks for the insight! I hope to get to talk more often here!
-- Owen Shadburne

Owen Shadburne

unread,
Mar 1, 2024, 4:28:43 PMMar 1
to checkstyle-devel
Forgot to mention: my username on GitHub is CubeTures. I've submitted a couple of PRs already and can link those if you'd like.
Reply all
Reply to author
Forward
0 new messages