-
Notifications
You must be signed in to change notification settings - Fork 12
Split INavigationAware into separate interfaces #25
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or requestlayer/applicationMeans some changes in the Application layerMeans some changes in the Application layer
Description
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();
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestlayer/applicationMeans some changes in the Application layerMeans some changes in the Application layer