How would you name an interface which provides 1 method inUse()?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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
and name your interface
IHasUsageState. This gives you the flexibility of adding things likeStarting,Finishing,WaitingToBeUsedor 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 intuitiveif (obj.Usage == UsageState.Idle) { }, not to mention you may decide in the future that you might want it to specify WHY it’s idle.