Using Adts ( Abstract Data Types ) Has Advantages For Program Modularity
2267 WordsApr 27, 201610 Pages
Using ADTs (abstract data types) has advantages for program modularity.
the ability to define abstractions is an important skill for programmers to understand exactly what is mean by abstraction and how it applies to programming. We use abstractions all the time. For example, when we get in the car, we turn the key in the ignition and the car starts. We shift in to gear and drive. We do not need to know anything about what actually happens when we turn the key to be able to drive the car.
For example, when we use a vending machine, we insert coins in to a slot, push a button and reach into a window to take the item we selected. However, we do not know how the vending machine calculates that we have given it the correct change, or how pressing a button causes an item to be made available to us.
Both the user of the car and the user of the vending machine need to know very little about how the car or vending machine works. Details of the inner workings are hidden from the user. Also , the machines themselves are broken into modules.
For example, the vending machine has a mechanism that money that has been inserted and communicates with the item selection mechanism when enough coins have been inserted to pay an item.
Abstract data types serve the same function in programs: they hide unnecessary details from the user (called information hiding), and they allow the program to break up the problem into smaller more manageable pieces. [Should get in the