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()

private void DisableButtons()

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.

Leave a Reply

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

You are commenting using your 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