-4

Is an Interface an object-oriented Data Structure?

Interview questions like write a data structure for a given problem have solutions which look a lot like Iterfaces, are interfaces and data structures the same?

For e.g. Data Structue for playing cards include method signatures which look a lot like Interfaces

user793468
  • 4,898
  • 23
  • 81
  • 126
  • I would look up some literature on Data Structures in general, the mere thought that an interface could be a data structure or vice-versa is an ambiguous question. – KillaBytes Aug 04 '15 at 21:37
  • 1
    @Kozmik What is your interpretaion? – user793468 Aug 04 '15 at 21:39
  • Well what do you consider an interface? Which data structure do you find synonymous with an interface (there is more than one structure you could be referring to)? You provided an example, but its overly broad - perhaps giving a more in depth example would be helpful or explain a little further about what you are noticing with the Data Structure for playing cards? What data structure is used for that? – KillaBytes Aug 04 '15 at 21:46
  • @Kozmik I though I was clear about that... Creating a data structure and the associated methods to define and manipulate a standard deck of playing cards... What more info do you need? Would like to know your interpretation – user793468 Aug 04 '15 at 21:50
  • I'm confused by your interpretation of the standard deck of playing cards - what data structure would you use to manipulate the deck as you've indicated? How is that data structure related to an interface? @GrayCygnus - answered your question well in that an interface is not a related to a data structure. I was more trying to help you along to an answer but Gray put it more succinctly. – KillaBytes Aug 04 '15 at 21:58

1 Answers1

1

Maybe you should check What is the definition of "interface" in object oriented programming

"Interface" can have several connotations, however in the OOP area it can be seen as a "contract" that all classes that implement (which is to explicitly use an interface) the interface agree to. It is also related to the concepts of polymorphism (which is to have a function with different kinds and number of parameters) and overwriting (which is what one does when "writing" the specific code of an implemented function in the class that uses it).

I would say that an Interface and a Data Structure are not the same thing. Data Structures are a more general concept, and include several ordinary structures like lists, arrays, stacks, hash tables, etc. Interfaces do not store any kind of data, other than its own code, and as mentioned above, only acquire an actual meaning when implemented.

Other way to see it is to consider that an Interface is an actual program (with the extention of your choice) whether a Data Structure is something that is used in the program, usually included in the Grammar of the language in use, or that can be built with other tools and data structures (for example you can implement your own node, and then use them to implement our own list, and then modify it to make a stack, etc.).

Community
  • 1
  • 1
DarkCygnus
  • 7,420
  • 4
  • 36
  • 59