DEV Community

Cover image for The power of abstraction
Arik
Arik

Posted on • Originally published at creactiviti.com

The power of abstraction

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.

Oldest comments (9)

Collapse
 
ben profile image
Ben Halpern

Beautifully said

Collapse
 
cyprx profile image
Nam Nguyen

I like the example about human body.

Collapse
 
umardaraz profile image
umar-daraz

Well said

Collapse
 
rifaimartin profile image
Rifai Martin

the best

Collapse
 
rifaimartin profile image
Rifai Martin

I want to see more about writing like this, besides being easy to understand this looks very interesting

Collapse
 
thomasjunkos profile image
Thomas Junkツ • Edited

Abstraction is the most powerful and the most dangerous tool in your belt: you could build bridges over canyons or dig yourself into a hole.
Abstraction oftentimes comes with its evil brother complexity. You invite one to the party and both come. You need to have an eye on both.

Collapse
 
biros profile image
Boris Jamot ✊ /

So true!

We have to keep pragmatic.

Collapse
 
santeee profile image
Santee

YEAH!
The abstraction guide you to the real important thing, Design!
For me, in the Object oriented design, thanks to abstraction you can design the Business Logic with the Design Principles in mind, that's access you to better use of Interfaces or abstract classes.
At present, I work with people that just write code and create table in the databases. Those systems don't have design and maintenance is too hard.

Collapse
 
andrewjrdo profile image
Andrew Do Jr

That's the best shit that i ever heard about Abstraction