Edit : now your question is being edited to include an example
// example of the style of method public void ShouldIShowOrHideButton() { Button.Visible = ((chkSomeSetting.Checked) && (DateTime.Now.Day < 8)); }
My answer is neither . I would do two things:
- Move the
Button.Visible part outside the function, so the function just calculates the logic and returns a bool . - Name the function according to its internal logic , regardless of whether it is used for the button or not. Therefore, if your function checks the wedding day, it will be called
IsWeddingDay , if it checks the monthly meeting, it will be IsMonthlyMeeting .
Code will be
Button.Visible = IsMonthlyMeeting()
and then the logic can be used to control any other widgets, if necessary.
Old answer : You probably need to explain more about what ShowIfThisHideIfThat does.
If it depends on one condition, for example:
if (condition) ShowBotton() else HideButton()
then i would use
Button.SetVisibility(condition)
in accordance with the comment of Lazarenko above, or if the language has the properties:
Button.Visible = condition
If you have two conditions, for example, that is shown in ShowIfThisHideIfThat, which is equivalent:
if (cond1) ShowButton() else if (cond2) HideButton() else LeaveButtonAsItIs()
then the logic, in my opinion, is complicated, and I would not use a single function. Of course the code is equivalent
Button.Visible = cond1 || (!cond2 && Button.Visible)
but you lose your comprehension.