Looking for a good name for interface with inUse() method [closed]
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.
I would name it. IInUse
. Looks good...
I would prefer to name it as IUsable keeping in mind the standard conventions that MS follows. (Eg: IEnumerable, IComparable etc)
I would prefer
InUsable
. Sounds everlasting.
see here
I would name it. IUsable. Looks good...
This is what I would have done in Java
public interface Usable {
public boolean inUse();
}
It should start with Uppercase 'I', so the interface name becomes in your case IInUse.
Follow the C# coding standards over here.
How about IExclusiveUseObject?
are you looking for answers for both c# and java?
As a c-sharper, I prefix with "I" and most c# developers I talk to do also, probably because it's in the microsoft naming conventions.
However interestingly when search around for java naming conventions I see a mix of prefixed and no prefix.
So in c# perhaps something like:
public interface IUsable {
void InUse();
}
精彩评论