Refactoring: EnableDisableButtons

Posted on Updated on

Było tak:

private void EnableButtons()
{
    SortOptionByReferenceButtonIsEnabled = true;
    SortOptionByTabletVersionButtonIsEnabled = true;
    SortOptionByOnlineVersionButtonIsEnabled = true;
    SortOptionByProductButtonIsEnabled = true;
    SortOptionByLabelButtonIsEnabled = true;
}

private void DisableButtons()
{
    SortOptionByReferenceButtonIsEnabled = false;
    SortOptionByTabletVersionButtonIsEnabled = false;
    SortOptionByOnlineVersionButtonIsEnabled = false;
    SortOptionByProductButtonIsEnabled = false;
    SortOptionByLabelButtonIsEnabled = false;
}

Zamieniamy na:

private void EnableButtons()
{
    EnableDisableButtons(true);
}

private void DisableButtons()
{
    EnableDisableButtons(false);
}

private void EnableDisableButtons(bool isEnabled)
{
    SortOptionByReferenceButtonIsEnabled = isEnabled;
    SortOptionByTabletVersionButtonIsEnabled = isEnabled;
    SortOptionByOnlineVersionButtonIsEnabled = isEnabled;
    SortOptionByProductButtonIsEnabled = isEnabled;
    SortOptionByLabelButtonIsEnabled = isEnabled;
}

Jak dobrze nazwać metodę EnableDisableButtons?

TODO: pokazać jak w R# szybko takie rzeczy się refactoruje.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s