How would you name an interface which provides 1 method inUse()?
I would actually reconsider the name 'inUse()' in the first place; A boolean value obviously has only two possible values, but you're actually adding the ability to get a state. I'd consider declaring an enum
public enum UsageState
{
Idle,
InUse
}
and name your interface IHasUsageState
. This gives you the flexibility of adding things like Starting
, Finishing
, WaitingToBeUsed
or other options depending on precisely what is is you're doing, for example if you have threading issues to deal with in the future.
Also, you eliminate the need for negative checks like if (!obj.InUse()) { }
in favor of the more readable and intuitive if (obj.Usage == UsageState.Idle) { }
, not to mention you may decide in the future that you might want it to specify WHY it's idle.
IUsageIndicator
if you want to show that your object is currently in use or not.
IUsable
if you want to show that your object can be used or not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With