BairesDev
  1. Blog
  2. Software Development
  3. Why Abstraction is the Key to Simple Code
Software Development

Why Abstraction is the Key to Simple Code

Abstraction is essential to balance.

Diego Espada

By Diego Espada

VP of Delivery Diego Espada works with every BairesDev team to ensure the quality of the company's work and to implement necessary methodologies.

5 min read

Featured image

Abstraction is one of those concepts that no one can agree on in software development. Not because someone argues that we could do without it, mind you (developing software wouldn’t be possible without abstraction). The discussion is about how much abstraction we should use when we build our applications. 

For instance, many people see The Zen of Python’s aphorism “explicit is better than implicit” and understand that abstraction occupies only a minor space in software development. Following those lines, it’s better to put everything into the code as a way to be as clear as possible. However, this feels like an oversimplification. In fact, the next aphorism in The Zen of Python’s list is “simple is better than complex.”

So, how do both of those live with one another? If you expressed everything, you’d end up with a massive code that would be impossible to work on. On the other hand, an oversimplification might lead to too many assumptions, which can leave the code beyond understandable (except for two individuals: you and God, and sometimes not even you). Faced with this scenario, it all starts to be clearer: simplifying the code is key, but in just measure. Abstraction is essential to achieve this balance – provided that you know the best contexts in which to use it.

 

What is Abstraction in Software Development?

When you hear the term “abstraction”, you likely think of something that isn’t physical, like an idea. While that’s part of what “abstraction” means in the development world, we need to add something to understand it fully. That has to do with “abstraction” as an action, that is, considering something from a theoretical perspective and separated from something else. 

So, if we combine both of those parts, it’s possible to get a more precise definition: in software development, abstraction is a way to simplify an idea or action. Thus, it’s the task of considering an element in our development and look for ways to express them more simply. 

A real-life example will surely help you understand this: when you type print (“Hello, world”) in the console, you know that you’ll see a “Hello, world.” imprinted on the screen. It’s pretty basic stuff, and that’s why it’s the first thing you learn as a developer when learning a new language. But for all its simplicity, could you explain how that simple command ends up imprinting that message? What’s the “magic” that makes that happen?

It’s likely that you don’t have the answer, but it’s ok. Why would you want to know that? You only need to know that if you use the print() function, you’ll get a specific output (in this case, the “Hello, world.”). As such, this program is an abstraction. It’s a single line of code that provides an expected output while “hiding” its inner workings. You only need to know what to input to anticipate the output. 

This function (all functions, really) hides all the complexity and allows you to use it more simply. Apart from functions, other abstractions are very common in software development: libraries, database management systems, REST APIs, and many more. Without these abstractions, developing software would be a herculean task because you’d have to work with complex code lines.

 

Abstraction As The Key To Simple Code

If the abstraction in software development allows developers to perform complex tasks through simple ways, you might think that there’s not much else to be said: abstraction makes code simple. While that’s true, it’s important to understand something else. Abstraction isn’t something that’s already done – it’s in constant evolution. In other words, every time you code, you can create your abstractions. And you definitely should, because it can help you develop better applications and much simpler code.

How come? Because using abstractions in the right way will make the code more readable, maintainable, and scalable. It does so by hiding away the details that ultimately don’t matter for the use at hand and only providing the relevant parts for that particular context. In other words, abstraction means less code, which, in turn, means a more manageable product.

That’s nothing to scoff at, especially when software means thousands of code lines. Using abstractions is useful because it lets you be more economical with what you write. What’s more important – they allow you to break free from hard dependencies on your current elements, which means that you can change those elements at any time in the future and only have to refactor the abstraction itself, not all the lines of code touched by what you changed. 

So, using abstractions means your code is simpler by being shorter and more readable but it also means it’s simpler for you to manage it in the future. That’s something any developer should aspire to, as all products will eventually be updated, upgraded, and maintained. Abstractions make it easier to provide a longer shelf-life to all the products you develop. 

 

A Necessary Change Of Mind

Modern programming is all about abstractions. In fact, we could say that modern applications are created on top of a multitude of abstractions and no one could argue. That’s why it’s so essential for you to learn when to use them. Doing that can make your development job more straightforward and manage increasing complexity with better oversight. 

If you’re already developing products, you’re already using abstractions, even if you don’t think about it. What you need to do now is put aside that unconscious use and make a mind shift by adopting abstractions as another tool in your set. By doing that, you’ll be able to identify better instances where abstractions could make a difference, thus creating better products and increasing your productivity. 

Diego Espada

By Diego Espada

Diego Espada, VP of Delivery, helps guide BairesDev team integrity of development practices through the growth experienced by the company each year. Working across all areas of dev, Espada ensures that every team utilizes BairesDev's stringent methodologies and level of quality.

Stay up to dateBusiness, technology, and innovation insights.Written by experts. Delivered weekly.

Related articles

Software Development - The Power of
Software Development

By BairesDev Editorial Team

18 min read

Contact BairesDev
By continuing to use this site, you agree to our cookie policy and privacy policy.