What Is Abstraction
What Is Abstraction
Abstraction is one of the four cornerstones of Computer Science. It involves filtering out
– essentially, ignoring - the characteristics that we don't need in order to concentrate on
those that we do.
How to abstract
Abstraction is the gathering of the general characteristics we need and the filtering out
of the details and characteristics that we do not need.
When baking a cake, there are some general characteristics between cakes. For
example:
a cake needs ingredients
each ingredient needs a specified quantity
a cake needs timings
When abstracting, we remove specific details and keep the general relevant patterns.
General patterns Specific details
We need to know that a cake has ingredients We don't need to know what those
ingredients are
We need to know that each ingredient has a We don’t need to know what that
specified quantity quantity is
We need to know that each cake needs a We don't need to know how long the
specified time to bake time is
Creating a model
A model is a general idea of the problem we are trying to solve.
For example, a model cat would be any cat. Not a specific cat with a long tail and short
fur - the model represents all cats. From our model of cats, we can learn what any cat
looks like, using the patterns all cats share.
Similarly, when baking a cake, a model cake wouldn’t be a specific cake, like a sponge
cake or a fruit cake. Instead, the model would represent all cakes. From this model we
can learn how to bake any cake, using the patterns that apply to all cakes.
Once we have a model of our problem, we can then design an algorithm to solve it.