When discussing software development, there is disagreement over the optimal level of abstraction to use. Despite the fact that abstraction is an essential part of software development, there is no consensus on the matter. In this article, we will explore the best level of abstraction to use in software development.
Many programmers take “explicit is better than implicit” from The Zen of Python to mean that abstraction should be avoided where possible. Therefore, it is seen as preferable to document all aspects of the code for maximum clarity. However, this view may be too simplistic; the second aphorism in the list is “simple is better than complicated”.
It is clear that achieving harmonious coexistence between code and complexity is no easy task. Striking the right balance between simplicity and complexity is essential and can only be achieved through the use of abstraction. If too much detail is included, the code may become too complicated, while oversimplifying could lead to an unreasonably complex code that is difficult to understand. Therefore, effective abstraction is key to maintaining the right balance.
Where does Abstraction fit into the Software Development Life Cycle?
When one hears the term ‘abstraction’, it is often associated with something intangible, such as a concept or theory. This is correct in the context of software development, however additional context is necessary to gain a full understanding. In this sense, ‘abstraction’ is a verb, meaning to take a theoretical and detached view of any subject.
By combining these two definitions, we can identify the fundamental concept: abstraction in software development is a way of simplifying complicated processes. The challenge then is to consider an element of our work and explore methods of representing it in a more concise manner.
An illustration of this concept in a real-world setting can help to clarify it further. When writing the command ‘print(“Hello, world”)’ in the console, the expected result is that “Hello, world.” is displayed on the screen. This fundamental lesson is often taught as the first step for those beginning to learn programming. However, could you elaborate further on the mechanism that allows this command to store the given data permanently? What is the precise process behind this?
It is understandable that the solution may not be immediately obvious; however, it is necessary to understand that the print() method consistently produces the same result (“Hello, world.”) in this example. This is considered an abstract programme due to its ability to produce the desired result with one line of code, despite its complexity. Knowing the inputs will enable you to accurately predict the results.
All functions abstract their complexity from the user, aiding in the development process. Libraries, database management systems, REST APIs and more provide further abstractions which make working with complex code easier. Without these abstractions, software development would be a challenging and arduous task.
Abstraction: The Foundation of Straightforward Program Design
It is understandable to think that there is nothing more to be said about how abstraction simplifies code by allowing programmers to complete complex tasks in a straightforward manner. However, it is important to note that the process of abstraction is ongoing and can be applied every time code is written. By doing so, it can lead to more efficient applications and simpler code.
It is clear that the application of abstractions can help improve code in various ways. Abstractions conceal unnecessary information, allowing only the relevant information to be displayed. This leads to a simpler and more manageable outcome, with less code required. Thus, abstraction is an important factor to consider when writing code.
Software can often consist of thousands of lines of code, making it a remarkable achievement. Using abstractions can help to improve the conciseness of the code and, more importantly, reduces hard dependencies on existing components. This means that changes can be made to these elements in the future without needing to modify every single line of code that relies on them.
Therefore, utilizing abstractions can make code easier to maintain in the long-term, as it can be made shorter and more comprehensible. This should be an aim all developers strive for, as all products require support and upkeep over time. By utilizing abstractions, it is simpler to make products last for a longer period of time.
A Mental Shift that’s Long Overdue
Abstractions are the basis of modern programming. It is fair to say that current applications are constructed from a variety of abstractions, making it essential to understand when to use them. Doing so can simplify development and help manage the ever-growing complexity.
It is likely that abstractions are already present in your product development process, even if you are not aware of it. To optimise your product quality and output, it is important to develop an intentional approach to using abstractions. Doing so will enable you to recognise when abstractions may be beneficial to your process.