As someone who needs to consume tons of APIs ...
Please write your API sequentially:
Consistent naming in the API itself. Use verbs, nouns, keywords EXACTLY in the same style.
According to the target environment, it will be used. If .NET, check out the Microsoft naming guidelines.
Consistent concepts. Factory pattern? Builder Template? Static methods? Interfaces? Just pick one and stick to it. REALLY. There is no such thing as a small exception to the rule. He will stick out like a sore thumb. More than one exception? Your API is more and more amateur.
Here's another one: Specificity.
The base classes that I can implement, if you decide to provide them, should have few and clearly defined functions for implementation. Don't tell me that "GetData ()" returns "object []" and then expect me to implement it, find out why I need to pass it to the string [] and then debug why it is called 20 times. It is much better to have DataPoint [] GetChartData (), string [] GetLabelData (), etc. And let me choose which ones I should implement.
Don’t forget the silly names: PostRenderColorWheelModifyHSVBaseHandler. You can often reorganize super-specific things into more general names + parameters.
String parameters - no, no! Use enumerations. I do not want to use a handler, for example
PostRenderHandler ("ColorWheel", "HSV", someDelegate);
I would really like to list what I can research:
PostRenderHandler(ModuleType.ColorWheel, Options.ColorWheelHSV, someDelegate);
Man, I could go on ... The power of this guy Josh Bloch - well-written APIs can be really awesome ... bad ones can be very painful.
Jeff Meatball Yang Apr 12 '10 at 4:33
source share