All articles

Software Engineering

Abstract, Reuse & Ship Faster

Abstraction lets us reuse code and ship features faster. It allows us focus on business requirements rather than reinventing the wheel.

PC

Patrice Chaula

· 4 min read

Abstract, Reuse & Ship Faster

Abstraction is the process of hiding internal implementation details and showing only the essential part to the user. It focuses on what an object does rather than how it does it. An abstraction for a software component is a succinct description that suppresses the details that are unimportant to a software developer and emphasizes the information that is important. To understand why abstraction is necessary for reuse, we need to understand the computer at a low level.

The computer at a low level

A computer is another physical object just like trees, buildings and rocks. It's physical properties allow computer scientists and software engineers to abstract the physical processes happening within it. Data is an abstraction of electrical voltages stored either in CPU, RAM, SSD, HDD e.t.c. The lowest level of data abstraction are bits and bytes. From the bits and bytes more abstractions are created, these are data types. These data types are strings, integers, booleans and floats. We use these data types without understanding how they have been implemented. We don't need to build them over and over again, we just need to reuse them. Data abstraction is an abstraction of the computer's hardware memory.


A CPU has got instructions embedded into it. CPU instructions allow engineers to direct it to perform certain tasks. We use machine code to execute these instructions. To make things easier this machine code is hidden under levels of abstractions. Modern programming languages like C++, C and Rust compile to object code. A linker is used to compile object code into machine code. Languages like C++, C and Rust gives us abstracted components to use for operations like reading files, allocating memory, multithreading, multiprocessing functionality and more. This allows the programmer to focus on the business logic.


Abstraction is written everywhere in computers. For instance, the operating system is an abstraction, the browser is an abstraction. The operating system abstracts away the file system, process scheduling, virtual memory, sockets and device drivers. The browser abstracts away how content is fetched and loaded.

Modern abstraction and reuse

Software is an executable abstraction. It bridges the gap between pure thought and physical action. Software is authored as an abstraction to keep human programmers from going insane trying to manage billions of electrical currents manually. It makes sense to abstract it even more to make the lives of programmers easier. A large number of reusable libraries have been developed to make the lives of developers easy. Instead of developing features from scratch, developers install libraries. This cuts development costs and makes development faster. Most libraries allows developers to extend the library. This is done through parameters, inheritance, dependency injection and polymorphism.


Let's look at Django Web Framework. Django makes it easy for developers to develop backend APIs faster without worrying about handling multiple user connections. Django has got a built in object relational mapper library that allows developers to interact with the database without writing SQL code. This feature of django allows developers to write clean code. Developers do not need to include SQL statements in their Python code.


There are other libraries that support django to help with implementing different functionalities. I have listed some of them in the table below


Functionality

Library

Authentication and Registration

dj-rest-auth

Rest API

Django Rest Framework

Cross Origin Resource Sharing

django-cors-headers

PostgreSQL driver

psycopg


Let's look at another library called React.js. React let's you build user interfaces out of individual pieces called components. React abstracts away the DOM. It uses the virtual DOM. It keeps a lightweight in-memory representation of the UI. When something changes, it computes the difference between the old and the new versions. It updates only the parts of the real page that actually changed, rather than rebuilding everything. This makes updates efficient.


Most of the time there is no need to implement a solution from scratch. There is already a lot of open source libraries out there which can be reused. To use a library correctly, one needs to understand the properties of an abstracted component.

  1. Hidden part: This is the part that is not intended to be seen by the developer. It is used internally by the component. For example in a language like Java you attain this using the "private" access modifier.
  2. Fixed part: The fixed part is visible to the developer but cannot be changed. To achieve this in Java we use the "public" and "final" keyword.
  3. Variant part: This is the part the developer is allowed to modify. The developer can customize the component through parameters or overriding overridable methods.


When choosing an open source library check if the library is actively maintained. Check how many people are currently maintaining it. Check the number of stars on github. Check the number of issues reported on github. Check the maturity of the library.

Less admin. More learning.

Enrolments, lessons, invoices and progress in one place. Set up your institution today.

Get startedMore articles