Partager via


Attributes and API usability

I'm in the middle of running an API study this week with an API that makes heavy use of attributes throughout. Basically, much of the functionality that the API supports is largely exposed through the use of attributes. The API requires that you decorate classes, member variables and properties with attributes to implement some functionality. If you want to customise that functionality, you set various optional parameters on the attributes. There is very little (almost nothing) that you need to do in actual imperative code.

We're half way through the study and are starting to see a pattern in the way that participants respond to the use of attributes throughout the API (once the study is over, I'll let you in on more of the details...).

I'm interested in hearing what others think of such a use of attributes in an API. What advantages and disadvantages do you think such an API would offer? And do the advantages outweigh the disadvantages or vice versa? In your opinion, is the heavy use of attributes throughout an API a good or a bad thing?

Comments

  • Anonymous
    May 06, 2004
    Attributes as concept is a good thing no doubt,declarative programming and AOP is always good thing but implementation can be improved by providing completely decoupled alternative among other things IMHO.
  • Anonymous
    May 08, 2004
    The comment has been removed
  • Anonymous
    May 09, 2004
    I was thinking about this just the other day. I think that generally, attributes in code are awesome. I believe that they can provide very important functionality in with very little maintenance effort and extremely easy implementation.

    However, I also believe that as more and more library/framework creators catch the Attribute fever, we're going to have far too many of them decorating everything. I think it might be time to search out an alternative way to represent the attributes (if not representation, then manageability, but that implies that there might be yet another tool to manage attributes, giving us a less usable IDE for our more usale API).

    Anyway, I think we'll start to see a problem as we get too many attributes in our code.