Skip to content

Refactor for reuse #122

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

Merged
merged 8 commits into from
Mar 30, 2018
Merged

Refactor for reuse #122

merged 8 commits into from
Mar 30, 2018

Conversation

kevmoo
Copy link
Collaborator

@kevmoo kevmoo commented Mar 30, 2018

The only user-visible change here is fixing some error messages.

Otherwise, this just makes a few members public in a way that allows experimenting with reuse from other code.

Eventually, the code may end up in source_gen – but we'll take our time.

@kevmoo kevmoo requested a review from natebosch March 30, 2018 19:43
@@ -0,0 +1,6 @@
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
Copy link
Member

Choose a reason for hiding this comment

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

2018


final _dartCoreObjectChecker = const TypeChecker.fromRuntime(Object);

/// Returns the set of fields that are written to via factory.
Copy link
Member

Choose a reason for hiding this comment

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

blank line after the first sentence

I'm assuming there are side effects to this method (like writing to buffer) - maybe we should focus on those in the first description rather than the return value?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Did a big clean-up here

{ParameterElement ctorParam})) {
var fieldsSetByFactory = new Set<FieldElement>();
var className = classElement.displayName;
// Create the factory method
Copy link
Member

Choose a reason for hiding this comment

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

what is this meant to be describing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed – old noise.

var className = classElement.displayName;
// Create the factory method

// Get the default constructor
Copy link
Member

Choose a reason for hiding this comment

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

this is a "what" comment - is there a "why" we should be documenting? Or should we drop the comment? Or pull it out into a method named findDefaultConstructor(...)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed and adding a TODO around #50

.difference(fieldsSetByFactory);

//
// Generate the static factory method
Copy link
Member

Choose a reason for hiding this comment

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

This method is ~100 lines and big section comments like this make me think it could be broken up into different methods.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did a bit of cleanup. There is a lot of state in a few vars here. I'd have to create another class to ship them between functions, which seems like more noise than it's worth

@kevmoo
Copy link
Collaborator Author

kevmoo commented Mar 30, 2018

@natebosch – fixed copyright year...

@kevmoo kevmoo merged commit 729a32e into master Mar 30, 2018
@kevmoo kevmoo deleted the refactor_for_reuse branch March 30, 2018 22:02
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.

2 participants