문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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.

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 cs.stackexchange
scroll top