The power of abstraction

Arik - Dec 6 '18 - - Dev Community

If someone had asked me "what is the number 1, absolutely most important concept in all of software development?" I would answer it using one word: "abstraction".

Abstraction is all about reducing an idea to its absolute essence.

Let's look at an example: take the activity of running. If you take a closer look at what is actually happening in your body while you run, your head would spin: a myriad of muscles are keeping your body balanced, your heart is pumping blood like crazy, your lungs are working full speed to keep your blood oxygenated, your sweat glands are pouring sweat on your skin to keep you cool and on and on.

But to you it's simply running. Your mind simply abstracted, or removed the non-essential details from this concept of running so you can easily think about it.

Let's look at another example. Here's some code:

var splitString = str.split("");
var reverseArray = splitString.reverse();
var joinArray = reverseArray.join("");
return joinArray;

Now let's add abstraction:

function reverseString (str) {
  var splitString = str.split("");
  var reverseArray = splitString.reverse();
  var joinArray = reverseArray.join("");
  return joinArray;
}

In the first example we have to read every line of code in sequence and keep track of what's happening in order to understand it. If this was part of a larger piece of code we would potentially have to do that over and over again throughout the lifetime of the software.

In the second example however, we give a name to that piece of code which lets us ignore the internal details and keep the essential concept in mind: reversing a string. Aha!

This idea is so central to computers (and life, really) that when you think about it for a moment you realize that the hardware and software you use every day are composed of "layers" (or abstractions) of software. From silicon to machine code, to assembly code, to the operating system, to your application code, each layer can be easily reasoned about without exploding our heads with details.

Creating clear abstraction in software is the essence of software design. It's the difference between understandable, easy to maintain software and a nightmare to deal with.

. . . . . . . . . . . . . . . . . . .
Terabox Video Player