Over the years, I have participated in many development projects where we could use a DLL (Dynamic Link Library) or use an API.
This article will explain the differences between DLL and API, the pros and cons of each method, and introduce you to a new product, which I have developed.
To learn more about REST APIs, please see my article on REST and RESTful APIs.
What is a DLL?
A DLL is a library of code and data that can be used by more than one program simultaneously. For example, in Windows operating systems, the PrintConfig DLL performs standard Print Configuration User Interface and related functions that allow users to modify printer settings.
Therefore, each program can use the DLL to implement a Print dialog box.
DLLs help promote code reuse and efficient memory usage.
By using a DLL, modular programming, which puts the code into separate components, becomes easy.
For example, consider a POS application that has optional modules. The main program loads each module at run time if that module exists. Because the modules are separate, the program’s load time is shorter. A module is only loaded when that functionality is requested.
Moreover, It is easier to apply updates to each module without affecting other parts of the program. For example, you may have a payroll module in your POS application. By isolating the changes to a specific DLL responsible for the payroll functionality, you can apply an update without building or installing the whole program again.
The list below explains some of the advantages of using a DLL in your program:
1- Saving resources
A DLL can reduce code duplication ( loaded on the disk and in physical memory) when multiple programs use the same library. Saving resources can significantly improve the foreground program’s performance and the performance of other programs running in the background and the Windows OS.
2- Modular architecture
A DLL helps to develop modular programs. Modular programming enables you to create large programs that require multiple language versions or a program that requires modular architecture. An example of a modular program is a POS program with many modules. The POS software loads each module dynamically at run time.
3- Easy Deployment
When a DLL function needs an update, a fix, or an improvement, the DLL deployment and installation do not require the program to be relinked with the DLL. Furthermore, every program that uses the DLL will benefit from the update or the fix.
4- Easy Integration
Generally speaking, using a DLL for integration is easy.
API vs. DLL
Although I mentioned ease of deployment as an advantage of using a DLL, if you can use an API to achieve the same results, your code maintenance will be easier.
Web API is usually deployed from the cloud (or web). As new updates, fixes, or improvements occur, your code automatically and almost always benefit from the updates, without any efforts to update your code.
The most crucial factor to remember is that you can use a DLL only in Windows development. You can use a DLL in your Android or iOS development.
Even in a Windows environment, you may or may not have used the Dot Net Framework in your development. For example, if you are coding in standard C++. In these cases, if your DLL has Dot Net Framework requirements, you won’t be able to use them.
There is another family of DLLs, which we call unmanaged. In contrast to managed DLL, which depends heavily or partially on the presence of Dot Net Framework, an unmanaged DLL does not need the Dot Net Framework to operate.
So, you can see that using a Web API provides more freedom and also platform-independence.
There are cases in which a DLL becomes more useful than an API, assuming both options are available:
- A DLL could simplify a more complex API and provide a packaged solution that saves you development time.
- The API requires a certain level of knowledge or technology that is not present in your team.
- A DLL does not require a live internet connection. It will work offline, provided nothing that it does require online functionality.
- A DLL usually runs faster than an API.
- In the case of a lengthy process, an API could timeout. In contrast, a DLL could provide a scenario in which the machine is unresponsive, and your code might be able to handle that better.
API also has many advantages:
- Self-documenting is possible in API, whereas you have to maintain & ship documentation separately for a DLL.
- The server’s latest data is accessible to an API, whereas the DLL will need to download/update it first.
- The API always reflects the changes to the Business Logic. But a new version of the DLL is required.
- You can access an API from almost any platform, and it should work while the DLL is platform-dependent.
The list could go on, but it all depends on the application and availability of the DLL and the API.
For .NET (including .NET Core), the Microsoft-supported mechanism for sharing code is NuGet, which defines how packages for .NET are created, hosted, and consumed. It provides the tools for each of those roles.
Please read my article on NuGet.
If you are thinking about building an API for your application, then maybe you should create a DLL for that as well. Having a DLL not only helps you with developers who prefer the DLL and have better use for it.
Pi Process DLL
Although we have an extensive API for the semi-integrated solution, which supports multiple devices, I decided to build an easy-to-use DLL to help .Net Framework developers.
Pi Process provides several functions to conduct credit card transactions, gift card transactions, and ACH transactions.
Since I built the Pi Process based on an existing API, it supports several integrations and devices into a single function.
- Sound Payments
- Clearent ACH
- Gift Cards
For credit and debit card processing, Pi Process supports the following transaction types:
Gift card transactions:
One simple call is all it takes to perform a CreditSale() transaction, and Pi Process returns the results in a response object, which separates all fields for you:
PiProcess myProcess = new PiProcess();
myProcess.requestFields.Account = "xxxxxx";
myProcess.requestFields.Serial = "53xxxxxx";
myProcess.requestFields.Amount = $10.99;
myProcess.requestFields.MerchantID = "1";
myProcess.requestFields.Ticket = 100;
results = myProcess.CreditSale();
Each transaction type returns a boolean value, depends on the results of the transaction. True, for the approved transaction and False, for the declined transaction:
console.writeln("Transaction Result: " + myProcess.responseFields.TransactionResult );
console.writeln("Transaction ID: " +
console.writeln("Referenece No: " +
console.writeln("Approved Amount: " + myProcess.responseFields.ApprovedAmount );
console.writeln("Approval Code: " +
Similar calls provide you with the gift card and ACH transactions.
Please contact me if you want a copy of the Pi Process.
Both API and DLL provide many advantage to developers. You use these technologies to bring new and improved functions and features to your software and it’s if you want to offer an integration option to your consumer, you should consider both API and DLL, where possible.