Abstract data types are used to describe an object without needing to know how it works.
A valet parking your car doesn’t care what’s under the hood. A valet’s job can be described by laying out an abstract concept of what he needs to do his job. He just needs a vehicle that accelerates, decelerates, turns left, turns right. A valet could park a plane with the interface below. A valet could park a boat. A valet doesn’t care that it’s a propeller or turbine making the plane go forward and backward. He doesn’t care that it’s a rudder moving the plane or boat left and right.
A valet can do his job as long as he has the methods below.
Object Vehicle
{
method Accelerate
method decelerate
method turn right
method turn left
}
In software, think about a system that needs to pull data from multiple sources. You could created an abstract concept of what the system needs. GetFirstName, GetLastName, GetPhoneNumber, etc… When a consumer needs to use that system, they would be in charge of creating their own object that implements this interface and actually does the things the methods describe. I need to GetFirstName, so I need to connect to a database, run a query based on parameters, get the data from the result set and send the first name back. How I do that is up to me, the systems doesn’t care how I implemented it, it just needs me to fill in the work.
Latest Answers