3
$\begingroup$

I just had a CS mid-term and one of the questions was:

OOD allows ADTs to be created and used.

  • True
  • False

I answered false, but my answer was marked as incorrect. I suspect what the question means is "objected-oriented design can be used to implement abstract data types", but if that's what it means it seems very clumsily worded to me. My rationale for answering false was ADTs are conceptual and exist outside of any particular programming paradigm, so "creation" of an ADT is purely a theoretical exercise.

To me it seems like the question is analogous to saying "OOD allows algorithms to be created". You might use OOD in the implementation of an algorithm, but it has nothing to do with its creation.

Would I be right in appealing my mark? My professor is kind of an idiot and I've already corrected him on several other points throughout the term, so I'm trying to avoid antagonizing him if I'm wrong.

$\endgroup$
  • 1
    $\begingroup$ I would withdraw from the class if the professor does not know the difference between OOD and OOP immediately after I see this kind of exam problems. $\endgroup$ – scaaahu Jul 30 '13 at 5:22
7
$\begingroup$

First, if this is exactly the sentence on the exam and not your translation, it's ambiguous. It could mean that OOD is one possible way to create and use ADT, or that creating and using ADTs requires OOD.

Furthermore, ADT can mean two things: abstract data type or algebraic data type. The two concepts are completely different but are often confused. An algebraic data type is a type that is defined by its recursive structure, or equivalently by the ways to build an object of that type. An abstract data type is a type that is defined by its properties, with the way to build objects remaining hidden.

The second interpretation — that you need OOD for ADTs — is definitely false. There are programming languages which have no object orientation whatsoever but have ADTs in one sense or the other or both. Standard ML is a prime example: record and sum type definitions provide algebraic data types, while the module system provides abstract data types.

The first interpretation — that ADTs can be implemented with OOD — is contentious, because it depends on terminology that isn't standard. In typical languages that provide objects, you can build algebraic data types: define several implementations of a class to make a sum type, and put multiple fields in a class to make a product type. However this is not intrinsic to object-oriented programming. Regarding abstract data types, most object-oriented languages provide some kind of abstraction facility by hiding the implementation of a class under some interface. However, this isn't intrinsic to OOP: the key feature of objects is inheritance, and you can have inheritance without any abstraction whatsoever.

The question may be making a difference between object-oriented design and object-oriented programming construct, but OOD isn't really on the same plane as ADTs.

All in all this is a poorly-worded exam question. The connection between OOD and ADTs is an interesting subject, but the question is not phrased in a meaningful way.

$\endgroup$
  • $\begingroup$ Yeah, that's the exact wording in the question. I'm pretty sure it means abstract data type since we haven't studied algebraic data types in this course (though I've studied them privately while learning Haskell). I think I'm going to challenge it, I've actually found 2 other questions in the exam which definitely have the wrong solution, so I might as well add this one to the pile. There are only 37 questions in total so it's a pretty bad exam. $\endgroup$ – a_____a Jul 30 '13 at 4:07
  • $\begingroup$ @shn If you do that, bring (hard) evidence to support your claims. Questions here may be a good start, but your teacher may dismiss them. $\endgroup$ – Raphael Jul 30 '13 at 10:25
  • $\begingroup$ I think Scala can serve as a good example of how ADTs (both kinds, afaik) can be modelled/implemented in terms of object-orientation. $\endgroup$ – Raphael Jul 30 '13 at 10:26
0
$\begingroup$

It all depends on your definition of "created."

If by created you mean "defined," then certainly the answer is true. The concept of an Interface in Java or similar languages is an ADT. By giving a name to certain methods which can be called on a type, you have created an abstract data type, which you can use for variables and parameters.

If by created you mean "instantiated," then the answer is false, since you can't instantiate an abstract type. An object will have the type of an ADT. It will have the type of a class which implements an ADT.

$\endgroup$
  • 1
    $\begingroup$ It seems to me that a Java interface is more concrete than an ADT. As I understand it, it's more like a theoretical model than an interface and more akin to an algorithm in terms of abstraction. Wikipedia says: "Abstract data types are purely theoretical entities, used (among other things) to simplify the description of abstract algorithms, to classify and evaluate data structures, and to formally describe the type systems of programming languages.". You can't create a theoretical entity in in Java. $\endgroup$ – a_____a Jul 30 '13 at 1:49
  • $\begingroup$ Yet in the next sentence it says "ADTs are often implemented as modules," implying that a language can, in fact, implement the concept of an ADT. Can you define any properties that differentiate an ADT from a Java interface? Both specify functions which can be used, while masking the details of those functions' implementation. Either way, it seems nitpicky at this point. While debatable, I would hardly call your professor "wrong" for saying that Java uses interfaces to implement ADTs. $\endgroup$ – jmite Jul 30 '13 at 1:56
  • $\begingroup$ Also, if you are going to debate semantics, you'd have to refer to your class's textbook, rather than Wikipedia. Often there isn't a unified terminology, so always go by the book your class is using. $\endgroup$ – jmite Jul 30 '13 at 1:57
  • 2
    $\begingroup$ Can you define any properties that differentiate an ADT from a Java interface? — That's easy. ADTs can be implemented in any programming language, but by definition, Java interfaces can only be written in Java. $\endgroup$ – JeffE Jul 31 '13 at 15:46
  • $\begingroup$ True, but you could port from Java to another language. In the cases of ADTs or Interfaces, you're really just translating from one format to another. The fact that one of these happens to be parseable and runnable on the JVM doesn't mean that it's not defining an ADT. $\endgroup$ – jmite Jul 31 '13 at 15:51
0
$\begingroup$

No, I don't think you have a leg to stand on.

To the extent that there is any ambiguity in the question, it seems pretty clear to me what is meant. It seems that the claim is: object-oriented languages allow (enable, make possible) you to construct (implement, build) an abstract data type in your code. The answer to that is "true": standard object-oriented languages do allow you to implement and use abstract data types in your code.

Your argument for "false" in particular strikes me as weak. ADTs are not merely theoretical: you can implement an ADT in your code, and people often do. To say that they are "merely" conceptual is to miss the point. If I said "A hammer allows me to construct a chair by nailing together pieces of wood", and you replied "false: the notion of a chair is merely conceptual", we'd all look at you funny. I think about the same applies here.

Object-oriented design is relevant to ADTs. To the extent that you think of object-oriented design as recommending you build encapsulated objects, then that encapsulation basically means you are building an ADT.

I would not recommend appealing your grade on this question. Save your appeals for situations where you have a more reasonable case.

$\endgroup$
  • 2
    $\begingroup$ If "allow" means "permit", the sentence has the same meaning as "Kittens allow ADTs to be created and used," which is formally true, but utterly useless. If "allow" means "is required for", the sentence is clearly false; consider the equivalent claim "ADTs cannot be created and used without OOD". You seem to be assuming that "allow" means "enable", which is not standard English. $\endgroup$ – JeffE Jul 31 '13 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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