The traditional source of truth for applications is DBMS(SQL/NoSQL) and they rely on ORMs which natively support searching, sorting, filtering, pagination and more. As technologies evolved, applications moved beyond DBs and started to rely on APIs(typically REST endpoints) of other SaaS application. We all know the brighter side of SaaS offering but quite often these offering comes with numerous pitfalls, being:
Metered/usage based pricing - Most SaaS services are priced based on usage. To cut cost, engineers typically delay usage of such offerings to the right side stages of SDLC, leading to lose of such benefits during the early stage testing.
Vanilla implementations - As the complexity and requirements of today’s applications differ from each other, SaaS providers stick to vanilla API implementations and only based on the usage and requirements they implement features like searching, sorting, filtering, pagination that are commonly available in most ORM.
Additional/Competitive offerings - Another common observation that we’re seeing in modern applications is that instead of relying on one datasource they need to consider multiple sources to aggregate and consolidate the data. On the other hand, when there is an alternate system offering better features, it should be easy to switch to a new source because of business demands.
To overcome these pitfalls, developers are adopting intuitive, and at certain instances, old school approaches to tackle problems of this kind. Either way, one needs to spend time building features that are readily available in ORMs. We ourselves have come across similar situations more than a couple of times and decided to devote our time in solving this problem by building a library and open source it.
TechConative built an open source library inmemory-posf and published it, inmemory-posf would save developer effort and time, allowing them to concentrate on building modern, feature-rich applications.
By now you would have guessed the primary features for this library are searching, ordering, filtering, and of-course pagination, part of the obvious features that’s been highlighted in the problem statement.
Some more features of this library:
Let’s assume you have a social media as your datasource with the following json as response.
|
|
The following POJO could be it’s corresponding model class:
maven
gradle
POSFService
class from the library and override getRawData()
method
getRawData()
supplies the input data to our library
|
|
Now we’re all set to use the library, refer our GitHub repository for the criteria syntax.
|
|
|
|
pageResult.getData()
returns the processed dataset as per the criteria defined.
In case there are limitations in your design and not able to extend POSFService don't worry we have do have alternate approaches for you. Tweak Step #3 & Step #5 as the following
List
.
|
|
We have identified few features that could augment the current feature set:
Feel free to let us know your thoughts and feature suggestions that you would like built. We would be elated if you join us in building this library further. Meanwhile, You can also look through and contribute to the source in our git repository.