Here’s how your reusable code can be made easier with libraries.
If your organization has more than a single app or a number of common areas of functionality/APIs, you need to think of how to manage your codebase smarter by using reusable libraries.
Too often libraries are thought of as exclusively open-source projects that solve general problems across many teams. But both CocoaPods (iOS) and Gradle/Maven (Android) support using your own private repository for in-house reusable libraries. They’re a fantastic way to streamline your development processes.
Here are 5 advantages to making reusable libraries a deliberate part of your mobile app architecture:
1. Single point of testing
By combining oft-reused pieces into a library, you need only test that core functionality once. This means unit tests are more easily maintained, and that functional testing has already determined and squashed lots of bugs.
When this library is reused in another project, common mistakes and problems have already been accounted for, speeding the development.
A specialized but critical subset of the first point is security. A misstep in any part of your app can be problematic, but security holes can open your organization up to large legal and financial risk.
Third-party audits can look in-depth at the different aspects of the server/app communication and dig deep into any security concerns. Once verified, these are the things that can remain hardened without risk of forgetting any important aspects.
3. Cleaner code contracts
By standardizing the way your app interacts with the server, you can more cleanly express the handoff between the backend and the app. New developers (or developers working on a new project) have an easier time getting up to speed because it’s clear what pieces are wholly owned inside the app and which pieces are delegated.
It can also help vastly reduce the amount of boilerplate code that is sometimes required in connecting to and consuming an API, without forcing your API to fit into an easier to consume box. This adds to both the clarity and maintainability of both your server API code and app client code.
4. Controlled roll-out of new features
As the server adds new features, the library team can wrap those in the API. These releases can be pegged together and managed coherently with specific version numbers and tags. For instance, if you have 5 apps that roll their own individual login strategies and the server adds two-factor authentication, you now have 5 different things to re-code.
With a reusable library, you can simply roll out a new version which supports two-factor and the apps can incorporate it in the next release.
5. Dedicated teams/ownership
One of the biggest indicators of success, particularly in larger organizations, is having someone who is responsible and advocates for a key project. With a reusable library, you can build a team around that core piece of functionality.
If a dedicated team isn’t appropriate, there can at least be a specific owner to ensure that the concerns are not forgotten and the code is not stale. This means that you have a much higher chance that the functionality will be correct, consistent, and stable across all apps.