'. '

Blogs:JaroslavTulach:Theory

From APIDesign

(Difference between revisions)
Jump to: navigation, search
(Jaroslav Tulach's Theory Thoughts)
(Jaroslav Tulach's Theory Thoughts)
Line 4: Line 4:
<startFeed />
<startFeed />
 +
 +
==== Joel Neely on Enums in APIs ====
 +
 +
Today I found out that there is an interesting
 +
[[:Talk:Blogs:AndreiBadea:EnumsInAPIs#Joel_Neely_said_...|comment]]
 +
to the blog entry published by
 +
[[AndreiBadea|Andrei]] a week ago. [[AndreiBadea|Andrei]] shared with us few thoughts on the [[Blogs:AndreiBadea:EnumsInAPIs|use of enums in API]]. [[Talk:Blogs:AndreiBadea:EnumsInAPIs#Joel_Neely_said_...|Joel Neely noted]] that it all depends on how the '''enum''' is used in the API. I cannot do anything else than agree with
 +
[[Talk:Blogs:AndreiBadea:EnumsInAPIs#Joel_Neely_said_...|his words]], yes it depends on whether the '''enum''' is used [[wikipedia::Covariance_and_contravariance_(computer_science)|covariantly or contravariantly]]. If the enum is used covariantly only, then extending it with new constant in new version of the API is OK.
 +
 +
The only problem is that as soon as you publish an '''enum''', one can immediately write a '''switch''' statement over it. And the '''switch''' statement's behaviour is contravariant. That is no good news for the API writers and compatible extensibility of their '''enum''' based APIs...
 +
 +
--[[User:JaroslavTulach|JaroslavTulach]] 21:22, 26 August 2008 (UTC)
==== [[Blogs:JaroslavTulach:Theory:LanguagesForEvolution|Are there any Languages Ready for API Evolution?]] ====
==== [[Blogs:JaroslavTulach:Theory:LanguagesForEvolution|Are there any Languages Ready for API Evolution?]] ====

Revision as of 21:22, 26 August 2008

Contents

Jaroslav Tulach's Theory Thoughts

Joel Neely on Enums in APIs

Today I found out that there is an interesting comment to the blog entry published by Andrei a week ago. Andrei shared with us few thoughts on the use of enums in API. Joel Neely noted that it all depends on how the enum is used in the API. I cannot do anything else than agree with his words, yes it depends on whether the enum is used covariantly or contravariantly. If the enum is used covariantly only, then extending it with new constant in new version of the API is OK.

The only problem is that as soon as you publish an enum, one can immediately write a switch statement over it. And the switch statement's behaviour is contravariant. That is no good news for the API writers and compatible extensibility of their enum based APIs...

--JaroslavTulach 21:22, 26 August 2008 (UTC)

Are there any Languages Ready for API Evolution?

When I was describing my API design adventures in TheAPIBook, I could not realize that many of these problems would not even appear if we had better languages, or systems more suitable for the DistributedDevelopment.

I may be wrong, but I do not know about any language that would support modularity. And here I mean not compilation piece by piece, but also modularity in time. Because that is the kind of modularity that is needed quite often during development of APIs for our libraries.

At one point of time we release a version of a library and distribute it to others by publishing it on the website. Now people unknown to us, distributed all around the world download it and use it. As a result, the amount of applications built on top of such library is increasing, which implies also that the amount of bugs and feature requests is growing too. After a while the time to release new version of the library comes. However what if the first version used to have a class:

public abstract class View {
  public abstract String getDisplayName();
}

What if one of the feature requests demands to add an HTML title to each view. Can we change the view class to following form:

public abstract class View {
  public abstract String getDisplayName();
  public abstract String getHTMLTitle();
}

Indeed, this cannot be done. Existing subclasses of View would no longer compile, because the change is not source compatible. Also, even if someone links already compiled subclass with the new version of the library, the Java virtual machine will complain and throw some kind of linkage error, as definition of an abstract super class method is missing.

I would love to see a language or system that would fail the compilation whenever I want to modify my already released classes in a style that could prevent some of their users to continue to use them in previously working way. This would be the real modularity, which is ready for changes in time. So far it seems to me that the current languages do not deal with changes in time really well. Just like Andrei described in his Enums in APIs blog, it seems that our languages do not think about the process of API evolution much and include constructs that one needs to avoid to make DistributedDevelopment possible.

Releasing new version of libraries with modified APIs is really common and our software engineering practices cannot live without it, yet it seems that there is no language in the world that would make this easy and clueless. Or am I wrong?


Also lively discussed at Lambda the Ultimate.

--JaroslavTulach 06:50, 24 August 2008 (UTC)

Visual Aspects of an API

The usual consensus is that visual aspects that are presented just to the end user are not part of API of some application. This is usually well justified and correct, except in some situations...

--JaroslavTulach 11:40, 11 August 2008 (UTC)

Dependencies Are Important Type of API

New type of API has been discovered!

JaroslavTulach 07:05, 15 July 2008 (UTC)

Personal tools
buy