Skip to content

Simplify canonical data types#430

Merged
robkeim merged 8 commits intoexercism:masterfrom
ErikSchierboom:simplify-canonical-data-types
Sep 9, 2017
Merged

Simplify canonical data types#430
robkeim merged 8 commits intoexercism:masterfrom
ErikSchierboom:simplify-canonical-data-types

Conversation

@ErikSchierboom
Copy link
Copy Markdown
Member

This PR is quite a big refactoring of the canonical data type handling. It contains lots of things: some use of dynamic, the ConstructorInput and Input properties referring to the Properties values instead of being copies, and much more :) With these changes, many exercises could further be simplified. The only exercises I'm not completely happy with are the alphametics and word-count exercises, which deal with dictionary conversions.

@jpreese
Copy link
Copy Markdown
Contributor

jpreese commented Sep 8, 2017

Oh boy, this is a big one :) Honestly I think my only critique is that I want Convert out of the Exercises/ dir!

Obviously it works and less code is required to generate some of the tests. I don't see anything that here that is a major red flag to me.

Copy link
Copy Markdown
Contributor

@robkeim robkeim left a comment

Choose a reason for hiding this comment

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

Great work @ErikSchierboom! One minor nit but I'll go ahead and merge as-is.

{
// Process expected
if (IsComplexNumber(canonicalDataCase.Expected))
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ErikSchierboom - between you, @jpreese, and I are style for when to use braces is clearly different... there are PRs where they're being added and removed:)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Haha, true. I tend to not bother with these kind of changes since it does boil down to preferences, but sometimes you just cant resist. I love braces!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@robkeim @jpreese Yeah, there is some stylistic difference between us ;) Perhaps we should start a discussion at #398.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ErikSchierboom ok sounds good!

private static string RenderComplexNumberAssert(TestMethodBody testMethodBody)
{
var template = "Assert.Equal({{ ExpectedParameter }}.Real(), {{ TestedValue }}.Real(), 15);\r\nAssert.Equal({{ ExpectedParameter }}.Imaginary(), {{ TestedValue }}.Imaginary(), 15);";
const string template = "Assert.Equal({{ ExpectedParameter }}.Real(), {{ TestedValue }}.Real(), precision: 15);\r\nAssert.Equal({{ ExpectedParameter }}.Imaginary(), {{ TestedValue }}.Imaginary(), precision: 15);";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice! This change definitely makes the output feel more natural and not like it was written by a program :)

}

protected override HashSet<string> AddAdditionalNamespaces()
protected override HashSet<string> AddAdditionalNamespaces() => new HashSet<string>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor: For consistency with other places in the code this should all be on one line

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed

@robkeim robkeim merged commit 62522c3 into exercism:master Sep 9, 2017
@robkeim
Copy link
Copy Markdown
Contributor

robkeim commented Sep 9, 2017

Great work, @ErikSchierboom 🎉

@ErikSchierboom ErikSchierboom deleted the simplify-canonical-data-types branch September 9, 2017 14:08
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