views:

94

answers:

5

We have a desktop application which needs to expose API.

Some people say: API should have an abstraction layer so actual implementation can change in future versions.

Others say: API should be version specific. So an API which uses version X will only work with it. Version X+1 will also deploy the dll's of version X in order not to break existing usage. This is claimed to be aligned with how frameworks like .Net or Silverlight works.

What is your opinion?

+2  A: 

Some questions that you should consider:

  • What's the likely expectations of your users?
  • Are you likely to need to make breaking changes between versions?
  • How much would it cost you in development effort to maintain compatibility across versions, based on any roadmap you currently have?

My opinion is that you should maintain API compatibility across versions if at all possible. Microsoft have achieved it, mostly, with Office and it's why there are so many add-ins, accessories and LOB applications built around them. I, for example, wrote an application on-top of Access XP that used Excel automation quite heavily and it works without error in Office 2010. That's what I call compatibility!

Rob
So with office is it exactly the same api between versions? Or do they make breaking changes in recent versions but also keep working with the older api's.
Yaron Naveh
I've never needed to change my code when Office has been upgraded, I believe (but would need to check to confirm) that the API provided is *additive*, so there's nothing ever taken away, only added. Be it new methods, classes/interfaces.
Rob
+1  A: 

I have found that versioning an interface is a useful tool to implement breaking changes.

You should do your best to get your API interfaces right the first time.

When you have a breaking change (changing existing signatures, so client code must be recompiled), you must change the interface, and when you do so you can change the version. Non-breaking changes (e.g. adding new features to a different class) shouldn't change the version, if you can avoid it.

Merlyn Morgan-Graham
A: 

If you are using Net as a reference you should notice that they take a hybrid approach, they use a bit of both, do not confuse CLR version with NET version.

You should consider your app uses in order to find the answer for you.

My money is on mantaining API compatibility accross all versions as possible.

However there are drawback to that as well.

Regards

serguey123
Where do Microsoft use the interface approach? If I build an application on WCF 3.5 it will run on CLR 3.5 not on 4.0.
Yaron Naveh
You did not read the post well did you?CLR version up to NET version 3.5 is 2.0They only changed in Net version 4.0Please study more
serguey123
A: 

If you do decide to go version specific make sure you're very up front with your users. I've missed deadlines half a dozen times do to my vendors changing their web services without notifying me and having to scramble to come up with a solution

Ian Jacobs
This is a desktop application. It will always ship with the dll.
Yaron Naveh
+1  A: 

Use the idea of closed for modification, open for extension. Any parts of the API you expose should not change in future versions if at all possible. (Parts you don't expose can be modified, provided they still function the same). A programmer expects to use an API and have that code work for it's lifetime, without worrying about the version he is referencing.

Consider that in later versions of the API, you might expose new features that each user of your API might want to adopt - but he already has code written against the old version of the API. He should be able to plug in the new parts without rewriting his old code (Assuming the new parts don't rely on the breaking changes).

If there are breaking changes to be made, you should not remove the old way of doing it, but mark it [Obsolete], and give a clear message on how it should be updated to the newer API.

Mark H
This does not seem the be the .Net way. If you want a .Net 4.0 application - you should recompile your 3.5 code with 4.0
Yaron Naveh
Ok, sorry, I've misunderstood what you were asking. The important thing I was expressing, is although it requires recompilation against a new version - recompiling works without errors and without modification. It's not a very big issue for a user to recompile code - but if they're forced to change it, it is.
Mark H