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

Abstract out creation "Of" and conversion "To" Quantity members #8

Merged
merged 30 commits into from
Jun 11, 2023

Conversation

atmoos
Copy link
Owner

@atmoos atmoos commented May 11, 2023

  • All quantities had "Copy Paste" versions of To{...} and Create{...} methods.
  • Now replaced by reusable structs
  • Held together by IFactory<TQuantity, TDimension> interface
  • Performance has degraded, but
  • Readability has increased (this has higher importance)

Note: Naming is still bad in many (new) areas. Ought to change when I publish this PR.

Initially borne out of an idea to make serialization easier...

In a nutshell

Previously:

Length smallMetric = Length.Si<Micro, Metre>(23);

Now:

Length smallMetric = Length.Of(23).Si<Micro, Metre>();

@atmoos atmoos added the enhancement New feature or request label May 11, 2023
@atmoos atmoos requested a review from sereneowl May 11, 2023 14:15
@atmoos atmoos self-assigned this May 11, 2023
@atmoos atmoos marked this pull request as ready for review May 22, 2023 12:04
README.md Show resolved Hide resolved
quantities.benchmark/AddingQuantities.cs Show resolved Hide resolved
quantities.benchmark/CreateQuantities.cs Show resolved Hide resolved
quantities.benchmark/CreateQuantities.cs Show resolved Hide resolved
quantities.test/AreaTest.cs Show resolved Hide resolved
quantities/factories/CubicFactory.cs Show resolved Hide resolved
quantities/factories/Factories.cs Show resolved Hide resolved
quantities/factories/IFactory.cs Show resolved Hide resolved
quantities/factories/LinearCreate.cs Show resolved Hide resolved
quantities/factories/LinearFactories.cs Show resolved Hide resolved
sereneowl
sereneowl previously approved these changes Jun 8, 2023
Copy link
Collaborator

@sereneowl sereneowl left a comment

Choose a reason for hiding this comment

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

Most questions are questions about understanding what you did. Stuff like:

  • when do you use Create and when an internal constructor
  • when do you use struct and when class
  • why do some quants have a root while others don't.

I hope that the next reviews will be smaller because I wish to dive deep in understanding what you actually built here 😁

quantities/factories/Factories.cs Outdated Show resolved Hide resolved
quantities/factories/Factories.cs Outdated Show resolved Hide resolved
quantities/factories/PerFactory.cs Show resolved Hide resolved
quantities/factories/PerFactory.cs Show resolved Hide resolved
quantities/factories/PowerFactory.cs Show resolved Hide resolved
quantities/quantities/Area.cs Show resolved Hide resolved
quantities/quantities/ElectricalResistance.cs Show resolved Hide resolved
quantities/quantities/Energy.cs Show resolved Hide resolved
quantities/units/Imperial/Mass/Ton.cs Show resolved Hide resolved
quantities/units/Si/Derived/Newton.cs Show resolved Hide resolved
@atmoos atmoos merged commit 50a59bb into master Jun 11, 2023
@atmoos atmoos deleted the systemOfMeasurement branch June 11, 2023 01:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants