Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Split up build_load_menu() #2272

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

ntrel
Copy link
Member

@ntrel ntrel commented Aug 23, 2019

Split out legacy code from build_load_menu() and put assign_cmd() in the middle, nearer where it's used - follow up tweak to #2256.

Move assign_cmd() above where it's used.
@elextr
Copy link
Member

elextr commented Aug 23, 2019

Both of these seem to be just waste of time noise.

Whats the point of breaking what is linear code into something that appears to be separate functionality. Disagree with it.

@ntrel ntrel changed the title build: Split up two functions build: Split up build_load_menu() Aug 24, 2019
@ntrel
Copy link
Member Author

ntrel commented Aug 24, 2019

@elextr:

these seem to be just waste of time noise

Please avoid this kind of language, it makes me uncomfortable. It sounds like you are annoyed. Obviously I do not think it is a waste of time or I would not have submitted it. I often don't submit changes I have done that aren't of clear benefit to a project.

I have removed the second commit (and updated the PR description), to avoid making a subtle argument for it. Regarding the first:

Smaller functions are easier to understand, and build_load_menu is long and complicated.
build_load_menu has 2 top-level scope variables that aren't used by load_old_menu.
load_old_menu has 4 top-level scope variables that aren't used by build_load_menu.
Each function reads different groups of data.

This should tell you that the code doesn't belong in one function.

Copy link
Member

@b4n b4n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, and I agree with @ntrel's rationale on splitting this.

@elextr
Copy link
Member

elextr commented Aug 24, 2019

Please avoid this kind of language, it makes me uncomfortable. It sounds like you are annoyed. Obviously I do not think it is a waste of time or I would not have submitted it. I often don't submit changes I have done that aren't of clear benefit to a project.

Programming is performed by people, and people have emotions. In this case the emotion is exasperation not anger. Geany is riddled with such spaghetti that divides simple linear code into sequential function calls and that makes it much harder to follow.

Not every function is actually doing something short and simple, thats just life, and breaking such code into multiple parts makes it harder to follow.

In this case the function of build_load_menu is "do this then do that", and your argument that one or two variables are not shared by this and that is irrelevant.

I'm sure we will continue to disagree on this, but thats life, @b4n will just have to keep adjudicating.

@codebrainz
Copy link
Member

codebrainz commented Aug 24, 2019

Not speaking to this PR itself, but in I tend to agree with @elextr in principle. A lot of Geany's code factoring is too granular and it makes it a pain to follow the flow when you have to keep jumping between short functions that do a small part of the overall goal. I don't think too many lines of code is - in and of itself - a valid reason to break up a function into smaller parts.

As discussed in the other PR, I'm also not fond of short helper functions which do trivial stuff everyone already understands in order to save a few lines of code. Some examples I looked at recently are the utils_free_pointers() function and the SETPTR() macro. These just increase the mental overhead required to understand the code by having to know all these functions rather than just plain C stdlib or GLib.

Sorry I'm slightly off topic here, I haven't review the changes here yet to see whether it seems justified. Maybe we could work toward some guidelines on factoring of functions as a separate discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants