I am writing a class where the name starts with an I (because that's the name of the product we're integrating with - can't change).
Convention states that class names have a capital letter to start, however in this case it would appear to the consumer as an interface.
Is there any documentation guiding developers on the correct approach here? In addition what happens if I do need to implement and interface - should it be IiProduct/IIProduct?
Edited to Add:
I can't mention the product for obvious reasons but it follows the same capitalisation convention as apple. iPhone, therefore IPhoneClass (follows their branding but appears as an interface) rather than IphoneClass (which follows convention rather than branding).
If the product name is for example iPhone
, then in that case I would call the classIphone
to keep class naming consistent. The interface would be IIphone
, which doesn't look great, but is clear in its meaning (as it follows convention).
I'm sure people using the class would be more upset if they thought it was an interface, than if it wasn't capitalized as the product is to follow convention.
Interface starts with I
as a prefix and then Interface name using capital letter. So interface will be IImposibleProduct
and class will be ImposibleProduct
.
I follow this convention for interface.
See the example
interface ICallable{
public void call();
}
ICallable = I + CapitlizeFirstLetter(call+able)
I think most developers follow these convention. From that point of view IClass
, IDone
, ICall
, IncomeTax
etc are not an interface. But IClassable
, ICallable
, ITaxable
etc respectively are interface.
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