“Adapter” or “adaptor”?

2020-08-10 19:41发布


In programming, which spelling—adapter or adaptor—is standard or de facto standard? Is there a difference between them?

In boost I see "adaptor", whereas in literature I see "adapter".

Which one is preferred in code?


They are both correct, though I think there's a slight preference for adapter to be used for people (such as someone who adapts a piece of music), while adaptor is used for a device or machine; thus, in computing, adaptor would generally be used. Wikipedia mentions this distinction, though without any real references to back it up. I would use whichever you feel more comfortable with, or the one in already in use in the code base you're working in if the word has been used already.


It is spelled Adapter in the 'Gang of Four' book (page 139) which is often considered definitive.

The term would usually be spelled Adaptor in British English.

A full reference for the 'Gang of Four' book is:

Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma (Author), Richard Helm (Author), Ralph Johnson (Author), John Vlissides (Author)


As an Aussie, I spell it Adaptor (an Adapter is a person who adapts, an adaptor is a device that performs adaptation). My teammate (who is Kiwi) spells it Adapter (which makes our code 'interesting' at times). The Yanks I know spell it Adapter, and I have no idea what the Poms use! It's obviously a dialectic thing.

If your programming language supports unicode, name it with a schwa j/k


Your choice of language might be meaningful here -- the C++ standard and Boost use "adaptor", Java uses "adapter".


I use adapter, because that's the correct spelling :) but i guess if you're not from the US the correct spelling might be adaptor.



I think you'll see "adapter" more commonly. Either is correct, so it's really up to you. The design pattern in particular seems to be spelled adapter. But, if you look at the wikipedia article on it (http://en.wikipedia.org/wiki/Adapter_pattern), it's spelled adaptor in the diagrams! Frankly, I don't see any justification for spelling the word adaptor in the first place, but English is a funny language that way.


Specific to Android, the spelling should be adapter, in order to keep it consistent with the framework:



According to Google Trends, Adapter is much more common: https://www.google.com/trends/explore?cat=5&date=all&q=adapter,adaptor https://www.google.com/trends/explore?date=all&q=adapter%20pattern,adaptor%20pattern


As some people here have already pointed out, the correct spelling is adaptor. Just because Americans have bastardised (Note: it's not bastardized either) the English language and constantly attempt to bleed it into all of their computer applications and media, among other things, does not make them right. :)