Skip to content

Refactor MakeMaker.pm #189

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

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

Conversation

mohawk2
Copy link
Member

@mohawk2 mohawk2 commented Dec 28, 2014

Mainly breaking MM->new up from being nearly 400 lines, to 40ish. Done as part of effort to implement extensions but turns out best way forward on that is orthogonal.

@mohawk2 mohawk2 force-pushed the refactor branch 13 times, most recently from 681a138 to d9d5c90 Compare January 1, 2015 19:59
@haarg
Copy link
Member

haarg commented Jan 1, 2015

Aside from a couple small nits, this looks pretty good to me.

@mohawk2 mohawk2 force-pushed the refactor branch 2 times, most recently from 0492511 to 5b6d25c Compare January 4, 2015 06:19
@mohawk2 mohawk2 changed the title Refactor MakeMaker.pm plus test Refactor MakeMaker.pm Jan 4, 2015
@mohawk2 mohawk2 force-pushed the refactor branch 2 times, most recently from dc6f4c1 to a2c2fe6 Compare January 5, 2015 06:59
@mohawk2 mohawk2 force-pushed the refactor branch 2 times, most recently from 7fec702 to 2e535db Compare January 18, 2015 15:22
@Leont
Copy link
Member

Leont commented Jul 1, 2015

To quote @ribasushi

As far as the larger ticket - step back explain what you are trying to achieve with this sort of cleanup. So far it only seems to be done for the sake of... cleaning up. Which baffles me.

This whole breaking up the new method is superficial at best. Whether we use one big method or a dozen smaller ones, we're still setting up a god object with unpredictable action at a distance. This is the kind of refactor that makes us feel good because wise men have told us that methods should be small, but doesn't address any of the fundamental design mistakes. All it does is distributing the crap for the sake of dogma.

I'm not convinced that this makes the codebase any better.

@mohawk2
Copy link
Member Author

mohawk2 commented Jul 5, 2015

I went through the 400-line "new" method (which isn't an accurate description of what it does), and couldn't understand what it did. I now understand what the various parts of it do, and claim it is far easier for others to do so as well. We may be stuck with the poor design of it doing too much, because of back-compat (I found modules that rely on current behaviour), but I didn't think we were stuck with incomprehensibe code?

@Leont
Copy link
Member

Leont commented Jul 5, 2015

and claim it is far easier for others to do so as well.

The init_* methods are similarly cut up in 19 pieces and I never found that to be particularly helpful. new is currently a long list of code that is run serially but interdepends in non-obvious ways, and after the breakup it is still a long list of code that is run serially but interdepends in non-obvious ways.

I don't oppose refactoring this (in fact I like some of it), but I don't think it should be approached this mechanically.

We may be stuck with the poor design of it doing too much, because of back-compat (I found modules that rely on current behaviour), but I didn't think we were stuck with incomprehensibe code?

You're missing my point entirely.

First of all, its length may be ugly but that's not the same as incomprehensible. I don't believe it is made more comprehensible by moving it around, even if it may be prettier. It's far from being the most difficult part of MakeMaker anyway.

Secondly, after your refactoring it is still poorly designed. IME, having short methods is not a goal by itself, but a typical result of good architecture. This is even more the case for constructors.

But my real point is this: is there anything that is made possible or even easier after this? Is there any concrete advantage to this? This has more costs than your effort in writing it, I'd like to know the benefits.

@sjn
Copy link

sjn commented Aug 11, 2018

FWIW, refactoring new() is something I approve, even if it doesn't immediately offer any direct benefits other than increasing the understandability/obviousness of the code.

Refactoring code just to make it easier to understand does IMO not have to be defended, so please accept this pull request! We need more PRs like this.

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.

4 participants