views:

49

answers:

3

I created an API wrapper called Chargify.NET and I'm starting to see a pattern develop that could potentially be solved by targeting .NET 4.

The issue is that as they enhance the API, I need to create more and more overloaded functions to handle one specific action (Creating a subscription, in this case). Right now, I have MANY (I think too many) overloaded CreateSubscription functions, and it's getting hard to manage the different signatures.

IS it possible (and/or suggested) to build the library against .NET 4 and use optional parameters and hope that the users of the library can use the .NET 4 library? Or should I continue along the path I'm on with 3.5? Or somehow target both?

Need some discussion about this ..

+1  A: 

There's really no right answer. If you start using .NET 4 features, you'll probably want to just target .NET 4, since trying to target both will either limit you to older features (meaning no reason to upgrade) or require 2 code paths (bad for maintenance).

Using .NET 4 will limit your target market to those people using .NET 4. It's really up to you to decide whether the extra flexibility and power that comes with the new features, and whether the simplified API (ie: optional parameter capabilities) is worth limiting your audience.

If your audience is commercial shops, this may be a big issue - if your target users are small developers, or mainly other open source developers - chances are they'll be much more willing to upgrade to .NET 4 to use your wrapper if it's required.

Reed Copsey
It's an open-source API wrapper for a community that needed a .NET version, so I'm not sure really if users would be willing to convert. It's used in a number of pre-existing projects as well as new ones .. so that might be an issue for them.
Kori
+1  A: 

Optional parameters have been fully supported by .NET well before 4.0. However, they have only recently gotten language support from C#. Remember that optional parameters are not required to be fully supported by a CLS compliant language - the compiler is allowed to ignore the default values you provide.

anonymous coward
A: 

Just so you know too, when the C# Compiler compiles your program and your program uses optional parameters, all the compiler does is substitute those optional parameters for overloaded functions. So you will gain no speed or code reduction benefit by switching to optional parameters.

icemanind
Speed isn't really an issue, but thanks for the reminder. I'd rather the compiler completely my overloaded functions than me writing them. /lazy
Kori