开发者

How should I make a library (.dll) file for other devs to use in their projects using C#?

Sure, there's a type of project in Visual Studio that outputs a DLL that people can use. I know that. I'm just wondering what are some of the standards that devs will expect when using my DLL file.

I'll be providing a class that searches for 开发者_Go百科movies in IMDB and returns results for a dev to consume.

Not a webservice, but a local DLL file. (I'm aware that IMDB frowns upon web scraping, but I'm also aware that they give permission to people if asked. My permission is already sent.)

How should I approach this?


Check out Microsoft's Design Guidelines for Class Library Developers.

Or the newer version of same (thanks to paper1337).


You're then interested in best practices when designing a class library. There is much to say to this thema.

One of the first and foremost things you need to do is to publish all your dependencies. Avoid any hidden dependencies in your code.

For example, don't rely on some key to be set in a shared key-value collection, such as Session. There is no way a user of your library can find it out.

If some method requires some service to be preinitialized, require a valid reference to be passed as an argument.


You need to provide a simple to use API, full documentation and worked examples as a minimum. If you can provide unit tests that would be a bonus.

Internally, you need to verify all inputs into your routines, as well as clearly document what configuration the user is expected to do. Solid exception handling is a given, and you should possibly consider some localisation support in there as well.


If you, or anybody, is serious about creating a good framework for others to use, check out http://www.amazon.com/Framework-Design-Guidelines-Conventions-Libraries/dp/0321246756


What ever you make public, should remain public and their signatures cannot be changed in your next version and you must support it forever.

So, take care in establishing your contracts and document them with examples. Make public members only if it needs to be.


  1. Easy-to-use API with appropriate class, method and property names.
  2. API has been tested (e.g. unit tests)
  3. Supporting documentation.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜