Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Split INavigationAware into separate interfaces #25

Open
LeftTwixWand opened this issue Oct 12, 2022 · 2 comments
Open

Split INavigationAware into separate interfaces #25

LeftTwixWand opened this issue Oct 12, 2022 · 2 comments
Labels
enhancement New feature or request layer/application Means some changes in the Application layer

Comments

@LeftTwixWand
Copy link
Owner

Now INavigationAware interface looks like this:

public interface INavigationAware
{
    void OnNavigatedTo(object parameter);

    void OnNavigatedFrom();
}

Current implementation is not correct from the architecture point of view. It forces us to have both methods, when one of them might be surplus.

public async void OnNavigatedTo(object parameter)
{
    if (parameter is long orderId)
    {
        // Do some stuff
    }
}

public void OnNavigatedFrom()
{
    // Useless
}

Like SOLID Interface Segregation Principle says: Clients should not be forced to implement any methods they don’t use
That's why it would be better to split INavigationAware into two separate interfaces INavigatedTo and INavigatedFrom.
And as a part of code enhancement, it might be possible to make a parameter in OnNavigatedTo(object parameter) strongly typed for the cases, where we have only one possible navigation scenario.

public interface INavigatedTo<T>
{
    void OnNavigatedTo(T parameter);
}

public interface INavigatedTo : INavigatedTo<object>
{
}

public interface INavigatedFrom
{
    void OnNavigatedFrom();
}
@LeftTwixWand LeftTwixWand added enhancement New feature or request layer/application Means some changes in the Application layer labels Oct 12, 2022
@LeftTwixWand
Copy link
Owner Author

It would also be good to have a few navigation scenarios with different parameters.

@LeftTwixWand
Copy link
Owner Author

Navigation service needs to be refactored, because part of navigation process is handled in NavigatedEventHandler

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request layer/application Means some changes in the Application layer
Projects
None yet
Development

No branches or pull requests

1 participant