Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Just browsing through Code Complete last night and I came across the explanation of abstract data types.

I must have read it 5 times, and the Wikipedia article doesn't help much either. So what I'm looking for is a simple explanation of exactly what is an Abstract Data Type? Any solid examples? In C# or VB?

I understand that String is supposed to be one, why is this? And why isn't Int32 one? Or is it?

Any pointers are much appreciated.

share|improve this question
Maybe this help you dba-oracle.com/t_object_encapsulation_abstract.htm –  yeradis Jan 21 '11 at 10:32

5 Answers 5

Objects are not ADTs (*). (So in C# String and Int32 are not ADTs.)

With that out of the way, an abstract data type "has a public name, a hidden representation, and operations to create, combine and observe values of the abstraction". (Quoting from the linked paper.)

(*) Briefly, Cook explains that:

  • Objects cannot inspect the hidden representation of other objects, unlike members of an ADT. That implies that values of an ADT may be implemented efficiently, even for operations that require inspection of multiple abstract values.
  • Objects behave like a characteristic function over the values of a type, rather than as an algebra. Objects use procedural abstraction rather than type abstraction
  • ADTs usually have a unique implementation in a program. When one's language has modules, it's possible to have multiple implementations of an ADT, but they can't usually interoperate.
share|improve this answer

When you hear the word abstract in CS context, think 'hides details' or 'zoom-out conceptually'. A class is an abstract object for example because it allows one to use the name as an 'abstract' entity that has a lot of functions under the hood that would otherwise have to be typed manually. It is generally meant for injecting human element into code such as readability and mapping the code in an intuitive way.

I may be wrong though.

share|improve this answer
I understand the term abstract in the case of abstract classes and understand I means hiding details etc. I just don't understand how its mean in terms of a datatype? It stores data...so how is it abstract? –  billy.bob Jan 21 '11 at 10:24
Well I would imagine that String is an abstract data-type because it is actually an array of Char types under the hood. String is a nice abstract term for this. –  zhenka Jan 21 '11 at 10:26
If it is sufficiently abstract, all you (need to) know is "it stores data and when I ask for it, I get it back". If you're even luckier, there are some performance guarantees attached. –  Vatine Jan 21 '11 at 10:27
Ahh I see what you're saying @Eugene, would this also explain why Int32 isn't an ADT as it isn't abstracting anything? –  billy.bob Jan 21 '11 at 10:27
en.wikipedia.org/wiki/Enumerated_type I think this provides a good example of ADT (not explain it though) –  zhenka Jan 21 '11 at 10:29

Taken from http://csc.colstate.edu/ray/2108_Sp09/Abstract%20Data%20Type.htm

Abstract Data Type

• A specification of a set of data and the set of operations that can be performed on the data. Such a data type is abstract in the sense that it is independent of various concrete implementations.

• Example: all of Java’s built-in types, such as int, double, char are all ADTs. You can declare variables of these types without understanding the underlying implementation details. You can initialize, modify, access the information held by these variables via specific operations.

• You can create your own ADT by using class mechanism.

share|improve this answer

If you know Factory Design Pattern, It'll more understandable what is ADT.

Let us discuss it with the example, Let take a Pizza store, which has the regional branches in NY, Chicago, California, etc. The Head Office, which is in Washington defines how should a Pizza prepared and let the regional branches implements that on their own.

Here, Pizza is a ADT, and NYPizza, ChicagoPizza, CaliforniaPizza are subtypes.

Hope this helps to get the idea in a abstract way.

share|improve this answer

An abstract data type is defined by it's interface. I think a good example of this is the JDBC API. You look up a Datasource (an ADT), and you get a specific implementation of that datasource depending on what database type you want to access. You create Statements and work with ResultSets, which are also ADTs. The point is that the interface is defined, the implementation is not.

Why would you want this? Again with JDBC, it allows more portable code because since you use the interface to access the object, you don't need to worry about what kind of database you are accessing. That can be handled in exactly one place: where the datasource is defined. If you are using factories, the factory can return different objects based on the context of the data they contain, while allowing the code operating on those objects to remain the same.

Some reasons I see to use ADTs:

  • To keep from repeating yourself. If you only need to handle specifics in one place, changes are easier to do and track.
  • To provide a level of abstraction. ADTs allow you to think at a higher level. You can think of what to do rather than how to do it.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.