
Public call functions are an essential component of many software architectures and designs.
Here is a deeper look at what public calls are, why they are used, and their importance in software development.
What are Public Call Functions?
A public call function in software is a function or method that is declared with the public access modifier.
This means it can be called and accessed by code external to the class or module where the function is defined.
Some key properties of public functions:
- They are part of the public interface or API of a class/module that other code can rely on.
- They allow for encapsulation – implementation details are hidden and external code only interacts through the public interface.
- They enable modular and reusable code architecture.
- They should be documented properly to allow external use.
- They can be invoked directly using the class and function name syntax.
Public functions contrasts with private functions which can only be called within the same class.
Why Use Public Functions?
There are several important reasons public functions are used in software design:
Enable Modular Architecture
Public functions allow classes to expose an interface that can be relied upon by other parts of the codebase.
This encourages modular architecture where each class encapsulates specific functionality and exposes a public API.
Code Reuse
With public functions, code in one class can leverage functionality defined in another class without having to know its implementations.
This allows reuse of code across the codebase.
Abstraction
The implementation details of a class can be hidden behind its public functions.
This provides abstraction that helps manage complexity.
Standardized Interface
Public functions enable a standardized interface for interacting with a class/module across the codebase.
External code simply relies on the public interface rather than internal implementation.
Facilitate Testing
Public functions enable better unit testing of classes in isolation using mock objects and stubs to simulate behaviour.
The interface remains standardized while internal implementation can be tested.
Better Collaboration
Public functions allow better division of responsibility and collaboration between classes.
Rather than monolithic classes, responsibilities can be divided across classes that provide and consume public functions.
Maintainable Code
With changes isolated through public functions, code is easier to maintain over time.
As long as the public interface remains the same, internal implementation can be changed without affecting external code.
Best Practices For Public Functions
Properly leveraging public functions requires some best practices:
- Provide clear and thorough documentation on usage of the public functions.
- Keep public interfaces and functions simple, concise and easy to use.
- Try to maintain backwards compatibility of public APIs over time.
- Avoid exposing unnecessary internal details through public functions.
- Use access modifiers properly to encapsulate private state and utility functions.
The Public Call Function in Liquid Loans

A key component of the Liquid Loans system is liquidations.
In order to maintain overcollateralization of USDL, any vaults under 110% must be liquidated.
In order to facilitate this process, users of the protocol are incentivized to liquidate vaults via a public call function.
Conclusion
Public call functions enable modular and reusable code by exposing a class’s capabilities through an interface abstracted from its internal details.
They facilitate better code organization, testing, collaboration and long-term maintenance. Following best practices for public APIs allows leveraging encapsulation and abstraction effectively.
In object oriented programming, public functions are a critical tool for managing complexity in large and complex software systems.