In software projects, terms like abstractions, components, services, and libraries are often used in daily communication, and sometimes, it becomes confusing. They all describe reusable code, but each has specific connotations that help engineers communicate more effectively. Here's a brief overview of each.
1. Abstractions
Abstractions simplify complex systems by hiding unnecessary details and providing a simplified interface. For example, a data access layer abstracts database operations, allowing developers to work with higher-level concepts without dealing with SQL queries. This is a very broad term because any component, service, or library is indeed an abstraction, but we tend to use it to emphasize that we're hiding part of a problem's complexity.
Using abstractions is essential in computer science because, otherwise, our only tool would be electrical signals coming and going through a cable. Zeroes and ones abstract us from remembering the correct voltage representing an activated or deactivated state in a transistor. Logic gates are abstractions of a bunch of transistors, processors are abstractions of logic gates, and this goes all the way up to data structures that map to real-world concepts (like an invoice) or windows drawn on a screen (which are indeed just code drawing colored dots here and there).
2. Components
Components are modular, self-contained parts of a system that encapsulate specific functionality. They allow us to group the related code and better manage code responsibility (i.e., all the code related to managing tickets goes into the ticketing component). They are designed to be reusable and loosely coupled, meaning they interact with other components through well-defined interfaces. Component is still a generic term that can refer to almost any reusable piece of code. An example is a "user login form" in a web application or a set of functions that allow your software to make financial calculations.
3. Services
Services are independent components that provide specific functionality, often over a network. They are commonly used in service-oriented or microservices architectures, such as a "payment processing service" that handles payments through APIs. A service's key distinction is that it runs independently from the main program as a separate program so that it can be developed separately. The way to use a service is through the operating system's standard functions (Like inter-process messaging, files, pipes, or network messages).
Suppose you're developing an application that depends on a service. In that case, you'll need to start that service (Often a different app) before starting your application, and if you stop the service, your app will stop functioning. This is extremely useful when running your app on one computer and the service on another, which essentially enables the Internet. All websites are services running on someone's servers that the browser in our machine uses.
4. Libraries
Libraries are collections of reusable code that provide specific functionality to be embedded in your program, such as a "date manipulation library." Unlike services, libraries are distributed as part of the application code in the same program, so they cannot run independently on different machines. In other words, when we use libraries, they become part of our code in the final executable.
Dynamic libraries are a feature of modern operating systems that prevent common libraries from being duplicated in all programs. Because these libraries are often distributed independently, they can be confused with services, but they behave as if they were embedded in your app without any communication mechanism. The operating system dynamically links them when your app starts. When a program doesn't use dynamic libraries, we say it's a statically linked binary and has the advantage of being runnable anywhere without installing any dependencies.
Summary
- Abstractions simplify systems by hiding details.
- Components are reusable parts of a larger system.
- Services provide functionality independently, often distributed.
- Libraries are reusable code collections embedded in applications.
Libraries and services can be considered components of a larger system, as they encapsulate specific functionality and enhance the overall system architecture. Furthermore, all these concepts are ultimately abstractions, as they simplify complex functionality and make it easier for developers to work with software systems. These terms are important because they help us discuss how to reuse our code or use third-party code when creating new software.
Top comments (0)