Abstract Data Type ( ADT )
Let us try to find a definition for Abstract before going anywhere near the computer relevance to this topic. This is the definition from google: "consider a concept without thinking of a specific example; consider abstractly or theoretically", meaning that being Abstract the object itself is not finaly defined. The term "Car" is abstract for instance. A Car is never really defined before you tell what kind of brand it is. The complete definition of an abstract object like Car would be "Saab" or "Volvo" and even this would be abstract.
So where is the relationship between programming and abstract types, the above example of a car is one of the probably most used and one of the best ones. But for variaty let's take something else as an example, this being; an Abstract List of items, which doesnt have a definition on compile time. So i'm not gonna give a specific object example.
Hence having the following problem; You are writing a program where you want to allocate objects such Items in your store, reserve parts to the items you are selling and so forth. How would you first define these? Well it's obvious, they are Items then there are definitions of an Item which, if talked about more, would take us on the the road of Object orientation and polymophism. However the topic is Abstract Data Type(s). Having a superclass called Item then subclasses that might be the following; Reserve Part, Store Item, Corporate Item these are all items and have stuff in common, but they might not want to be defined as just an "Item" because they might differ in some ways and somewhere in your code you might need to have a better definiton of the term "Item".
So having a group of sub-items, think of the following problem, we want to have these in some kind of list, maybe as an inventory list, how would this be done? Well we could easily use three different lists but then it wouldnt actually be a nice inventory set. This is where the abstraction comes in hand we define a list being: List<T>. T meaning that it can be whatever as long as all the items is type defined as the same Type. Now i need to clearify that
ReservePart derives from Item which will allow for polymorphism and inheritance and this will of cours let us store these objects in the same list.
So where is the relationship between programming and abstract types, the above example of a car is one of the probably most used and one of the best ones. But for variaty let's take something else as an example, this being; an Abstract List of items, which doesnt have a definition on compile time. So i'm not gonna give a specific object example.
Hence having the following problem; You are writing a program where you want to allocate objects such Items in your store, reserve parts to the items you are selling and so forth. How would you first define these? Well it's obvious, they are Items then there are definitions of an Item which, if talked about more, would take us on the the road of Object orientation and polymophism. However the topic is Abstract Data Type(s). Having a superclass called Item then subclasses that might be the following; Reserve Part, Store Item, Corporate Item these are all items and have stuff in common, but they might not want to be defined as just an "Item" because they might differ in some ways and somewhere in your code you might need to have a better definiton of the term "Item".
So having a group of sub-items, think of the following problem, we want to have these in some kind of list, maybe as an inventory list, how would this be done? Well we could easily use three different lists but then it wouldnt actually be a nice inventory set. This is where the abstraction comes in hand we define a list being: List<T>. T meaning that it can be whatever as long as all the items is type defined as the same Type. Now i need to clearify that
ReservePart derives from Item which will allow for polymorphism and inheritance and this will of cours let us store these objects in the same list.
Kommentarer
Trackback