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

Refactor NullClassBuilder#generate_class #32

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

Conversation

padi
Copy link
Contributor

@padi padi commented Jun 26, 2013

Seems that this can be refactored further.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 5525994 on padi:initialize_base_class into 0869d4a on avdi:master.

@sferik
Copy link
Collaborator

sferik commented Jan 26, 2014

This patch no longer applies cleanly to master. If you’re still interested in having it be applied, can you please rebase from master?

@padi
Copy link
Contributor Author

padi commented Jan 26, 2014

@sferik sure. I'll look at it tomorrow and see if it still makes sense to apply this patch.

@padi
Copy link
Contributor Author

padi commented Jan 26, 2014

@sferik oops. I still don't know anything about Rubocop, so I guess I'll just continue it tomorrow. The rspec tests pass though.

Edit: I get it now. The NullBuilderClass has 147 out of 144 allowable number of lines (enforced by rubocop.yml). Should I try to shorten the number of non-empty lines or should I increase the class lines to 147? Perhaps applying Replace Method w/ Method Object on the new method initialize_base_class?

@sferik
Copy link
Collaborator

sferik commented Jan 27, 2014

@padi If you can find a way to refactor further that doesn’t increase the length of the class, that would be great. Otherwise, I think it’s okay to increase the RuboCop limit to 147 (or an even 150).

- Replace method w/ method object
@padi
Copy link
Contributor Author

padi commented Jan 28, 2014

@sferik it's ok now. Let me know what you think.

@sferik
Copy link
Collaborator

sferik commented Jan 28, 2014

@padi I know I suggested refactoring to cut down the length of the NullClassBuilder class but it seems a bit excessive to have a class whose sole purpose is initializing another class.

@avdi Curious to get your thoughts on this.

@base_class = builder.base_class
end

def execute(generation_mod, customization_mod)
Copy link
Collaborator

Choose a reason for hiding this comment

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

When there is a class that only does one thing, I like to name that method call. This makes it easy to substitute with a proc, lambda, or Method object. There’s actually a RubyTapas episode about this, which describes why this can be useful. 😄

@sferik sferik force-pushed the master branch 3 times, most recently from 0fa92ab to 4397306 Compare November 10, 2014 15:55
@sferik sferik force-pushed the master branch 4 times, most recently from 1dc5ada to 72228eb Compare September 6, 2015 22:29
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.

3 participants