Code below shows setting a value of an object's property and calling a private
method in a setter to update the status of the object. Is this call a good practice or setter at most should only validate incoming value and should not take part in other kinds of logic?
public class Toolbar
{
private bool isMenuButtonVisible;
public bool IsMenuButtonVisible
{
get => isMenuButtonVisible;
set
{
isMenuButtonVisible = value;
UpdateToolbarVisualState();
}
}
private void UpdateToolbarVisualState()
{
MenuButtonBackground.IsVisible = IsMenuButtonVisible;
MenuButtonIcon.IsVisible = IsMenuButtonVisible;
MenuButtonLabel.IsVisible = IsMenuButtonVisible;
//...
}
}