Abstract Data Type in Java
#1 Members - Reputation: 176
Posted 11 September 2012 - 10:26 PM
I wrote that it was a group of similar data types in a class together that performed a series of Mutations and accessing methods. it also makes the data processes hidden from a programmer that may just use the accessor and mutator methods to achieve what is needed with the driver.
I was given a D- and told I was way off.
Can someone help me figure out where I went wrong? Everything I look up seems similar to tha and some sites even just claim its a class with private variables.
Any help would be appreciated.
#2 Members - Reputation: 4604
Posted 11 September 2012 - 11:48 PM
My game: Gnoblins
Developer journal about Gnoblins
Small goodies: Simple alpha transparency in deferred shader
#3 Moderators - Reputation: 1533
Posted 12 September 2012 - 06:26 AM
I don't see anything wrong with your answer, except that, because of the D-, it wasn't the same as the guys definition.
"May the semicolons be ever in you favor."
Edited by Glass_Knife, 12 September 2012 - 06:27 AM.
#4 Moderators - Reputation: 6622
Posted 12 September 2012 - 06:46 AM
#5 Moderators - Reputation: 1533
Posted 12 September 2012 - 07:59 PM
You can add things, remove things, count things, iterate, sort, print, ect.
At what point does an abstract data type become concrete? All the data is hidden, and there can be concrete classes without any data held inside them. From a theoretical point of view, is any class that can be instantiated a concrete type, or is there more to it?
Just asking for my own knowledge. I never really thought about defining an abstract class, and I can see from my first post that I don't
really understand.
I am always amazed at how much I still don't know about computer science.
Edited by Glass_Knife, 12 September 2012 - 07:59 PM.
#6 Moderators - Reputation: 6622
Posted 13 September 2012 - 08:28 AM
At least part of the reason that we don't use these terms very often is that, outside the classroom, the line between abstract and concrete data type isn't particularly firm. For example, the definition of a std::vector in the C++ standard omits implementation details, but it's so specific that there are really very few ways that you can implement it. In particular there are big O guarantees for standard library types that go a long way in restricting implementation details.
However, if you are in a classroom, then abstract data types just define operations and concrete data types have implementations.
#7 Moderators - Reputation: 13471
Posted 13 September 2012 - 08:37 AM
I've seen ADT used a bit by C-educated colleagues. Where a C++-based programmer might say "abstract base class", or a Java programmer might say "interface", these guys would say "abstract data type", but we'd all mean the same thing.In practical terms, outside of the classroom, people don't use the terms abstract data type and concrete data type very often.
e.g. the abstract part
//Java guy says:
public interface Interface
{
int DoStuff();
}
public class InterfaceFactory
{
public static Interface Create();
}
//C++ guy says:
class ABC
{
public:
static ABC* New();
virtual ~ABC() = 0;
virtual int DoStuff() = 0;
};
//C guy says
typedef struct {} ADT;
ADT* ADT_Create();
void ADT_Destroy(ADT*);
int ADT_DoStuff(ADT*);And the (hidden) concrete backing://Java guy says:
public class Concrete implements Interface
{
public int DoStuff() { return 42 };
}
public class InterfaceFactory
{
public static Interface Create() { return new Concrete; }
}
//C++ guy says:
class Concrete : public ABC
{
public:
int DoStuff() { return 42; }
};
static ABC* ABC::New() { return new Concrete; }
//C guy says
typedef struct {} Concrete;
ADT* ADT_Create() { return (ADT*)malloc(sizeof(Concrete)); }
void ADT_Destroy(ADT* o) { free(o); }
int ADT_DoStuff(ADT* o) { return 42; }
Edited by Hodgman, 13 September 2012 - 08:57 AM.
#9 Moderator* - Reputation: 5344
Posted 13 September 2012 - 08:40 PM
Someone correct me if I'm wrong, but I think this would've been better:I'm a little confused as to what I should have written still.
Or something like that...[...] it
was a group of similar data types inis a class (or data type)togetherthatperformeddeclares a series of possible operations that my be performed on it, often with declared but undefined memberMutations and accessingmethods. italsomakes the dataprocessesand representation of the actual object hidden from a programmer and gives a common interface that may be used to abstractly interact with an underlying, possibly unknown concrete typethat may just use the accessor and mutator methods to achieve what is needed with the driver. For example, an abstract List type can declare a common interface for accessing and storing items sequentially. It does not require the underlying storage to use a contiguous array or a linked list; it makes no mention of class member objects (how the data is stored is abstracted away). Instead it provides a common, abstract interface that one may use to implement or interact with a concrete type (like an ArrayList or LinkedList). The concrete data type may then be abstractly treated as a generic List that fulfills the abstract List's contract (that is, you can sequentially store and access items, and you don't care if you have an ArrayList or a LinkedList; all you care about is the fact that you have a List).
Edited by Cornstalks, 13 September 2012 - 09:00 PM.
#10 Members - Reputation: 512
Posted 14 September 2012 - 01:43 AM
An abstract data type specifies a component's interface via signatures (e.g. "new: --> Stack, push: Stack x T --> Stack, size: Stack --> Integer") and it's visible behavior via axioms (e.g. "size(new()) = 0, size(push(A, x)) = size(A) + 1") but makes no statements at all about it's implementation.
Edited by lwm, 14 September 2012 - 01:45 AM.
my last project: Roa. working on something new now.






