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

EditDialog.GetNewValue is getting too big #275

Open
tznind opened this issue Dec 30, 2023 · 1 comment
Open

EditDialog.GetNewValue is getting too big #275

tznind opened this issue Dec 30, 2023 · 1 comment

Comments

@tznind
Copy link
Collaborator

tznind commented Dec 30, 2023

We have logic that answers the following question:

  • Given a property of arbitrary Type with current value oldValue
  • What UI should I show to illicit a new value from the user
  • Run that UI
  • Did the UI cancel or complete?
  • If complete return true and out the new value

This is that method:

internal static bool GetNewValue(Design design, Property property, object? oldValue, out object? newValue)

There are really 2 possibilities that this method decides:

  • Show a modal (e.g. enter a string)
  • Show an 'editor' (e.g. PosEditor)

This is hard to test and getting too big.

Possible Solutions

Add a shared interface for all editors INewValueGetter (PosEditor, SizeEditor etc)

Create a new class PropertyValueFactory with function Create that takes a Design, Property and oldValue then returns an INewValueGetter.

This will allow for unit testing that the correct decisions about what editor should be shown to be written and move the logic of this tree into its own class.

Advantages

In #271 I have started down the route of a more complex ArrayEditor. Having this logic in its own class would make it possible to centralize 'new value' logic.

Testability

Automation style of tests e.g. mocking INewValueGetter with test implementations that simulate the user driving editor to create a given value.

@tznind
Copy link
Collaborator Author

tznind commented Dec 31, 2023

I have started work on this in #271 with new ValueFactory class

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

No branches or pull requests

1 participant